Search in sources :

Example 1 with ZNRecordUpdater

use of org.apache.helix.ZNRecordUpdater in project helix by apache.

the class TestWtCacheSyncOpSingleThread method testHappyPathZkCacheBaseDataAccessor.

// TODO: add TestZkCacheSyncOpSingleThread
// TODO: add TestZkCacheAsyncOpMultiThread
@Test
public void testHappyPathZkCacheBaseDataAccessor() throws Exception {
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // init zkCacheDataAccessor
    String curStatePath = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901");
    String extViewPath = PropertyPathBuilder.externalView(clusterName);
    ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
    baseAccessor.create(curStatePath, null, AccessOption.PERSISTENT);
    List<String> cachePaths = Arrays.asList(curStatePath, extViewPath);
    ZkCacheBaseDataAccessor<ZNRecord> accessor = new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, cachePaths, null);
    boolean ret = TestHelper.verifyZkCache(cachePaths, accessor._wtCache._cache, _gZkClient, true);
    Assert.assertTrue(ret, "wtCache doesn't match data on Zk");
    // create 10 current states
    for (int i = 0; i < 10; i++) {
        String path = curStatePath + "/session_0/TestDB" + i;
        boolean success = accessor.create(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
        Assert.assertTrue(success, "Should succeed in create: " + path);
    }
    // verify wtCache
    // TestHelper.printCache(accessor._wtCache);
    ret = TestHelper.verifyZkCache(cachePaths, accessor._wtCache._cache, _gZkClient, false);
    Assert.assertTrue(ret, "wtCache doesn't match data on Zk");
    // update each current state 10 times, single thread
    for (int i = 0; i < 10; i++) {
        String path = curStatePath + "/session_0/TestDB" + i;
        for (int j = 0; j < 10; j++) {
            ZNRecord newRecord = new ZNRecord("TestDB" + i);
            newRecord.setSimpleField("" + j, "" + j);
            boolean success = accessor.update(path, new ZNRecordUpdater(newRecord), AccessOption.PERSISTENT);
            Assert.assertTrue(success, "Should succeed in update: " + path);
        }
    }
    // verify cache
    // TestHelper.printCache(accessor._wtCache._cache);
    ret = TestHelper.verifyZkCache(cachePaths, accessor._wtCache._cache, _gZkClient, false);
    Assert.assertTrue(ret, "wtCache doesn't match data on Zk");
    // set 10 external views
    for (int i = 0; i < 10; i++) {
        String path = PropertyPathBuilder.externalView(clusterName, "TestDB" + i);
        boolean success = accessor.set(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
        Assert.assertTrue(success, "Should succeed in set: " + path);
    }
    // verify wtCache
    // accessor.printWtCache();
    ret = TestHelper.verifyZkCache(cachePaths, accessor._wtCache._cache, _gZkClient, false);
    Assert.assertTrue(ret, "wtCache doesn't match data on Zk");
    // get 10 external views
    for (int i = 0; i < 10; i++) {
        String path = PropertyPathBuilder.externalView(clusterName, "TestDB" + i);
        ZNRecord record = accessor.get(path, null, 0);
        Assert.assertEquals(record.getId(), "TestDB" + i);
    }
    // getChildNames
    List<String> childNames = accessor.getChildNames(extViewPath, 0);
    // System.out.println(childNames);
    Assert.assertEquals(childNames.size(), 10, "Should contain only: TestDB0-9");
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue(childNames.contains("TestDB" + i));
    }
    // exists
    for (int i = 0; i < 10; i++) {
        String path = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901", "session_0", "TestDB" + i);
        Assert.assertTrue(accessor.exists(path, 0));
    }
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : ZNRecordUpdater(org.apache.helix.ZNRecordUpdater) Date(java.util.Date) ZNRecord(org.apache.helix.ZNRecord) Test(org.testng.annotations.Test)

Example 2 with ZNRecordUpdater

use of org.apache.helix.ZNRecordUpdater in project helix by apache.

the class TestZkBaseDataAccessor method testSyncGet.

@Test
public void testSyncGet() {
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String testName = className + "_" + methodName;
    System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
    String path = String.format("/%s/%s", testName, "msg_0");
    ZNRecord record = new ZNRecord("msg_0");
    ZkBaseDataAccessor<ZNRecord> accessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
    Stat stat = new Stat();
    ZNRecord getRecord = accessor.get(path, stat, 0);
    Assert.assertNull(getRecord);
    try {
        accessor.get(path, stat, AccessOption.THROW_EXCEPTION_IFNOTEXIST);
        Assert.fail("Should throw exception if not exist");
    } catch (Exception e) {
    // OK
    }
    boolean success = accessor.create(path, record, AccessOption.PERSISTENT);
    Assert.assertTrue(success);
    getRecord = accessor.get(path, stat, 0);
    Assert.assertNotNull(getRecord);
    Assert.assertEquals(getRecord.getId(), "msg_0");
    Assert.assertEquals(stat.getVersion(), 0);
    record.setSimpleField("key0", "value0");
    success = accessor.set(path, record, AccessOption.PERSISTENT);
    Assert.assertTrue(success);
    getRecord = accessor.get(path, stat, 0);
    Assert.assertNotNull(getRecord);
    Assert.assertEquals(record.getSimpleFields().size(), 1);
    Assert.assertNotNull(getRecord.getSimpleField("key0"));
    Assert.assertEquals(getRecord.getSimpleField("key0"), "value0");
    Assert.assertEquals(stat.getVersion(), 1);
    ZNRecord newRecord = new ZNRecord("msg_0");
    newRecord.setSimpleField("key1", "value1");
    success = accessor.update(path, new ZNRecordUpdater(newRecord), AccessOption.PERSISTENT);
    Assert.assertTrue(success);
    getRecord = accessor.get(path, stat, 0);
    Assert.assertNotNull(getRecord);
    Assert.assertEquals(getRecord.getSimpleFields().size(), 2);
    Assert.assertNotNull(getRecord.getSimpleField("key0"));
    Assert.assertEquals(getRecord.getSimpleField("key0"), "value0");
    Assert.assertNotNull(getRecord.getSimpleField("key1"));
    Assert.assertEquals(getRecord.getSimpleField("key1"), "value1");
    Assert.assertEquals(stat.getVersion(), 2);
    System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
}
Also used : Stat(org.apache.zookeeper.data.Stat) ZNRecordUpdater(org.apache.helix.ZNRecordUpdater) Date(java.util.Date) ZNRecord(org.apache.helix.ZNRecord) Test(org.testng.annotations.Test)

Example 3 with ZNRecordUpdater

use of org.apache.helix.ZNRecordUpdater in project helix by apache.

the class TestZkCacheAsyncOpSingleThread method testHappyPathExtOpZkCacheBaseDataAccessor.

@Test
public void testHappyPathExtOpZkCacheBaseDataAccessor() throws Exception {
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // init external base data accessor
    ZkClient extZkclient = new ZkClient(ZK_ADDR);
    extZkclient.setZkSerializer(new ZNRecordSerializer());
    ZkBaseDataAccessor<ZNRecord> extBaseAccessor = new ZkBaseDataAccessor<ZNRecord>(extZkclient);
    // init zkCacheBaseDataAccessor
    String curStatePath = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901");
    String extViewPath = PropertyPathBuilder.externalView(clusterName);
    ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
    extBaseAccessor.create(curStatePath, null, AccessOption.PERSISTENT);
    List<String> zkCacheInitPaths = Arrays.asList(curStatePath, extViewPath);
    ZkCacheBaseDataAccessor<ZNRecord> accessor = new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, null, zkCacheInitPaths);
    // TestHelper.printCache(accessor._zkCache);
    boolean ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // create 10 current states using external base accessor
    List<String> paths = new ArrayList<String>();
    List<ZNRecord> records = new ArrayList<ZNRecord>();
    for (int i = 0; i < 10; i++) {
        String path = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901", "session_0", "TestDB" + i);
        ZNRecord record = new ZNRecord("TestDB" + i);
        paths.add(path);
        records.add(record);
    }
    boolean[] success = extBaseAccessor.createChildren(paths, records, AccessOption.PERSISTENT);
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue(success[i], "Should succeed in create: " + paths.get(i));
    }
    // verify wtCache
    for (int i = 0; i < 10; i++) {
        // TestHelper.printCache(accessor._zkCache);
        ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
        if (ret == true)
            break;
        Thread.sleep(100);
    }
    // System.out.println("ret: " + ret);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // update each current state 10 times by external base accessor
    List<DataUpdater<ZNRecord>> updaters = new ArrayList<DataUpdater<ZNRecord>>();
    for (int j = 0; j < 10; j++) {
        paths.clear();
        updaters.clear();
        for (int i = 0; i < 10; i++) {
            String path = curStatePath + "/session_0/TestDB" + i;
            ZNRecord newRecord = new ZNRecord("TestDB" + i);
            newRecord.setSimpleField("" + j, "" + j);
            DataUpdater<ZNRecord> updater = new ZNRecordUpdater(newRecord);
            paths.add(path);
            updaters.add(updater);
        }
        success = extBaseAccessor.updateChildren(paths, updaters, AccessOption.PERSISTENT);
        for (int i = 0; i < 10; i++) {
            Assert.assertTrue(success[i], "Should succeed in update: " + paths.get(i));
        }
    }
    // wait zkEventThread update zkCache
    Thread.sleep(100);
    // verify cache
    // TestHelper.printCache(accessor._zkCache);
    ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // set 10 external views by external accessor
    paths.clear();
    records.clear();
    for (int i = 0; i < 10; i++) {
        String path = PropertyPathBuilder.externalView(clusterName, "TestDB" + i);
        ZNRecord record = new ZNRecord("TestDB" + i);
        paths.add(path);
        records.add(record);
    }
    success = extBaseAccessor.setChildren(paths, records, AccessOption.PERSISTENT);
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue(success[i], "Should succeed in set: " + paths.get(i));
    }
    // wait zkEventThread update zkCache
    Thread.sleep(100);
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // remove 10 external views by external accessor
    paths.clear();
    for (int i = 0; i < 10; i++) {
        String path = PropertyPathBuilder.externalView(clusterName, "TestDB" + i);
        paths.add(path);
    }
    success = extBaseAccessor.remove(paths, 0);
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue(success[i], "Should succeed in remove: " + paths.get(i));
    }
    // wait zkEventThread update zkCache
    Thread.sleep(100);
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // clean up
    extZkclient.close();
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) DataUpdater(org.I0Itec.zkclient.DataUpdater) ZNRecordUpdater(org.apache.helix.ZNRecordUpdater) ZNRecord(org.apache.helix.ZNRecord) Test(org.testng.annotations.Test)

Example 4 with ZNRecordUpdater

use of org.apache.helix.ZNRecordUpdater in project helix by apache.

the class TestZkCacheAsyncOpSingleThread method testHappyPathSelfOpZkCacheBaseDataAccessor.

@Test
public void testHappyPathSelfOpZkCacheBaseDataAccessor() throws Exception {
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // init zkCacheDataAccessor
    String curStatePath = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901");
    String extViewPath = PropertyPathBuilder.externalView(clusterName);
    ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
    baseAccessor.create(curStatePath, null, AccessOption.PERSISTENT);
    List<String> zkCacheInitPaths = Arrays.asList(curStatePath, extViewPath);
    ZkCacheBaseDataAccessor<ZNRecord> accessor = new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, null, zkCacheInitPaths);
    // TestHelper.printCache(accessor._zkCache._cache);
    boolean ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // create 10 current states using this accessor
    List<String> paths = new ArrayList<String>();
    List<ZNRecord> records = new ArrayList<ZNRecord>();
    for (int i = 0; i < 10; i++) {
        String path = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901", "session_0", "TestDB" + i);
        ZNRecord record = new ZNRecord("TestDB" + i);
        paths.add(path);
        records.add(record);
    }
    boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue(success[i], "Should succeed in create: " + paths.get(i));
    }
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, false);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // update each current state 10 times by this accessor
    List<DataUpdater<ZNRecord>> updaters = new ArrayList<DataUpdater<ZNRecord>>();
    for (int j = 0; j < 10; j++) {
        paths.clear();
        updaters.clear();
        for (int i = 0; i < 10; i++) {
            String path = curStatePath + "/session_0/TestDB" + i;
            ZNRecord newRecord = new ZNRecord("TestDB" + i);
            newRecord.setSimpleField("" + j, "" + j);
            DataUpdater<ZNRecord> updater = new ZNRecordUpdater(newRecord);
            paths.add(path);
            updaters.add(updater);
        }
        success = accessor.updateChildren(paths, updaters, AccessOption.PERSISTENT);
        for (int i = 0; i < 10; i++) {
            Assert.assertTrue(success[i], "Should succeed in update: " + paths.get(i));
        }
    }
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    ret = TestHelper.verifyZkCache(zkCacheInitPaths, zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
    // ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor, _gZkClient, true);
    // System.out.println("ret: " + ret);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // set 10 external views 10 times by this accessor
    paths.clear();
    records.clear();
    for (int j = 0; j < 10; j++) {
        for (int i = 0; i < 10; i++) {
            String path = PropertyPathBuilder.externalView(clusterName, "TestDB" + i);
            ZNRecord record = new ZNRecord("TestDB" + i);
            record.setSimpleField("setKey", "" + j);
            paths.add(path);
            records.add(record);
        }
        success = accessor.setChildren(paths, records, AccessOption.PERSISTENT);
        for (int i = 0; i < 10; i++) {
            Assert.assertTrue(success[i], "Should succeed in set: " + paths.get(i));
        }
    }
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    ret = TestHelper.verifyZkCache(zkCacheInitPaths, accessor._zkCache._cache, _gZkClient, true);
    // System.out.println("ret: " + ret);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    // get 10 external views
    paths.clear();
    records.clear();
    for (int i = 0; i < 10; i++) {
        String path = extViewPath + "/TestDB" + i;
        paths.add(path);
    }
    records = accessor.get(paths, null, 0);
    for (int i = 0; i < 10; i++) {
        Assert.assertEquals(records.get(i).getId(), "TestDB" + i);
    }
    // getChildren
    records.clear();
    records = accessor.getChildren(extViewPath, null, 0);
    for (int i = 0; i < 10; i++) {
        Assert.assertEquals(records.get(i).getId(), "TestDB" + i);
    }
    // // exists
    paths.clear();
    for (int i = 0; i < 10; i++) {
        String path = curStatePath + "/session_0/TestDB" + i;
        // // PropertyPathConfig.getPath(PropertyType.CURRENTSTATES,
        // // clusterName,
        // // "localhost_8901",
        // // "session_0",
        // // "TestDB" + i);
        paths.add(path);
    }
    success = accessor.exists(paths, 0);
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue(success[i], "Should exits: " + paths.get(i));
    }
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) DataUpdater(org.I0Itec.zkclient.DataUpdater) ZNRecordUpdater(org.apache.helix.ZNRecordUpdater) ZNRecord(org.apache.helix.ZNRecord) Test(org.testng.annotations.Test)

Example 5 with ZNRecordUpdater

use of org.apache.helix.ZNRecordUpdater in project helix by apache.

the class TestZkCacheSyncOpSingleThread method testZkCacheCallbackExternalOpNoChroot.

@Test
public void testZkCacheCallbackExternalOpNoChroot() throws Exception {
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // init external base data accessor
    ZkClient zkclient = new ZkClient(ZK_ADDR);
    zkclient.setZkSerializer(new ZNRecordSerializer());
    ZkBaseDataAccessor<ZNRecord> extBaseAccessor = new ZkBaseDataAccessor<ZNRecord>(zkclient);
    // init zkCacheDataAccessor
    String curStatePath = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901");
    String extViewPath = PropertyPathBuilder.externalView(clusterName);
    ZkBaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_gZkClient);
    extBaseAccessor.create(curStatePath, null, AccessOption.PERSISTENT);
    List<String> cachePaths = Arrays.asList(curStatePath, extViewPath);
    ZkCacheBaseDataAccessor<ZNRecord> accessor = new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, null, cachePaths);
    // TestHelper.printCache(accessor._zkCache._cache);
    TestListener listener = new TestListener();
    accessor.subscribe(curStatePath, listener);
    // create 10 current states
    List<String> createPaths = new ArrayList<String>();
    for (int i = 0; i < 10; i++) {
        String path = curStatePath + "/session_0/TestDB" + i;
        createPaths.add(path);
        boolean success = extBaseAccessor.create(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
        Assert.assertTrue(success, "Should succeed in create: " + path);
    }
    Thread.sleep(500);
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    boolean ret = TestHelper.verifyZkCache(cachePaths, accessor._zkCache._cache, _gZkClient, true);
    // System.out.println("ret: " + ret);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    System.out.println("createCnt: " + listener._createPathQueue.size());
    Assert.assertEquals(listener._createPathQueue.size(), 11, "Shall get 11 onCreate callbacks.");
    // verify each callback path
    createPaths.add(curStatePath + "/session_0");
    List<String> createCallbackPaths = new ArrayList<String>(listener._createPathQueue);
    Collections.sort(createPaths);
    Collections.sort(createCallbackPaths);
    // System.out.println("createCallbackPaths: " + createCallbackPaths);
    Assert.assertEquals(createCallbackPaths, createPaths, "Should get create callbacks at " + createPaths + ", but was " + createCallbackPaths);
    // update each current state, single thread
    List<String> updatePaths = new ArrayList<String>();
    listener.reset();
    for (int i = 0; i < 10; i++) {
        String path = curStatePath + "/session_0/TestDB" + i;
        for (int j = 0; j < 10; j++) {
            updatePaths.add(path);
            ZNRecord newRecord = new ZNRecord("TestDB" + i);
            newRecord.setSimpleField("" + j, "" + j);
            boolean success = accessor.update(path, new ZNRecordUpdater(newRecord), AccessOption.PERSISTENT);
            Assert.assertTrue(success, "Should succeed in update: " + path);
        }
    }
    Thread.sleep(500);
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    ret = TestHelper.verifyZkCache(cachePaths, accessor._zkCache._cache, _gZkClient, true);
    // System.out.println("ret: " + ret);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    System.out.println("changeCnt: " + listener._changePathQueue.size());
    Assert.assertEquals(listener._changePathQueue.size(), 100, "Shall get 100 onChange callbacks.");
    // verify each callback path
    List<String> updateCallbackPaths = new ArrayList<String>(listener._changePathQueue);
    Collections.sort(updatePaths);
    Collections.sort(updateCallbackPaths);
    Assert.assertEquals(updateCallbackPaths, updatePaths, "Should get change callbacks at " + updatePaths + ", but was " + updateCallbackPaths);
    // remove 10 current states
    TreeSet<String> removePaths = new TreeSet<String>();
    listener.reset();
    for (int i = 0; i < 10; i++) {
        String path = curStatePath + "/session_0/TestDB" + i;
        removePaths.add(path);
        boolean success = accessor.remove(path, AccessOption.PERSISTENT);
        Assert.assertTrue(success, "Should succeed in remove: " + path);
    }
    Thread.sleep(500);
    // verify cache
    // TestHelper.printCache(accessor._zkCache._cache);
    ret = TestHelper.verifyZkCache(cachePaths, accessor._zkCache._cache, _gZkClient, true);
    // System.out.println("ret: " + ret);
    Assert.assertTrue(ret, "zkCache doesn't match data on Zk");
    System.out.println("deleteCnt: " + listener._deletePathQueue.size());
    Assert.assertTrue(listener._deletePathQueue.size() >= 10, "Shall get at least 10 onDelete callbacks.");
    // verify each callback path
    Set<String> removeCallbackPaths = new TreeSet<String>(listener._deletePathQueue);
    Assert.assertEquals(removeCallbackPaths, removePaths, "Should get remove callbacks at " + removePaths + ", but was " + removeCallbackPaths);
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) TreeSet(java.util.TreeSet) ZNRecordUpdater(org.apache.helix.ZNRecordUpdater) ZNRecord(org.apache.helix.ZNRecord) Test(org.testng.annotations.Test)

Aggregations

Date (java.util.Date)8 ZNRecord (org.apache.helix.ZNRecord)8 ZNRecordUpdater (org.apache.helix.ZNRecordUpdater)8 Test (org.testng.annotations.Test)8 ArrayList (java.util.ArrayList)5 DataUpdater (org.I0Itec.zkclient.DataUpdater)5 Stat (org.apache.zookeeper.data.Stat)2 TreeSet (java.util.TreeSet)1