Java 类org.apache.zookeeper.ZooKeeperMain 实例源码

项目:ditb    文件:ZooKeeperMainServer.java   
/**
 * Run the tool.
 * @param args Command line arguments. First arg is path to zookeepers file.
 */
public static void main(String args[]) throws Exception {
  String [] newArgs = args;
  if (!hasServer(args)) {
    // Add the zk ensemble from configuration if none passed on command-line.
    Configuration conf = HBaseConfiguration.create();
    String hostport = new ZooKeeperMainServer().parse(conf);
    if (hostport != null && hostport.length() > 0) {
      newArgs = new String[args.length + 2];
      System.arraycopy(args, 0, newArgs, 2, args.length);
      newArgs[0] = "-server";
      newArgs[1] = hostport;
    }
  }
  // If command-line arguments, run our hack so they are executed.
  if (hasCommandLineArguments(args)) {
    HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain zkm =
      new HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(newArgs);
    zkm.runCmdLine();
  } else {
    ZooKeeperMain.main(newArgs);
  }
}
项目:pbase    文件:ZooKeeperMainServer.java   
/**
 * Run the tool.
 * @param args Command line arguments. First arg is path to zookeepers file.
 */
public static void main(String args[]) throws Exception {
  String [] newArgs = args;
  if (!hasServer(args)) {
    // Add the zk ensemble from configuration if none passed on command-line.
    Configuration conf = HBaseConfiguration.create();
    String hostport = new ZooKeeperMainServer().parse(conf);
    if (hostport != null && hostport.length() > 0) {
      newArgs = new String[args.length + 2];
      System.arraycopy(args, 0, newArgs, 2, args.length);
      newArgs[0] = "-server";
      newArgs[1] = hostport;
    }
  }
  // If command-line arguments, run our hack so they are executed.
  if (hasCommandLineArguments(args)) {
    HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain zkm =
      new HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(newArgs);
    zkm.runCmdLine();
  } else {
    ZooKeeperMain.main(newArgs);
  }
}
项目:HIndex    文件:ZooKeeperMainServer.java   
/**
 * Run the tool.
 * @param args Command line arguments. First arg is path to zookeepers file.
 */
public static void main(String args[]) throws Exception {
  String [] newArgs = args;
  if (!hasServer(args)) {
    // Add the zk ensemble from configuration if none passed on command-line.
    Configuration conf = HBaseConfiguration.create();
    String hostport = new ZooKeeperMainServer().parse(conf);
    if (hostport != null && hostport.length() > 0) {
      newArgs = new String[args.length + 2];
      System.arraycopy(args, 0, newArgs, 2, args.length);
      newArgs[0] = "-server";
      newArgs[1] = hostport;
    }
  }
  // If command-line arguments, run our hack so they are executed.
  if (hasCommandLineArguments(args)) {
    HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain zkm =
      new HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(newArgs);
    zkm.runCmdLine();
  } else {
    ZooKeeperMain.main(newArgs);
  }
}
项目:hbase    文件:ZKMainServer.java   
/**
 * Run the tool.
 * @param args Command line arguments. First arg is path to zookeepers file.
 */
public static void main(String[] args) throws Exception {
  String [] newArgs = args;
  if (!hasServer(args)) {
    // Add the zk ensemble from configuration if none passed on command-line.
    Configuration conf = HBaseConfiguration.create();
    String hostport = new ZKMainServer().parse(conf);
    if (hostport != null && hostport.length() > 0) {
      newArgs = new String[args.length + 2];
      System.arraycopy(args, 0, newArgs, 2, args.length);
      newArgs[0] = "-server";
      newArgs[1] = hostport;
    }
  }
  // If command-line arguments, run our hack so they are executed.
  // ZOOKEEPER-1897 was committed to zookeeper-3.4.6 but elsewhere in this class we say
  // 3.4.6 breaks command-processing; TODO.
  if (hasCommandLineArguments(args)) {
    HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain zkm =
      new HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(newArgs);
    zkm.runCmdLine();
  } else {
    ZooKeeperMain.main(newArgs);
  }
}
项目:PyroDB    文件:ZooKeeperMainServer.java   
/**
 * Run the tool.
 * @param args Command line arguments. First arg is path to zookeepers file.
 */
public static void main(String args[]) throws Exception {
  String [] newArgs = args;
  if (!hasServer(args)) {
    // Add the zk ensemble from configuration if none passed on command-line.
    Configuration conf = HBaseConfiguration.create();
    String hostport = new ZooKeeperMainServer().parse(conf);
    if (hostport != null && hostport.length() > 0) {
      newArgs = new String[args.length + 2];
      System.arraycopy(args, 0, newArgs, 2, args.length);
      newArgs[0] = "-server";
      newArgs[1] = hostport;
    }
  }
  // If command-line arguments, run our hack so they are executed.
  if (hasCommandLineArguments(args)) {
    HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain zkm =
      new HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(newArgs);
    zkm.runCmdLine();
  } else {
    ZooKeeperMain.main(newArgs);
  }
}
项目:c5    文件:ZooKeeperMainServer.java   
/**
 * Run the tool.
 * @param args Command line arguments. First arg is path to zookeepers file.
 */
public static void main(String args[]) throws Exception {
  Configuration conf = HBaseConfiguration.create();
  String hostport = new ZooKeeperMainServer().parse(conf);
  String[] newArgs = args;
  if (hostport != null && hostport.length() > 0) {
    newArgs = new String[args.length + 2];
    System.arraycopy(args, 0, newArgs, 2, args.length);
    newArgs[0] = "-server";
    newArgs[1] = hostport;
  }
  ZooKeeperMain.main(newArgs);
}
项目:zookeeper.dsc    文件:ZooKeeperQuotaTest.java   
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);
}
项目:fuck_zookeeper    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:ZooKeeper    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:StreamProcessingInfrastructure    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:bigstreams    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:bigstreams    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:zookeeper    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:SecureKeeper    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:SecureKeeper    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:StreamBench    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:LoadBalanced_zk    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:LoadBalanced_zk    文件:ZooKeeperQuotaTest.java   
@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);
}
项目:zookeeper-pkg    文件:ZooKeeperQuotaTest.java   
@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);
}