Skip to content

Commit 1b89f4d

Browse files
authored
add additional logging around shutdown, add fairness to shutdown semaphore (#343)
1 parent 5dc7589 commit 1b89f4d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

config/config.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pekkoConfiguration {
8383
seed-nodes=["pekko://[email protected]:2551"]
8484
downing-provider-class = "org.apache.pekko.cluster.sbr.SplitBrainResolverProvider"
8585
sharding {
86-
state-store-mode="persistence"
86+
state-store-mode="ddata"
8787
passivation {
8888
strategy = default-strategy
8989
default-strategy {

src/main/java/com/arpnetworking/clusteraggregator/Main.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,29 @@ public static void main(final String[] args) {
111111
configuration.get().launch();
112112

113113
// Wait for application shutdown
114+
LOGGER.info()
115+
.setMessage("Configurators launched, waiting for shutdown signal")
116+
.log();
114117
SHUTDOWN_SEMAPHORE.acquire();
118+
LOGGER.info()
119+
.setMessage("Shutdown signal received, shutting down main thread")
120+
.log();
115121
} catch (final InterruptedException e) {
116122
throw new RuntimeException(e);
117123
} finally {
118124
if (configurator.isPresent()) {
119125
configurator.get().shutdown();
126+
} else {
127+
LOGGER.warn()
128+
.setMessage("No configurator present to shut down")
129+
.log();
120130
}
121131
if (configuration.isPresent()) {
122132
configuration.get().shutdown();
133+
} else {
134+
LOGGER.warn()
135+
.setMessage("No running configuration present to shut down")
136+
.log();
123137
}
124138
// Notify the shutdown that we're done
125139
SHUTDOWN_SEMAPHORE.release();
@@ -284,7 +298,7 @@ private static Builder<? extends JsonNodeSource> getFileSourceBuilder(
284298
private static final Logger LOGGER = com.arpnetworking.steno.LoggerFactory.getLogger(Main.class);
285299
private static final Duration SHUTDOWN_TIMEOUT = Duration.ofMinutes(3);
286300
private static final SourceTypeLiteral SOURCE_TYPE_LITERAL = new SourceTypeLiteral();
287-
private static final Semaphore SHUTDOWN_SEMAPHORE = new Semaphore(0);
301+
private static final Semaphore SHUTDOWN_SEMAPHORE = new Semaphore(0, true);
288302
private static final Thread SHUTDOWN_THREAD = new ShutdownThread();
289303
private static final String HOCON_FILE_EXTENSION = ".conf";
290304

0 commit comments

Comments
 (0)