Skip to content

Commit

Permalink
#287 fix for 2.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
he7g committed Nov 10, 2017
1 parent d68251d commit 8947e32
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ShardingListenerManager extends AbstractListenerManager {

private ExecutorService executorService;

private ConnectionStateListener connectionStateListener;

public ShardingListenerManager(final JobScheduler jobScheduler) {
super(jobScheduler);
shardingService = jobScheduler.getShardingService();
Expand All @@ -49,7 +51,7 @@ public void start() {
executorService = Executors.newSingleThreadExecutor(
new SaturnThreadFactory(executorName + "-" + jobName + "-registerNecessaryWatcher", false));
shardingService.registerNecessaryWatcher(necessaryWatcher);
addConnectionStateListener(new ConnectionStateListener() {
connectionStateListener = new ConnectionStateListener() {
@Override
public void stateChanged(CuratorFramework client, ConnectionState newState) {
if ((newState == ConnectionState.CONNECTED) || (newState == ConnectionState.RECONNECTED)) {
Expand All @@ -59,7 +61,8 @@ public void stateChanged(CuratorFramework client, ConnectionState newState) {
registerNecessaryWatcher();
}
}
});
};
addConnectionStateListener(connectionStateListener);
}
}

Expand All @@ -69,6 +72,9 @@ public void shutdown() {
if (executorService != null) {
executorService.shutdownNow();
}
if (connectionStateListener != null) {
removeConnectionStateListener(connectionStateListener);
}
isShutdown = true;
}

Expand Down

0 comments on commit 8947e32

Please sign in to comment.