当前位置: 首页>>代码示例>>Java>>正文


Java ZooKeeperMain.createQuota方法代码示例

本文整理汇总了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);
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:39,代码来源:ZooKeeperQuotaTest.java

示例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);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:43,代码来源:ZooKeeperQuotaTest.java


注:本文中的org.apache.zookeeper.ZooKeeperMain.createQuota方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。