geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sai_boorlaga...@apache.org
Subject [06/50] [abbrv] incubator-geode git commit: GEODE-1458: Prevent sequence logger from launching and closing a thread
Date Tue, 31 May 2016 21:25:36 GMT
GEODE-1458: Prevent sequence logger from launching and closing a thread

The sequence logger code was launching a thread from a static block,
even if it was not enabled. The thread was then immediately dying.
Fixing the code to not launch the thread unless it is enabled, and to
not die immediately if it is.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/1d11d94d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/1d11d94d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/1d11d94d

Branch: refs/heads/feature/GEODE-93
Commit: 1d11d94dfe600b99007ccdc28f178d98fd86fd30
Parents: fa6e722
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Fri May 20 14:06:13 2016 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed May 25 10:14:08 2016 -0700

----------------------------------------------------------------------
 .../sequencelog/SequenceLoggerImpl.java         | 21 ++++++++------------
 .../gemfire/internal/Bug49856JUnitTest.java     |  8 ++------
 2 files changed, 10 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1d11d94d/geode-core/src/main/java/com/gemstone/gemfire/internal/sequencelog/SequenceLoggerImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/sequencelog/SequenceLoggerImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/sequencelog/SequenceLoggerImpl.java
index 26c944e..678bc11 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/sequencelog/SequenceLoggerImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/sequencelog/SequenceLoggerImpl.java
@@ -31,9 +31,9 @@ import com.gemstone.gemfire.internal.sequencelog.io.OutputStreamAppender;
  */
 public class SequenceLoggerImpl implements SequenceLogger {
 
-  private static final SequenceLogger INSTANCE;
+  private static final SequenceLoggerImpl INSTANCE;
   
-  public static final String ENABLED_TYPES_PROPERTY = "gemfire.GraphLoggerImpl.ENABLED_TYPES";
+  public static final String ENABLED_TYPES_PROPERTY = "gemfire.SequenceLoggerImpl.ENABLED_TYPES";
   
   private final EnumSet<GraphType> enabledTypes;
   
@@ -59,8 +59,8 @@ public class SequenceLoggerImpl implements SequenceLogger {
    * Should be invoked when GemFire cache is closing or closed. 
    */
   public static void signalCacheClose() {
-    if (INSTANCE != null) {
-      ((SequenceLoggerImpl)INSTANCE).consumerThread.interrupt();
+    if (INSTANCE != null && INSTANCE.consumerThread != null) {
+      INSTANCE.consumerThread.interrupt();
     }
   }
 
@@ -95,8 +95,10 @@ public class SequenceLoggerImpl implements SequenceLogger {
   }
   
   private void start() {
-    consumerThread = new ConsumerThread();
-    consumerThread.start();
+    if(!enabledTypes.isEmpty()) {
+      consumerThread = new ConsumerThread();
+      consumerThread.start();
+    }
   }
 
   private class ConsumerThread extends Thread {
@@ -110,13 +112,6 @@ public class SequenceLoggerImpl implements SequenceLogger {
     public void run() {
       Transition edge;
       while(true) {
-        GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-        if (cache == null || cache.isClosed()) {
-          if (appender != null) {
-            appender.close();
-          }
-          break;
-        }
         try {
           edge = edges.take();
           if(edge instanceof FlushToken) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1d11d94d/geode-core/src/test/java/com/gemstone/gemfire/internal/Bug49856JUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/Bug49856JUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/Bug49856JUnitTest.java
index 1335b3d..48ba516 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/Bug49856JUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/Bug49856JUnitTest.java
@@ -42,7 +42,6 @@ public class Bug49856JUnitTest {
     GemFireCacheImpl cache = (GemFireCacheImpl)ccf.create();
 
     SystemFailure.getFailure();
-    SequenceLoggerImpl.getInstance();
 
     Thread.sleep(5000);
     // Assert the threads have been started.
@@ -65,20 +64,17 @@ public class Bug49856JUnitTest {
         watchDogRunning = true;
       } else if (t.getName().contains("SystemFailure Proctor")) {
         proctorRunning = true;
-      } else if (t.getName().contains("State Logger Consumer Thread")) {
-        loggerConsumerRunning = true;
       }
     }
     StringBuilder sb = new StringBuilder(new Date(System.currentTimeMillis()).toString());
     sb.append((watchDogRunning ^ expectThreads) ? " SystemFailure WatchDog, " : " ");
     sb.append((proctorRunning ^ expectThreads) ? "SystemFailure Proctor, " : "");
-    sb.append((loggerConsumerRunning ^ expectThreads) ? "State Logger Consumer Thread " :
"");
     sb.append(expectThreads ? "not started." : "still running.");
 
     if (expectThreads) {
-      assertTrue(sb.toString(), proctorRunning && watchDogRunning && loggerConsumerRunning);
+      assertTrue(sb.toString(), proctorRunning && watchDogRunning);
     } else {
-      assertTrue(sb.toString(), !proctorRunning && !watchDogRunning && !loggerConsumerRunning);
+      assertTrue(sb.toString(), !proctorRunning && !watchDogRunning);
     }
   }
 


Mime
View raw message