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;
}
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]));
}
}
Aggregations