// 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 =
PropertyPathConfig.getPath(PropertyType.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 =
PropertyPathConfig.getPath(PropertyType.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);