class WorkerRegistry {

    public void registry() {
        String address = NetUtils.getHost();
        Set<String> workerZkPaths = getWorkerZkPaths();
        int workerHeartbeatInterval = workerConfig.getWorkerHeartbeatInterval();

        for (String workerZKPath : workerZkPaths) {
            zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(workerZKPath, "");
            zookeeperRegistryCenter.getZookeeperCachedOperator().getZkClient().getConnectionStateListenable().addListener(new ConnectionStateListener() {
                @Override
                public void stateChanged(CuratorFramework client, ConnectionState newState) {
                    if (newState == ConnectionState.LOST) {
                        logger.error("worker : {} connection lost from zookeeper", address);
                    } else if (newState == ConnectionState.RECONNECTED) {
                        logger.info("worker : {} reconnected to zookeeper", address);
                        zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(workerZKPath, "");
                    } else if (newState == ConnectionState.SUSPENDED) {
                        logger.warn("worker : {} connection SUSPENDED ", address);
                    }
                }
            });
            logger.info("worker node : {} registry to ZK {} successfully", address, workerZKPath);
        }

        HeartBeatTask heartBeatTask = new HeartBeatTask(this.startTime,
            this.workerConfig.getWorkerReservedMemory(),
            this.workerConfig.getWorkerMaxCpuloadAvg(),
            workerZkPaths,
            this.zookeeperRegistryCenter);

        this.heartBeatExecutor.scheduleAtFixedRate(heartBeatTask, workerHeartbeatInterval, workerHeartbeatInterval, TimeUnit.SECONDS);
        logger.info("worker node : {} heartbeat interval {} s", address, workerHeartbeatInterval);
    }

}