Search in sources :

Example 1 with ServerRunningListener

use of com.alibaba.otter.canal.common.zookeeper.running.ServerRunningListener in project canal by alibaba.

the class ServerRunningTest method buildServerRunning.

private ServerRunningMonitor buildServerRunning(final CountDownLatch countLatch, final Long cid, final String ip, final int port) {
    ServerRunningData serverData = new ServerRunningData(cid, ip + ":" + port);
    ServerRunningMonitor runningMonitor = new ServerRunningMonitor(serverData);
    runningMonitor.setDestination(destination);
    runningMonitor.setListener(new ServerRunningListener() {

        public void processActiveEnter() {
            System.out.println(String.format("cid:%s ip:%s:%s has start", cid, ip, port));
            countLatch.countDown();
        }

        public void processActiveExit() {
            System.out.println(String.format("cid:%s ip:%s:%s has stop", cid, ip, port));
            countLatch.countDown();
        }

        public void processStart() {
            System.out.println(String.format("cid:%s ip:%s:%s processStart", cid, ip, port));
        }

        public void processStop() {
            System.out.println(String.format("cid:%s ip:%s:%s processStop", cid, ip, port));
        }
    });
    runningMonitor.setZkClient(zkclientx);
    runningMonitor.setDelayTime(1);
    return runningMonitor;
}
Also used : ServerRunningData(com.alibaba.otter.canal.common.zookeeper.running.ServerRunningData) ServerRunningMonitor(com.alibaba.otter.canal.common.zookeeper.running.ServerRunningMonitor) ServerRunningListener(com.alibaba.otter.canal.common.zookeeper.running.ServerRunningListener)

Aggregations

ServerRunningData (com.alibaba.otter.canal.common.zookeeper.running.ServerRunningData)1 ServerRunningListener (com.alibaba.otter.canal.common.zookeeper.running.ServerRunningListener)1 ServerRunningMonitor (com.alibaba.otter.canal.common.zookeeper.running.ServerRunningMonitor)1