if (rc == Code.OK.intValue()) {
callback.operationFinished(ctx, null);
return;
}
if (rc != Code.NODEEXISTS.intValue()) {
KeeperException ke = ZkUtils.logErrorAndCreateZKException(
"Could not create ephemeral node to register hub", ephemeralNodePath, rc);
callback.operationFailed(ctx, new PubSubException.ServiceDownException(ke));
return;
}
logger.info("Found stale ephemeral node while registering hub with ZK, deleting it");
// Node exists, lets try to delete it and retry
zk.delete(ephemeralNodePath, -1, new SafeAsyncZKCallback.VoidCallback() {
@Override
public void safeProcessResult(int rc, String path, Object ctx) {
if (rc == Code.OK.intValue() || rc == Code.NONODE.intValue()) {
registerWithZookeeper(callback, ctx);
return;
}
KeeperException ke = ZkUtils.logErrorAndCreateZKException(
"Could not delete stale ephemeral node to register hub", ephemeralNodePath, rc);
callback.operationFailed(ctx, new PubSubException.ServiceDownException(ke));
return;
}