Exemple #1
0
 /** Deletes the given ZK path recursively and create the path again. */
 private ListenableFuture<String> deleteAndCreate(
     final String path, final byte[] data, final CreateMode mode) {
   return Futures.transform(
       ZKOperations.ignoreError(
           ZKOperations.recursiveDelete(zkClient, path),
           KeeperException.NoNodeException.class,
           null),
       new AsyncFunction<String, String>() {
         @Override
         public ListenableFuture<String> apply(String input) throws Exception {
           return zkClient.create(path, data, mode);
         }
       },
       Threads.SAME_THREAD_EXECUTOR);
 }
Exemple #2
0
  private OperationFuture<String> createLiveNode() {
    String liveNode = getLiveNodePath();
    LOG.info("Create live node " + liveNode);

    JsonObject content = new JsonObject();
    content.add("data", liveNodeData.get());
    return ZKOperations.ignoreError(
        zkClient.create(liveNode, encodeJson(content), CreateMode.EPHEMERAL),
        KeeperException.NodeExistsException.class,
        liveNode);
  }
Exemple #3
0
 private OperationFuture<String> removeLiveNode() {
   String liveNode = getLiveNodePath();
   LOG.info("Remove live node " + liveNode);
   return ZKOperations.ignoreError(
       zkClient.delete(liveNode), KeeperException.NoNodeException.class, liveNode);
 }