Improve ZkDiscoveryService shutdown
This commit is contained in:
parent
aa0179303c
commit
16169dc728
@ -251,25 +251,21 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to delete ZK node {}", nodePath, e);
|
log.error("Failed to delete ZK node {}", nodePath, e);
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroyZkClient() {
|
private void destroyZkClient() {
|
||||||
stopped = true;
|
stopped = true;
|
||||||
try {
|
|
||||||
unpublishCurrentServer();
|
unpublishCurrentServer();
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
CloseableUtils.closeQuietly(cache);
|
CloseableUtils.closeQuietly(cache);
|
||||||
CloseableUtils.closeQuietly(client);
|
CloseableUtils.closeQuietly(client);
|
||||||
log.info("ZK client disconnected");
|
log.info("ZK client disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
public void destroy() {
|
private void destroy() {
|
||||||
destroyZkClient();
|
|
||||||
zkExecutorService.shutdownNow();
|
zkExecutorService.shutdownNow();
|
||||||
|
destroyZkClient();
|
||||||
log.info("Stopped discovery service");
|
log.info("Stopped discovery service");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user