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) {
 | 
			
		||||
            log.error("Failed to delete ZK node {}", nodePath, e);
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void destroyZkClient() {
 | 
			
		||||
        stopped = true;
 | 
			
		||||
        try {
 | 
			
		||||
            unpublishCurrentServer();
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
        }
 | 
			
		||||
        unpublishCurrentServer();
 | 
			
		||||
        CloseableUtils.closeQuietly(cache);
 | 
			
		||||
        CloseableUtils.closeQuietly(client);
 | 
			
		||||
        log.info("ZK client disconnected");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PreDestroy
 | 
			
		||||
    public void destroy() {
 | 
			
		||||
        destroyZkClient();
 | 
			
		||||
    private void destroy() {
 | 
			
		||||
        zkExecutorService.shutdownNow();
 | 
			
		||||
        destroyZkClient();
 | 
			
		||||
        log.info("Stopped discovery service");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user