use of org.apache.zookeeper_voltpatches.ZooKeeper in project voltdb by VoltDB.
the class TestLeaderCache method testDeleteChild.
@Test
public void testDeleteChild() throws Exception {
ZooKeeper zk = getClient(0);
configure("/cache02", zk);
LeaderCache dut = new LeaderCache(zk, "/cache02");
dut.start(true);
Map<Integer, Long> cache = dut.pointInTimeCache();
assertEquals("3 items cached.", 3, cache.size());
zk.delete("/cache02/1", -1);
while (true) {
cache = dut.pointInTimeCache();
if (cache.size() == 3) {
Thread.sleep(1);
} else {
break;
}
}
assertEquals("Item removed", 2, cache.size());
assertEquals(null, cache.get(1));
assertEquals(12345678, cache.get(0).longValue());
assertEquals(11223344, cache.get(2).longValue());
dut.shutdown();
zk.close();
}
use of org.apache.zookeeper_voltpatches.ZooKeeper in project voltdb by VoltDB.
the class ElasticJoinProducer method fetchPerPartitionTxnId.
/*
* 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);
}//Can be no node if the cluster was never restored
catch (KeeperException.NoNodeException e) {
return null;
} catch (Exception e) {
VoltDB.crashLocalVoltDB("Error retrieving per partition txn ids", true, e);
}
ByteBuffer buf = ByteBuffer.wrap(partitionTxnIdsBytes);
int count = buf.getInt();
Long partitionTxnId = null;
long[] partitionTxnIds = new long[count];
for (int ii = 0; ii < count; ii++) {
long txnId = buf.getLong();
partitionTxnIds[ii] = txnId;
int partitionId = TxnEgo.getPartitionId(txnId);
if (partitionId == m_partitionId) {
partitionTxnId = txnId;
continue;
}
}
if (partitionTxnId != null) {
return partitionTxnIds;
}
return null;
}
Aggregations