Package org.apache.zookeeper_voltpatches

Examples of org.apache.zookeeper_voltpatches.ZooKeeper$ExistsWatchRegistration


    }

    @Test
    public void testDeleteChildWithCallback() throws Exception
    {
        ZooKeeper zk = getClient(0);
        configure("/cache02", zk);

        TestCallback cb = new TestCallback();
        MapCache dut = new MapCache(zk, "/cache02", cb);
        dut.start(true);
        Map<String, JSONObject> cache = cb.m_cache;
        assertEquals("3 items cached.", 3, cache.size());

        zk.delete("/cache02/bb", -1);
        while(true) {
            cache = cb.m_cache;
            if (cache.size() == 3) {
                Thread.sleep(1);
            }
            else {
                break;
            }
        }
        assertEquals("Item removed", 2, cache.size());
        assertEquals(null, cache.get("/cache02/bb"));
        assertEquals("aaval", cache.get("/cache02/aa").get("key"));
        assertEquals("ccval", cache.get("/cache02/cc").get("key"));

        dut.shutdown();
        zk.close();
    }
View Full Code Here


    }

    @Test
    public void testAddChildWithPut() throws Exception
    {
        ZooKeeper zk = getClient(0);
        configure("/cache04", zk);

        MapCache dut = new MapCache(zk, "/cache04");
        dut.start(true);
        Map<String, JSONObject> cache = dut.pointInTimeCache();

        JSONObject dd = new JSONObject("{key:ddval}");
        dut.put("dd", dd);

        while(true) {
            cache = dut.pointInTimeCache();
            if (cache.size() == 3) {
                Thread.sleep(1);
            }
            else {
                break;
            }
        }
        assertEquals("Item added", 4, cache.size());
        assertEquals("aaval", cache.get("/cache04/aa").get("key"));
        assertEquals("bbval", cache.get("/cache04/bb").get("key"));
        assertEquals("ccval", cache.get("/cache04/cc").get("key"));
        assertEquals("ddval", cache.get("/cache04/dd").get("key"));

        // modify the new child and make sure it has a watch set.
        JSONObject dd2 = new JSONObject("{key:ddval2}");
        dut.put("dd", dd2);
        while(true) {
            cache = dut.pointInTimeCache();
            if (cache.get("/cache04/dd").get("key").equals("ddval2")) {
                break;
            }
        }
        assertEquals("Items accounted for.", 4, cache.size());
        assertEquals("ddval2", cache.get("/cache04/dd").get("key"));

        dut.shutdown();
        zk.close();
    }
View Full Code Here

    }

    @Test
    public void testAddChildWithPutWithCallback() throws Exception
    {
        ZooKeeper zk = getClient(0);
        configure("/cache04", zk);

        TestCallback cb = new TestCallback();
        MapCache dut = new MapCache(zk, "/cache04", cb);
        dut.start(true);
        Map<String, JSONObject> cache = cb.m_cache;

        JSONObject dd = new JSONObject("{key:ddval}");
        dut.put("dd", dd);

        while(true) {
            cache = cb.m_cache;
            if (cache.size() == 3) {
                Thread.sleep(1);
            }
            else {
                break;
            }
        }
        assertEquals("Item added", 4, cache.size());
        assertEquals("aaval", cache.get("/cache04/aa").get("key"));
        assertEquals("bbval", cache.get("/cache04/bb").get("key"));
        assertEquals("ccval", cache.get("/cache04/cc").get("key"));
        assertEquals("ddval", cache.get("/cache04/dd").get("key"));

        // modify the new child and make sure it has a watch set.
        JSONObject dd2 = new JSONObject("{key:ddval2}");
        dut.put("dd", dd2);
        while(true) {
            cache = cb.m_cache;
            if (cache.get("/cache04/dd").get("key").equals("ddval2")) {
                break;
            }
        }
        assertEquals("Items accounted for.", 4, cache.size());
        assertEquals("ddval2", cache.get("/cache04/dd").get("key"));

        dut.shutdown();
        zk.close();
    }
View Full Code Here

    /*
     * Inherit the per partition txnid from the long since gone
     * partition that existed in the past
     */
    private long[] fetchPerPartitionTxnId() {
        ZooKeeper zk = VoltDB.instance().getHostMessenger().getZK();
        byte partitionTxnIdsBytes[] = null;
        try {
            partitionTxnIdsBytes = zk.getData(VoltZK.perPartitionTxnIds, false, null);
        } catch (KeeperException.NoNodeException e){return null;}//Can be no node if the cluster was never restored
        catch (Exception e) {
            VoltDB.crashLocalVoltDB("Error retrieving per partition txn ids", true, e);
        }
        ByteBuffer buf = ByteBuffer.wrap(partitionTxnIdsBytes);
View Full Code Here

        assertTrue(results.length == 1);

        loadSomeData(client, 65, 5);

        //Check that if a catalog update blocker exists the catalog update fails
        ZooKeeper zk = ZKUtil.getClient(((LocalCluster) m_config).zkinterface(0), 10000, new HashSet<Long>());
        final String catalogUpdateBlockerPath = zk.create(
                VoltZK.elasticJoinActiveBlocker,
                null,
                ZooDefs.Ids.OPEN_ACL_UNSAFE,
                CreateMode.EPHEMERAL_SEQUENTIAL );
        try {
            /*
             * Update the catalog and expect failure
             */
            newCatalogURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.jar");
            deploymentURL = Configuration.getPathToCatalogForTest("catalogupdate-cluster-base.xml");
            boolean threw = false;
            try {
                client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL));
            } catch (ProcCallException e) {
                e.printStackTrace();
                threw = true;
            }
            assertTrue(threw);
        }
        finally {
            zk.delete(catalogUpdateBlockerPath, -1);
        }

        //Expect success
        client.updateApplicationCatalog(new File(newCatalogURL), new File(deploymentURL));

View Full Code Here

TOP

Related Classes of org.apache.zookeeper_voltpatches.ZooKeeper$ExistsWatchRegistration

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.