Skip to content
Merged
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 @@ -43,6 +43,7 @@
import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -85,7 +86,7 @@ public final class WorkerManager {
/**
* An ExecutorService used to clean up TaskWorkers.
*/
private final ScheduledExecutorService workerCleanupExecutor;
private final ExecutorService workerCleanupExecutor;

/**
* An ExecutorService to help with shutting down.
Expand Down Expand Up @@ -161,7 +162,7 @@ synchronized void waitForQuiescence() throws InterruptedException {
this.workers = new HashMap<>();
this.stateChangeExecutor = Executors.newSingleThreadScheduledExecutor(
ThreadUtils.createThreadFactory("WorkerManagerStateThread", false));
this.workerCleanupExecutor = Executors.newScheduledThreadPool(1,
this.workerCleanupExecutor = Executors.newCachedThreadPool(
ThreadUtils.createThreadFactory("WorkerCleanupThread%d", false));
this.shutdownExecutor = Executors.newScheduledThreadPool(0,
ThreadUtils.createThreadFactory("WorkerManagerShutdownThread%d", false));
Expand Down Expand Up @@ -289,13 +290,13 @@ void transitionToRunning() {
Math.max(0, spec.endMs() - time.milliseconds()));
}

void transitionToStopping() {
Future<Void> transitionToStopping() {
state = State.STOPPING;
if (timeoutFuture != null) {
timeoutFuture.cancel(false);
timeoutFuture = null;
}
workerCleanupExecutor.submit(new HaltWorker(this));
return workerCleanupExecutor.submit(new HaltWorker(this));
}

void transitionToDone() {
Expand Down