Skip to content

Commit

Permalink
ISPN-1388 All executors should be shutdown centrally
Browse files Browse the repository at this point in the history
  • Loading branch information
galderz authored and maniksurtani committed Sep 16, 2011
1 parent 861d412 commit bff5a04
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
Expand Up @@ -202,7 +202,13 @@ public void stop() {
l.cacheManagerStopping(this);
}
}

// Grab the executor factory
NamedExecutorsFactory execFactory = getComponent(NamedExecutorsFactory.class);
super.stop();
// Now that all components are stopped, shutdown their executors
execFactory.stop();

if (state == ComponentStatus.TERMINATED && needToNotify) {
for (ModuleLifecycle l : moduleLifecycles) {
l.cacheManagerStopped(this);
Expand Down
Expand Up @@ -100,6 +100,13 @@ public <T> T construct(Class<T> componentType, String componentName) {
}
}

public void stop() {
if (notificationExecutor != null) notificationExecutor.shutdownNow();
if (asyncTransportExecutor != null) asyncTransportExecutor.shutdownNow();
if (asyncReplicationExecutor != null) asyncReplicationExecutor.shutdownNow();
if (evictionExecutor != null) evictionExecutor.shutdownNow();
}

private ExecutorService buildAndConfigureExecutorService(String factoryName, Properties p, String componentName) throws Exception {
Properties props = new Properties(p); // defensive copy
if (p != null && !p.isEmpty()) props.putAll(p);
Expand Down
Expand Up @@ -80,7 +80,6 @@ void stop() {
}

if (syncProcessor != null) syncProcessor.shutdownNow();
if (asyncProcessor != null) asyncProcessor.shutdownNow();
}

protected abstract Log getLog();
Expand Down
Expand Up @@ -115,11 +115,6 @@ private void start() {
statisticsEnabled = configuration.isExposeJmxStatistics();
}

@Stop(priority = 9)
private void stop() {
asyncExecutor.shutdown();
}

private boolean useReplicationQueue(boolean sync) {
return !sync && replicationQueue != null && replicationQueue.isEnabled();
}
Expand Down
Expand Up @@ -217,8 +217,6 @@ public void stop() {
dispatcher.stop();
}

asyncExecutor.shutdown();

members = Collections.emptyList();
coordinator = false;
dispatcher = null;
Expand Down

0 comments on commit bff5a04

Please sign in to comment.