@Test
public void testQuotaWithQuorum() throws Exception {
ZooKeeper zk = createClient();
zk.setData("/", "some".getBytes(), -1);
zk.create("/a", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
int i = 0;
for (i=0; i < 300;i++) {
zk.create("/a/" + i, "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
}
ZooKeeperMain.createQuota(zk, "/a", 1000L, 5000);
String statPath = Quotas.quotaZookeeper + "/a"+ "/" + Quotas.statNode;
byte[] data = zk.getData(statPath, false, new Stat());
StatsTrack st = new StatsTrack(new String(data));
Assert.assertTrue("bytes are set", st.getBytes() == 1204L);
Assert.assertTrue("num count is set", st.getCount() == 301);
for (i=300; i < 600; i++) {
zk.create("/a/" + i, "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
}
data = zk.getData(statPath, false, new Stat());
st = new StatsTrack(new String(data));
Assert.assertTrue("bytes are set", st.getBytes() == 2404L);
Assert.assertTrue("num count is set", st.getCount() == 601);
}
}