You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/09/06 01:07:18 UTC

logging-log4j2 git commit: Extends AbstractLifeCycle so we can call stop(long, TimeUnit) soon.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master ca5b53680 -> 35fc4345e


Extends AbstractLifeCycle so we can call
stop(long, TimeUnit) soon.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/35fc4345
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/35fc4345
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/35fc4345

Branch: refs/heads/master
Commit: 35fc4345e9496974e6a12acd398e9dc5b754e60d
Parents: ca5b536
Author: Gary Gregory <gg...@apache.org>
Authored: Mon Sep 5 21:07:15 2016 -0400
Committer: Gary Gregory <gg...@apache.org>
Committed: Mon Sep 5 21:07:15 2016 -0400

----------------------------------------------------------------------
 .../logging/log4j/core/async/AsyncLoggerDisruptor.java      | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/35fc4345/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
index 259e22d..f11b3ed 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
@@ -21,6 +21,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.AbstractLifeCycle;
 import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
 import org.apache.logging.log4j.core.util.Log4jThreadFactory;
 import org.apache.logging.log4j.status.StatusLogger;
@@ -37,7 +38,7 @@ import com.lmax.disruptor.dsl.ProducerType;
  * life cycle of the context. The AsyncLoggerDisruptor of the context is shared by all AsyncLogger objects created by
  * that AsyncLoggerContext.
  */
-class AsyncLoggerDisruptor {
+class AsyncLoggerDisruptor extends AbstractLifeCycle {
     private static final int SLEEP_MILLIS_BETWEEN_DRAIN_ATTEMPTS = 50;
     private static final int MAX_DRAIN_ATTEMPTS_BEFORE_SHUTDOWN = 200;
     private static final StatusLogger LOGGER = StatusLogger.getLogger();
@@ -72,7 +73,7 @@ class AsyncLoggerDisruptor {
      *
      * @see #stop()
      */
-    synchronized void start() {
+    public synchronized void start() {
         if (disruptor != null) {
             LOGGER.trace(
                     "[{}] AsyncLoggerDisruptor not starting new disruptor for this context, using existing object.",
@@ -102,13 +103,14 @@ class AsyncLoggerDisruptor {
 
         LOGGER.trace("[{}] AsyncLoggers use a {} translator", contextName, useThreadLocalTranslator ? "threadlocal"
                 : "vararg");
+        super.start();
     }
 
     /**
      * Decreases the reference count. If the reference count reached zero, the Disruptor and its associated thread are
      * shut down and their references set to {@code null}.
      */
-    synchronized void stop() {
+    public synchronized void stop() {
         final Disruptor<RingBufferLogEvent> temp = getDisruptor();
         if (temp == null) {
             LOGGER.trace("[{}] AsyncLoggerDisruptor: disruptor for this context already shut down.", contextName);
@@ -138,6 +140,7 @@ class AsyncLoggerDisruptor {
             LOGGER.trace("AsyncLoggerDisruptor: {} discarded {} events.", asyncQueueFullPolicy,
                     DiscardingAsyncQueueFullPolicy.getDiscardCount(asyncQueueFullPolicy));
         }
+        super.stop();
     }
 
     /**