|
|
@ -189,18 +189,20 @@ public class ZookeeperOperator implements InitializingBean { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void persistEphemeral(final String key, final String value) { |
|
|
|
public void persistEphemeral(final String path, final String value) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (isExisted(key)) { |
|
|
|
// If the ephemeral node exist and the data is not equals to the given value
|
|
|
|
|
|
|
|
// delete the old node
|
|
|
|
|
|
|
|
if (isExisted(path) && !value.equals(get(path))) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
zkClient.delete().deletingChildrenIfNeeded().forPath(key); |
|
|
|
zkClient.delete().deletingChildrenIfNeeded().forPath(path); |
|
|
|
} catch (NoNodeException ignore) { |
|
|
|
} catch (NoNodeException ignore) { |
|
|
|
//NOP
|
|
|
|
//NOP
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
zkClient.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(StandardCharsets.UTF_8)); |
|
|
|
zkClient.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(path, value.getBytes(StandardCharsets.UTF_8)); |
|
|
|
} catch (final Exception ex) { |
|
|
|
} catch (final Exception ex) { |
|
|
|
logger.error("persistEphemeral key : {} , value : {}", key, value, ex); |
|
|
|
logger.error("persistEphemeral path : {} , value : {}", path, value, ex); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|