use of org.apache.zookeeper_voltpatches.ZooKeeper in project voltdb by VoltDB.
the class TestMapCache method testModifyChild.
@Test
public void testModifyChild() throws Exception {
ZooKeeper zk = getClient(0);
configure("/cache03", zk);
MapCache dut = new MapCache(zk, "/cache03");
dut.start(true);
Map<String, JSONObject> cache = dut.pointInTimeCache();
assertEquals("3 items cached.", 3, cache.size());
assertEquals("aaval", cache.get("/cache03/aa").get("key"));
JSONObject aa = new JSONObject("{key:aaval2}");
zk.setData("/cache03/aa", aa.toString().getBytes(), -1);
while (true) {
cache = dut.pointInTimeCache();
if (cache.get("/cache03/aa").get("key").equals("aaval2")) {
break;
}
}
assertEquals("3 items cached.", 3, cache.size());
assertEquals("aaval2", cache.get("/cache03/aa").get("key"));
assertEquals("bbval", cache.get("/cache03/bb").get("key"));
assertEquals("ccval", cache.get("/cache03/cc").get("key"));
dut.shutdown();
zk.close();
}
use of org.apache.zookeeper_voltpatches.ZooKeeper in project voltdb by VoltDB.
the class TestMapCache method testInitialCacheWithCallback.
@Test
public void testInitialCacheWithCallback() throws Exception {
ZooKeeper zk = getClient(0);
configure("/cache01", zk);
TestCallback cb = new TestCallback();
MapCache dut = new MapCache(zk, "/cache01", cb);
dut.start(true);
assertEquals("3 items cached.", 3, cb.m_cache.size());
assertEquals("aaval", cb.m_cache.get("/cache01/aa").get("key"));
assertEquals("bbval", cb.m_cache.get("/cache01/bb").get("key"));
assertEquals("ccval", cb.m_cache.get("/cache01/cc").get("key"));
dut.shutdown();
zk.close();
}
use of org.apache.zookeeper_voltpatches.ZooKeeper in project voltdb by VoltDB.
the class TestMapCache method testAddChildWithPut.
@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();
}
use of org.apache.zookeeper_voltpatches.ZooKeeper in project voltdb by VoltDB.
the class TestStateMachine method setUp.
@Before
public void setUp() throws Exception {
setUpZK(NUM_AGREEMENT_SITES);
coordinators = IntStream.range(0, NUM_AGREEMENT_SITES).mapToObj(i -> ":" + (i + Constants.DEFAULT_INTERNAL_PORT)).toArray(s -> new String[s]);
criteria = MeshProber.builder().coordinators(coordinators).startAction(StartAction.PROBE).hostCount(NUM_AGREEMENT_SITES).build();
ZooKeeper zk = m_messengers.get(0).getZK();
ZKUtil.addIfMissing(zk, "/test", CreateMode.PERSISTENT, null);
ZKUtil.addIfMissing(zk, "/test/db", CreateMode.PERSISTENT, null);
ZKUtil.addIfMissing(zk, stateMachineManagerRoot, CreateMode.PERSISTENT, null);
for (int ii = 0; ii < NUM_AGREEMENT_SITES; ii++) {
addStateMachinesFor(ii);
}
}
use of org.apache.zookeeper_voltpatches.ZooKeeper in project voltdb by VoltDB.
the class TestZK method testMassiveNode.
@Test
public void testMassiveNode() throws Exception {
ZooKeeper zk = getClient(0);
// byte bytes[] = new byte[50331648];
byte[] bytes = new byte[40000000];
zk.create("/bar", null, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
zk.create("/foo", bytes, Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
zk.getData("/foo", false, null);
}
Aggregations