Examples of CuratorTransactionFinal


Examples of org.apache.curator.framework.api.transaction.CuratorTransactionFinal

   */
  @Test
  public void testAtomicRecusiveDeleteWithConcurrentNodeAddition() throws Exception {
    final String path = "/foo/bar/baz/faz/fooz";
    mZKClient.create().creatingParentsIfNeeded().forPath(path);
    CuratorTransactionFinal tx =
        ZooKeeperUtils.buildAtomicRecursiveDelete(mZKClient, mZKClient.inTransaction(), "/foo");
    mZKClient.create().forPath("/foo/new-child");

    try {
      tx.commit();
    } catch (NotEmptyException nee) {
      // expected
    }
    Assert.assertNotNull(mZKClient.checkExists().forPath("/foo"));
  }
View Full Code Here

Examples of org.apache.curator.framework.api.transaction.CuratorTransactionFinal

   */
  @Test
  public void testAtomicRecusiveDeleteWithConcurrentNodeDeletion() throws Exception {
    final String path = "/foo/bar/baz/faz/fooz";
    mZKClient.create().creatingParentsIfNeeded().forPath(path);
    CuratorTransactionFinal tx =
        ZooKeeperUtils.buildAtomicRecursiveDelete(mZKClient, mZKClient.inTransaction(), "/foo");
    mZKClient.delete().forPath(path);

    try {
      tx.commit(); // should throw
    } catch (NoNodeException nne) {
      // expected
    }
    Assert.assertNotNull(mZKClient.checkExists().forPath("/foo"));
  }
View Full Code Here

Examples of org.apache.curator.framework.api.transaction.CuratorTransactionFinal

    try {
      final List<String> nodes = listRecursive(path);
      if (nodes.isEmpty()) {
        return;
      }
      final CuratorTransactionFinal t = client.inTransaction().check().forPath(path).and();
      for (final String node : reverse(nodes))  {
        t.delete().forPath(node).and();
      }
      t.commit();
    } catch (Exception e) {
      propagateIfInstanceOf(e, KeeperException.class);
      throw propagate(e);
    }
  }
View Full Code Here

Examples of org.apache.curator.framework.api.transaction.CuratorTransactionFinal

    if (operations.isEmpty()) {
      return emptyList();
    }

    // Assemble transaction
    final CuratorTransactionFinal transaction = (CuratorTransactionFinal) client.inTransaction();
    for (final ZooKeeperOperation operation : operations) {
      try {
        operation.register(transaction);
      } catch (final Exception e) {
        throw propagate(e);
      }
    }

    // Commit
    try {
      return transaction.commit();
    } catch (Exception e) {
      propagateIfInstanceOf(e, KeeperException.class);
      throw propagate(e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.