本文整理汇总了Java中org.apache.zookeeper.ZooKeeperMain.createQuota方法的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperMain.createQuota方法的具体用法?Java ZooKeeperMain.createQuota怎么用?Java ZooKeeperMain.createQuota使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.ZooKeeperMain
的用法示例。
在下文中一共展示了ZooKeeperMain.createQuota方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testQuota
import org.apache.zookeeper.ZooKeeperMain; //导入方法依赖的package包/类
public void testQuota() throws IOException,
InterruptedException, KeeperException, Exception {
final ZooKeeper zk = createClient();
final String path = "/a/b/v";
// making sure setdata works on /
zk.setData("/", "some".getBytes(), -1);
zk.create("/a", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
zk.create("/a/b", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
zk.create("/a/b/v", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
zk.create("/a/b/v/d", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
ZooKeeperMain.createQuota(zk, path, 1000L, 1000);
// see if its set
String absolutePath = Quotas.quotaZookeeper + path + "/" + Quotas.limitNode;
byte[] data = zk.getData(absolutePath, false, new Stat());
StatsTrack st = new StatsTrack(new String(data));
assertTrue("bytes are set", st.getBytes() == 1000L);
assertTrue("num count is set", st.getCount() == 1000);
String statPath = Quotas.quotaZookeeper + path + "/" + Quotas.statNode;
byte[] qdata = zk.getData(statPath, false, new Stat());
StatsTrack qst = new StatsTrack(new String(qdata));
assertTrue("bytes are set", qst.getBytes() == 8L);
assertTrue("count is set", qst.getCount() == 2);
stopServer();
startServer();
stopServer();
startServer();
ZooKeeperServer server = serverFactory.getZooKeeperServer();
assertNotNull("Quota is still set",
server.getZKDatabase().getDataTree().getMaxPrefixWithQuota(path) != null);
}
示例2: testQuota
import org.apache.zookeeper.ZooKeeperMain; //导入方法依赖的package包/类
@Test
public void testQuota() throws IOException,
InterruptedException, KeeperException, Exception {
final ZooKeeper zk = createClient();
final String path = "/a/b/v";
// making sure setdata works on /
zk.setData("/", "some".getBytes(), -1);
zk.create("/a", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
zk.create("/a/b", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
zk.create("/a/b/v", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
zk.create("/a/b/v/d", "some".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
ZooKeeperMain.createQuota(zk, path, 5L, 10);
// see if its set
String absolutePath = Quotas.quotaZookeeper + path + "/" + Quotas.limitNode;
byte[] data = zk.getData(absolutePath, false, new Stat());
StatsTrack st = new StatsTrack(new String(data));
Assert.assertTrue("bytes are set", st.getBytes() == 5L);
Assert.assertTrue("num count is set", st.getCount() == 10);
String statPath = Quotas.quotaZookeeper + path + "/" + Quotas.statNode;
byte[] qdata = zk.getData(statPath, false, new Stat());
StatsTrack qst = new StatsTrack(new String(qdata));
Assert.assertTrue("bytes are set", qst.getBytes() == 8L);
Assert.assertTrue("count is set", qst.getCount() == 2);
//force server to restart and load from snapshot, not txn log
stopServer();
startServer();
stopServer();
startServer();
ZooKeeperServer server = getServer(serverFactory);
Assert.assertNotNull("Quota is still set",
server.getZKDatabase().getDataTree().getMaxPrefixWithQuota(path) != null);
}