curator
curator copied to clipboard
org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists
We ran into this problem in our own application and i can not find why this could happen (see below)
/workersMonitor : checkExist /workers : checkExist /workers/10.24.76.52 : node not exit /workers/10.24.76.52/state : node not exit 2015-03-31 09:23:35,768 ERROR [main] zookeeper.ZookeeperService (ZookeeperService.java:startWorker(331)) - Worker Register Error Happen, Maker Sure Zookeeper Server Can Be Connected org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists for /workers/10.24.76.52/state at org.apache.zookeeper.KeeperException.create(KeeperException.java:119) at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:783) at org.apache.curator.framework.imps.CreateBuilderImpl$11.call(CreateBuilderImpl.java:688) at org.apache.curator.framework.imps.CreateBuilderImpl$11.call(CreateBuilderImpl.java:672) at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107) at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:668) at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:453) at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:443) at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:44) at com.suning.cybertron.superion.worker.containermanager.zookeeper.ZookeeperClient.writeData(ZookeeperClient.java:123) at com.suning.cybertron.superion.worker.containermanager.zookeeper.ZookeeperClient.makeDir(ZookeeperClient.java:152) at com.suning.cybertron.superion.worker.containermanager.zookeeper.ZookeeperService.startWorker(ZookeeperService.java:315) at com.suning.cybertron.superion.worker.containermanager.zookeeper.ZookeeperService.serviceStart(ZookeeperService.java:86) at org.apache.hadoop.service.AbstractService.start(AbstractService.java:193) at org.apache.hadoop.service.CompositeService.serviceStart(CompositeService.java:121) at com.suning.cybertron.superion.worker.containermanager.ContainerManagerImpl.serviceStart(ContainerManagerImpl.java:230) at org.apache.hadoop.service.AbstractService.start(AbstractService.java:193) at org.apache.hadoop.service.CompositeService.serviceStart(CompositeService.java:121) at com.suning.cybertron.superion.worker.Worker.serviceStart(Worker.java:143) at org.apache.hadoop.service.AbstractService.start(AbstractService.java:193) at com.suning.cybertron.superion.worker.Worker.initAndStartNodeManager(Worker.java:182) at com.suning.cybertron.superion.worker.Worker.main(Worker.java:227)
LOG.info("Start With Worker IP:" + this.workerIP);
this.client.makeDir(SuperionConstant.ZOOKEEPER_WORKER_MONITOR_PATH);
this.client.makeDir(SuperionConstant.ZOOKEEPER_WORKER_PATH);
this.workerMonitorPath = SuperionConstant.ZOOKEEPER_WORKER_MONITOR_PATH + "/" + this.workerIP;
/** Ephemeral Node: /workersMonitor/192.168.0.2 */
this.client.createEphemeralNode(this.workerMonitorPath);
this.workerPath = SuperionConstant.ZOOKEEPER_WORKER_PATH + "/" + this.workerIP;
/** worker Node: /workers/192.168.0.2 */
this.client.makeDir(this.workerPath);
String workerStatePath = this.workerPath + "/" + "state";
/** Persistent Node: /workers/192.168.0.2/state */
this.client.makeDir(workerStatePath);
/** Persistent Node: /workers/192.168.0.2/state/ProcessID */
String workerStatePidPath = workerStatePath + "/" + "ProcessID";
this.client.writeInt32(workerStatePidPath, workerPID);
//this.client.makeDir(SuperionConstant.ZOOKEEPER_JOB_PATH);
/** Persistent Node: /jobs/tmp */
this.client.makeDir(SuperionConstant.ZOOKEEPER_JOB_TMP_PATH);
/** Persistent Node: /jobs/state */
this.client.makeDir(SuperionConstant.ZOOKEEPER_JOB_STATE_PATH);
public synchronized void writeData(String path,byte data[]) throws Exception {
if(this.client.checkExists().forPath(path)!=null) {
//node exit
System.out.println(path+" : checkExist");
this.client.setData().forPath(path, data);
} else {
//node not exit, create new
System.out.println(path+ " : node not exit");
this.client.create().creatingParentsIfNeeded()
.withMode(CreateMode.PERSISTENT).forPath(path, data);
}
}
我在dubbox(alibaba-dubbo.2.8.4)升级的过程中也碰到了这个异常org.apache.zookeeper.KeeperException$NodeExistsException:KeeperErrorCode= NodeExists for ........,始终无法解决啊。请问这个异常怎么解决,有人有解决方案吗?