Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

Expand Down Expand Up @@ -95,6 +95,7 @@ public ColocationLogger start() {
public void stop() {
synchronized (lock) {
missingChildren.clear();
executorService.shutdownNow();
lock.notifyAll();
}
}
Expand Down Expand Up @@ -151,6 +152,11 @@ List<String> getMissingChildren() {
return new ArrayList<>(missingChildren);
}

@VisibleForTesting
ExecutorService getExecutorService() {
return executorService;
}

private Runnable checkForMissingColocatedRegionRunnable() {
return this::checkForMissingColocatedRegion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand Down Expand Up @@ -213,4 +214,18 @@ public void updateAndGetMissingChildRegionsUpdatesMissingChildren() {
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());
}
}