当前位置: 首页>>代码示例>>Java>>正文


Java Transaction.delete方法代码示例

本文整理汇总了Java中org.apache.zookeeper.Transaction.delete方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.delete方法的具体用法?Java Transaction.delete怎么用?Java Transaction.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.Transaction的用法示例。


在下文中一共展示了Transaction.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testChRootTransaction

import org.apache.zookeeper.Transaction; //导入方法依赖的package包/类
@Test
public void testChRootTransaction() throws Exception {
    // creating the subtree for chRoot clients.
    String chRoot = createNameSpace();
    // checking the child version using chRoot client.
    zk_chroot = createClient(this.hostPort + chRoot);
    String childPath = "/myid";
    Transaction transaction = zk_chroot.transaction();
    transaction.create(childPath, new byte[0], Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    transaction.check(childPath, 0);
    transaction.setData(childPath, childPath.getBytes(), 0);
    commit(transaction);

    Assert.assertNotNull("zNode is not created under chroot:" + chRoot, zk
            .exists(chRoot + childPath, false));
    Assert.assertNotNull("zNode is not created under chroot:" + chRoot,
            zk_chroot.exists(childPath, false));
    Assert.assertNull("zNode is created directly under '/', ignored configured chroot",
                    zk.exists(childPath, false));
    Assert.assertArrayEquals("zNode data not matching", childPath
            .getBytes(), zk_chroot.getData(childPath, false, null));

    transaction = zk_chroot.transaction();
    // Deleting child using chRoot client.
    transaction.delete(childPath, 1);
    commit(transaction);

    Assert.assertNull("chroot:" + chRoot + " exists after delete", zk
            .exists(chRoot + "/myid", false));
    Assert.assertNull("chroot:" + chRoot + " exists after delete",
            zk_chroot.exists("/myid", false));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:34,代码来源:MultiTransactionTest.java

示例2: testChRootTransaction

import org.apache.zookeeper.Transaction; //导入方法依赖的package包/类
@Test
public void testChRootTransaction() throws Exception {
    // creating the subtree for chRoot clients.
    String chRoot = createNameSpace();
    // checking the child version using chRoot client.
    zk_chroot = createClient(this.hostPort + chRoot);
    String childPath = "/myid";
    Transaction transaction = zk_chroot.transaction();
    transaction.create(childPath, new byte[0], Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    transaction.check(childPath, 0);
    transaction.setData(childPath, childPath.getBytes(), 0);
    transaction.commit();

    Assert.assertNotNull("zNode is not created under chroot:" + chRoot, zk
            .exists(chRoot + childPath, false));
    Assert.assertNotNull("zNode is not created under chroot:" + chRoot,
            zk_chroot.exists(childPath, false));
    Assert.assertNull("zNode is created directly under '/', ignored configured chroot",
                    zk.exists(childPath, false));
    Assert.assertArrayEquals("zNode data not matching", childPath
            .getBytes(), zk_chroot.getData(childPath, false, null));

    transaction = zk_chroot.transaction();
    // Deleting child using chRoot client.
    transaction.delete(childPath, 1);
    transaction.commit();

    Assert.assertNull("chroot:" + chRoot + " exists after delete", zk
            .exists(chRoot + "/myid", false));
    Assert.assertNull("chroot:" + chRoot + " exists after delete",
            zk_chroot.exists("/myid", false));
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:MultiTransactionTest.java

示例3: testTransaction

import org.apache.zookeeper.Transaction; //导入方法依赖的package包/类
@Test
public void testTransaction() throws Exception {
  zkClient.create("/transaction", "transaction".getBytes(), OPEN_ACL, CreateMode.PERSISTENT) ;
  Transaction transaction = zkClient.transaction();
  transaction.create("/transaction/test", new byte[0], OPEN_ACL, CreateMode.PERSISTENT);
  transaction.create("/transaction/test/nested", new byte[0], OPEN_ACL, CreateMode.PERSISTENT);
  transaction.create("/transaction/test/delete", new byte[0], OPEN_ACL, CreateMode.PERSISTENT);
  transaction.delete("/transaction/test/delete", 0);
  Assert.assertNull(zkClient.exists("/transaction/test", false));
  Assert.assertNull(zkClient.exists("/transaction/test/nested", false));
  transaction.commit();
  Assert.assertNotNull(zkClient.exists("/transaction/test", false));
  Assert.assertNotNull(zkClient.exists("/transaction/test/nested", false));
  Assert.assertNull(zkClient.exists("/transaction/test/delete", false));
}
 
开发者ID:DemandCube,项目名称:Scribengin,代码行数:16,代码来源:ZookeeperTransactionUnitTest.java


注:本文中的org.apache.zookeeper.Transaction.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。