mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
add ServerRunningMonitor.init
This commit is contained in:
@@ -87,6 +87,10 @@ public class ServerRunningMonitor extends AbstractCanalLifeCycle {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
processStart();
|
||||||
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
super.start();
|
super.start();
|
||||||
processStart();
|
processStart();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import org.I0Itec.zkclient.IZkStateListener;
|
import org.I0Itec.zkclient.IZkStateListener;
|
||||||
import org.I0Itec.zkclient.exception.ZkNoNodeException;
|
import org.I0Itec.zkclient.exception.ZkNoNodeException;
|
||||||
|
import org.I0Itec.zkclient.exception.ZkNodeExistsException;
|
||||||
import org.apache.commons.lang.BooleanUtils;
|
import org.apache.commons.lang.BooleanUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.zookeeper.Watcher.Event.KeeperState;
|
import org.apache.zookeeper.Watcher.Event.KeeperState;
|
||||||
@@ -172,6 +173,8 @@ public class CanalController {
|
|||||||
if (zkclientx != null) {
|
if (zkclientx != null) {
|
||||||
runningMonitor.setZkClient(zkclientx);
|
runningMonitor.setZkClient(zkclientx);
|
||||||
}
|
}
|
||||||
|
// 触发创建一下cid节点
|
||||||
|
runningMonitor.init();
|
||||||
return runningMonitor;
|
return runningMonitor;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@@ -448,6 +451,9 @@ public class CanalController {
|
|||||||
String parentDir = path.substring(0, path.lastIndexOf('/'));
|
String parentDir = path.substring(0, path.lastIndexOf('/'));
|
||||||
zkclientx.createPersistent(parentDir, true);
|
zkclientx.createPersistent(parentDir, true);
|
||||||
zkclientx.createEphemeral(path);
|
zkclientx.createEphemeral(path);
|
||||||
|
} catch (ZkNodeExistsException e) {
|
||||||
|
// ignore
|
||||||
|
// 因为第一次启动时创建了cid,但在stop/start的时可能会关闭和新建,允许出现NodeExists问题s
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user