public synchronized void notifyStatus()

in tablestore/src/main/java/com/alicloud/openservices/tablestore/tunnel/worker/ChannelConnect.java [50:88]


    public synchronized void notifyStatus(Channel channel) {
        LOG.debug("Begin notify status, channel: {}", channel);
        if (currentChannel != null && currentChannel.getVersion() > channel.getVersion()) {
            return;
        }
        currentChannel = new Channel(channel);
        switch (currentChannel.getStatus()) {
            case CLOSE:
                LOG.info("Closed channel status {}", this);
                close(false);
                break;
            case CLOSING:
                //draw closing action and check closed/finish status
                if (status.get() == ChannelConnectStatus.WAIT) {
                    status.set(ChannelConnectStatus.CLOSED);
                } else {
                    status.compareAndSet(ChannelConnectStatus.RUNNING, ChannelConnectStatus.CLOSING);
                }
                checkAndUpdateChannelStatus();
                break;
            case OPEN:
                if (status.compareAndSet(ChannelConnectStatus.WAIT, ChannelConnectStatus.RUNNING)) {
                    // Submit the pipeline task, the pipeline will loop for data processing.
                    LOG.info("Submit pipeline task, channel connect :{}", this);
                    if (channelExecutorService != null) {
                        channelExecutorService.submit(processPipeline);
                    }
                } else {
                    checkAndUpdateChannelStatus();
                }
                break;
            case TERMINATED:
                LOG.info("Terminated channel status {}", this);
                close(true);
                break;
            default:
                LOG.warn("Unexpected channel status {}", this);
        }
    }