You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by nn...@apache.org on 2021/03/26 23:19:50 UTC

[geode] branch support/1.12 updated: GEODE-9040: Shutdown ExecutorService when the SingleThreadColocationLogger is stopped (#6205)

This is an automated email from the ASF dual-hosted git repository.

nnag pushed a commit to branch support/1.12
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/support/1.12 by this push:
     new 65e7fee  GEODE-9040: Shutdown ExecutorService when the SingleThreadColocationLogger is stopped (#6205)
65e7fee is described below

commit 65e7fee5edbb612a44e77731acfbe77f7f4e5ea9
Author: Barry Oglesby <bo...@users.noreply.github.com>
AuthorDate: Fri Mar 26 13:18:37 2021 -1000

    GEODE-9040: Shutdown ExecutorService when the SingleThreadColocationLogger is stopped (#6205)
    
    (cherry picked from commit 3b422bbe9631b7531633671a3938ed9600cfbc6e)
---
 .../colocation/SingleThreadColocationLogger.java          |  8 +++++++-
 .../colocation/SingleThreadColocationLoggerTest.java      | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLogger.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLogger.java
index 6d74f74..247fb9d 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLogger.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLogger.java
@@ -63,7 +63,7 @@ public class SingleThreadColocationLogger implements ColocationLogger {
     this(region, delayMillis, intervalMillis, LOGGER::warn,
         pr -> getAllColocationRegions(pr).keySet(),
         newSingleThreadExecutor(
-            runnable -> new LoggingThread("ColocationLogger for " + region.getName(), false,
+            runnable -> new LoggingThread("ColocationLogger for " + region.getName(), true,
                 runnable)));
   }
 
@@ -95,6 +95,7 @@ public class SingleThreadColocationLogger implements ColocationLogger {
   public void stop() {
     synchronized (lock) {
       missingChildren.clear();
+      executorService.shutdownNow();
       lock.notifyAll();
     }
   }
@@ -151,6 +152,11 @@ public class SingleThreadColocationLogger implements ColocationLogger {
     return new ArrayList<>(missingChildren);
   }
 
+  @VisibleForTesting
+  ExecutorService getExecutorService() {
+    return executorService;
+  }
+
   private Runnable checkForMissingColocatedRegionRunnable() {
     return this::checkForMissingColocatedRegion;
   }
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLoggerTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLoggerTest.java
index ae1bb44..c9d66f3 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLoggerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/colocation/SingleThreadColocationLoggerTest.java
@@ -17,6 +17,7 @@ package org.apache.geode.internal.cache.partitioned.colocation;
 import static java.lang.System.lineSeparator;
 import static java.util.Collections.singleton;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.catchThrowable;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -214,4 +215,18 @@ public class SingleThreadColocationLoggerTest {
     assertThat(colocationLogger.getMissingChildren())
         .isEmpty();
   }
+
+  @Test
+  public void stopTerminatesExecutorService() {
+    SingleThreadColocationLogger colocationLogger =
+        new SingleThreadColocationLogger(region, 500, 1000, logger,
+            allColocationRegionsProvider, executorService);
+    colocationLogger.start();
+
+    colocationLogger.stop();
+
+    // Wait until the ExecutorService is terminated
+    await().untilAsserted(
+        () -> assertThat(colocationLogger.getExecutorService().isTerminated()).isTrue());
+  }
 }