private void shutdown()

in tablestore/src/main/java/com/alicloud/openservices/tablestore/tunnel/worker/TunnelWorker.java [236:275]


    private void shutdown(boolean isHalt) {
        if (workerStatus.get().equals(TunnelWorkerStatus.WORKER_ENDED) ||
                workerStatus.get().equals(TunnelWorkerStatus.WORKER_HALT)) {
            LOG.info("Tunnel worker has already been {} status, skip shutdown logic.", workerStatus);
            return;
        }
        if (channelDialer != null) {
            LOG.info("Shutdown channel dialer");
            channelDialer.shutdown();
        }
        if (stateMachine != null) {
            LOG.info("Shutdown tunnel state machine.");
            stateMachine.close();
        }
        if (isHalt && heartbeatExecutor != null) {
            LOG.info("Shutdown heartbeat executor.");
            heartbeatExecutor.shutdownNow();
            try {
                if (heartbeatExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
                    LOG.info("Heartbeat executor termination success.");
                } else {
                    LOG.warn("Heartbeat executor termination until timeout");
                }
            } catch (InterruptedException e) {
                LOG.warn("Wait heartbeat executor termination failed", e);
            }
        }
        try {
            LOG.info("Shutdown tunnel, tunnelId: {}, clientId: {}", tunnelId, clientId);
            client.shutdownTunnel(new ShutdownTunnelRequest(tunnelId, clientId));
        } catch (Exception e) {
            LOG.warn("Shutdown tunnel failed, tunnelId: {}, clientId: {}", tunnelId, clientId, e);
        }
        LOG.info("Tunnel worker is ended.");
        if (isHalt) {
            workerStatus.set(TunnelWorkerStatus.WORKER_HALT);
        } else {
            workerStatus.set(TunnelWorkerStatus.WORKER_ENDED);
        }
    }