Package org.apache.zookeeper

Examples of org.apache.zookeeper.Transaction


        // 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));
View Full Code Here


        // 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",
View Full Code Here

        // 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));
View Full Code Here

        // read operation during r/o mode
        String remoteData = new String(zk.getData(node1, false, null));
        Assert.assertEquals("Failed to read data in r-o mode", data, remoteData);

        try {
            Transaction transaction = zk.transaction();
            transaction.setData(node1, "no way".getBytes(), -1);
            transaction.create(node2, data.getBytes(),
                    ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            transaction.commit();
            Assert.fail("Write operation using multi-transaction"
                    + " api has succeeded during RO mode");
        } catch (NotReadOnlyException e) {
            // ok
        }
View Full Code Here

        // 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",
View Full Code Here

        // read operation during r/o mode
        String remoteData = new String(zk.getData(node1, false, null));
        Assert.assertEquals("Failed to read data in r-o mode", data, remoteData);

        try {
            Transaction transaction = zk.transaction();
            transaction.setData(node1, "no way".getBytes(), -1);
            transaction.create(node2, data.getBytes(),
                    ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            transaction.commit();
            Assert.fail("Write operation using multi-transaction"
                    + " api has succeeded during RO mode");
        } catch (NotReadOnlyException e) {
            // ok
        }
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.Transaction

Copyright © 2018 www.massapicom. 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.