You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/03/22 12:55:38 UTC
[14/41] logging-log4j2 git commit: LOG4J2-1080
RingBufferLogEventTranslator optimization
LOG4J2-1080 RingBufferLogEventTranslator optimization
- increased visibility of some fields to protected to facilitate falling back to AsyncEventRouter when the queue is full
- RingBufferLogEventTranslator now initializes thread-related fields when the thread-local instance is constructed
- thread-related fields are not modified by default
- a separate method is available for modifying thread-related fields
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/43cefdd8
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/43cefdd8
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/43cefdd8
Branch: refs/heads/gelf-layout-gc-free
Commit: 43cefdd8677052230d7ccdfb762526f507225afc
Parents: 32e3069
Author: rpopma <rp...@apache.org>
Authored: Tue Mar 15 02:08:43 2016 +1100
Committer: rpopma <rp...@apache.org>
Committed: Tue Mar 15 02:08:43 2016 +1100
----------------------------------------------------------------------
.../async/RingBufferLogEventTranslator.java | 53 ++++++--------------
1 file changed, 15 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/43cefdd8/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java
index 37a4825..da15ed6 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java
@@ -36,16 +36,16 @@ public class RingBufferLogEventTranslator implements
private AsyncLogger asyncLogger;
private String loggerName;
- private Marker marker;
- private String fqcn;
- private Level level;
- private Message message;
- private Throwable thrown;
+ protected Marker marker;
+ protected String fqcn;
+ protected Level level;
+ protected Message message;
+ protected Throwable thrown;
private Map<String, String> contextMap;
private ContextStack contextStack;
- private long threadId;
- private String threadName;
- private int threadPriority;
+ private long threadId = Thread.currentThread().getId();
+ private String threadName = Thread.currentThread().getName();
+ private int threadPriority = Thread.currentThread().getPriority();
private StackTraceElement location;
private long currentTimeMillis;
private long nanoTime;
@@ -59,11 +59,10 @@ public class RingBufferLogEventTranslator implements
}
/**
- * Release references held by this object to allow objects to be
- * garbage-collected.
+ * Release references held by this object to allow objects to be garbage-collected.
*/
private void clear() {
- setValues(null, // asyncLogger
+ setBasicValues(null, // asyncLogger
null, // loggerName
null, // marker
null, // fqcn
@@ -72,18 +71,16 @@ public class RingBufferLogEventTranslator implements
null, // t
null, // map
null, // contextStack
- 0, // threadName
null, // location
0, // currentTimeMillis
- null,
- 0, 0 // nanoTime
+ 0 // nanoTime
);
}
- public void setValues(final AsyncLogger anAsyncLogger, final String aLoggerName, final Marker aMarker,
+ public void setBasicValues(final AsyncLogger anAsyncLogger, final String aLoggerName, final Marker aMarker,
final String theFqcn, final Level aLevel, final Message msg, final Throwable aThrowable,
- final Map<String, String> aMap, final ContextStack aContextStack, long threadId,
- final String threadName, int threadPriority, final StackTraceElement aLocation, final long aCurrentTimeMillis, final long aNanoTime) {
+ final Map<String, String> aMap, final ContextStack aContextStack, final StackTraceElement aLocation,
+ final long aCurrentTimeMillis, final long aNanoTime) {
this.asyncLogger = anAsyncLogger;
this.loggerName = aLoggerName;
this.marker = aMarker;
@@ -93,34 +90,14 @@ public class RingBufferLogEventTranslator implements
this.thrown = aThrowable;
this.contextMap = aMap;
this.contextStack = aContextStack;
- this.threadId = threadId;
- this.threadName = threadName;
- this.threadPriority = threadPriority;
this.location = aLocation;
this.currentTimeMillis = aCurrentTimeMillis;
this.nanoTime = aNanoTime;
}
- public void setValuesPart1(final AsyncLogger anAsyncLogger, final String aLoggerName, final Marker aMarker,
- final String theFqcn, final Level aLevel, final Message msg, final Throwable aThrowable) {
- this.asyncLogger = anAsyncLogger;
- this.loggerName = aLoggerName;
- this.marker = aMarker;
- this.fqcn = theFqcn;
- this.level = aLevel;
- this.message = msg;
- this.thrown = aThrowable;
- }
-
- public void setValuesPart2(final Map<String, String> aMap, final ContextStack aContextStack, long threadId,
- final String threadName, int threadPriority, final StackTraceElement aLocation, final long aCurrentTimeMillis, final long aNanoTime) {
- this.contextMap = aMap;
- this.contextStack = aContextStack;
+ public void setThreadValues(final long threadId, final String threadName, final int threadPriority) {
this.threadId = threadId;
this.threadName = threadName;
this.threadPriority = threadPriority;
- this.location = aLocation;
- this.currentTimeMillis = aCurrentTimeMillis;
- this.nanoTime = aNanoTime;
}
}