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


Java ZooKeeperMain类代码示例

本文整理汇总了Java中org.apache.zookeeper.ZooKeeperMain的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperMain类的具体用法?Java ZooKeeperMain怎么用?Java ZooKeeperMain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ZooKeeperMain类属于org.apache.zookeeper包,在下文中一共展示了ZooKeeperMain类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.zookeeper.ZooKeeperMain; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:27,代码来源:ZooKeeperMainServer.java

示例2: main

import org.apache.zookeeper.ZooKeeperMain; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:ZKMainServer.java

示例3: main

import org.apache.zookeeper.ZooKeeperMain; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:17,代码来源:ZooKeeperMainServer.java

示例4: 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

示例5: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。