Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatcher cleanup #394

Merged
merged 17 commits into from
Apr 18, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class WorkflowDispatcher implements Runnable {
private static final Logger logger = getLogger(WorkflowDispatcher.class);
private static final PeriodicLogger periodicLogger = new PeriodicLogger(logger, 60);

private volatile boolean started;
private volatile boolean shutdownRequested;
private volatile boolean running;
private volatile boolean paused;
Expand Down Expand Up @@ -68,7 +67,6 @@ public WorkflowDispatcher(WorkflowInstanceExecutor executor, WorkflowInstanceDao
public void run() {
logger.info("Dispacther started.");
try {
started = true;
workflowDefinitions.postProcessWorkflowDefinitions();
running = true;
while (!shutdownRequested) {
Expand Down Expand Up @@ -101,20 +99,22 @@ public void run() {
}
}
} finally {
running = false;
shutdownPool();
executorDao.markShutdown();
running = false;
logger.info("Shutdown completed.");
shutdownDone.countDown();
}
}

public void shutdown() {
shutdownRequested = true;
if (started && shutdownDone.getCount() > 0) {
logger.info("Shutdown initiated.");
if (running) {
if (!shutdownRequested) {
logger.info("Initiating shutdown.");
shutdownRequested = true;
}
try {
shutdownDone.await();
logger.info("Shutdown completed.");
} catch (@SuppressWarnings("unused") InterruptedException e) {
logger.warn("Shutdown interrupted.");
}
Expand Down