Search in sources :

Example 1 with ServerRunningData

use of com.alibaba.otter.canal.common.zookeeper.running.ServerRunningData 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)

Example 2 with ServerRunningData

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

the class ClusterNodeAccessStrategy method initRunning.

private void initRunning(Object data) {
    if (data == null) {
        return;
    }
    ServerRunningData runningData = JsonUtils.unmarshalFromByte((byte[]) data, ServerRunningData.class);
    String[] strs = StringUtils.split(runningData.getAddress(), ':');
    if (strs.length == 2) {
        runningAddress = new InetSocketAddress(strs[0], Integer.valueOf(strs[1]));
    }
}
Also used : ServerRunningData(com.alibaba.otter.canal.common.zookeeper.running.ServerRunningData) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

ServerRunningData (com.alibaba.otter.canal.common.zookeeper.running.ServerRunningData)2 ServerRunningListener (com.alibaba.otter.canal.common.zookeeper.running.ServerRunningListener)1 ServerRunningMonitor (com.alibaba.otter.canal.common.zookeeper.running.ServerRunningMonitor)1 InetSocketAddress (java.net.InetSocketAddress)1