|
@@ -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
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|