Search in sources :

Example 1 with HierarchicalDataHolder

use of org.apache.helix.controller.HierarchicalDataHolder in project helix by apache.

the class TestHierarchicalDataStore method testHierarchicalDataStore.

@Test(groups = { "unitTest" })
public void testHierarchicalDataStore() {
    _zkClientString = new ZkClient(ZK_ADDR, 1000, 3000);
    String path = "/tmp/testHierarchicalDataStore";
    FileFilter filter = null;
    // _zkClient.setZkSerializer(new ZNRecordSerializer());
    _zkClientString.deleteRecursively(path);
    HierarchicalDataHolder<ZNRecord> dataHolder = new HierarchicalDataHolder<ZNRecord>(_zkClientString, path, filter);
    dataHolder.print();
    AssertJUnit.assertFalse(dataHolder.refreshData());
    // write data
    add(path, "root data");
    AssertJUnit.assertTrue(dataHolder.refreshData());
    dataHolder.print();
    // add some children
    add(path + "/child1", "child 1 data");
    add(path + "/child2", "child 2 data");
    AssertJUnit.assertTrue(dataHolder.refreshData());
    dataHolder.print();
    // add some grandchildren
    add(path + "/child1" + "/grandchild1", "grand child 1 data");
    add(path + "/child1" + "/grandchild2", "grand child 2 data");
    AssertJUnit.assertTrue(dataHolder.refreshData());
    dataHolder.print();
    AssertJUnit.assertFalse(dataHolder.refreshData());
    set(path + "/child1", "new child 1 data");
    AssertJUnit.assertTrue(dataHolder.refreshData());
    dataHolder.print();
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) HierarchicalDataHolder(org.apache.helix.controller.HierarchicalDataHolder) FileFilter(java.io.FileFilter) Test(org.testng.annotations.Test)

Aggregations

FileFilter (java.io.FileFilter)1 HierarchicalDataHolder (org.apache.helix.controller.HierarchicalDataHolder)1 ZkClient (org.apache.helix.manager.zk.ZkClient)1 Test (org.testng.annotations.Test)1