gpt4 book ai didi

org.apache.zookeeper.ZooKeeperMain类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 10:06:49 29 4
gpt4 key购买 nike

本文整理了Java中org.apache.zookeeper.ZooKeeperMain类的一些代码示例,展示了ZooKeeperMain类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperMain类的具体详情如下:
包路径:org.apache.zookeeper.ZooKeeperMain
类名称:ZooKeeperMain

ZooKeeperMain介绍

[英]The command line client to ZooKeeper.
[中]ZooKeeper的命令行客户端。

代码示例

代码示例来源:origin: apache/zookeeper

@Test
public void testACLWithExtraAgruments() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  // create persistent sequential node
  String cmdstring = "create -s /l data ip:10.18.52.144:cdrwa f g h";
  zkMain.cl.parseCommand(cmdstring);
  Assert.assertTrue(
      "Not considering the extra arguments after the acls.", zkMain
          .processZKCmd(zkMain.cl));
}

代码示例来源:origin: apache/zookeeper

@Test
public void testDeleteWithInvalidVersionNo() throws Exception {
   final ZooKeeper zk = createClient();
    ZooKeeperMain zkMain = new ZooKeeperMain(zk);
    String cmdstring = "create -s -e /node1 data ";
    String cmdstring1 = "delete /node1 2";//invalid dataversion no
       zkMain.executeLine(cmdstring);
    // For Invalid dataversion number should not throw exception
    zkMain.executeLine(cmdstring1);
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

String cmd = co.getCommand();
if (args.length < 1) {
  usage();
  return false;
  usage();
  return false;
  processCmd( cl);
} else if (cmd.equals("history")) {
  for (int i=commandCount - 10;i<=commandCount;++i) {
    connectToZK(args[1]);
  } else {
    connectToZK(host);
    acl = parseACLs(args[first+3]);
  stat = zk.setData(path, args[2].getBytes(),
      args.length > 3 ? Integer.parseInt(args[3]) : -1);
  printStat(stat);
} else if (cmd.equals("aget") && args.length >= 2) {
  path = args[1];
  data = (data == null)? "null".getBytes() : data;
  System.out.println(new String(data));
  printStat(stat);
} else if (cmd.equals("ls") && args.length >= 2) {
  path = args[1];

代码示例来源:origin: apache/zookeeper

public static void main(String args[]) throws CliException, IOException, InterruptedException
{
  ZooKeeperMain main = new ZooKeeperMain(args);
  main.run();
}

代码示例来源:origin: apache/zookeeper

public void executeLine(String line) throws CliException, InterruptedException, IOException {
 if (!line.equals("")) {
  cl.parseCommand(line);
  addToHistory(commandCount,line);
  processCmd(cl);
  commandCount++;
 }
}

代码示例来源:origin: apache/zookeeper

while ((line = (String)readLine.invoke(console, getPrompt())) != null) {
    executeLine(line);
    executeLine(line);
processCmd(cl);

代码示例来源:origin: apache/zookeeper

private void testInvalidCommand(String cmdString, int exitCode) throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  zkMain.cl.parseCommand(cmdString);
  // Verify that the exit code is set properly
  zkMain.processCmd(zkMain.cl);
  Assert.assertEquals(exitCode, zkMain.exitCode);
  // Verify that the correct exception is thrown
  try {
   zkMain.processZKCmd(zkMain.cl);
   Assert.fail();
  } catch (CliException e) {
   return;
  }
  Assert.fail("invalid command should throw CliException");
}

代码示例来源:origin: apache/zookeeper

String cmd = co.getCommand();
if (args.length < 1) {
  usage();
  throw new MalformedCommandException("No command entered");
  usage();
  throw new CommandNotFoundException("Command not found " + cmd);
  processCmd(cl);
} else if (cmd.equals("history")) {
  for (int i = commandCount - 10; i <= commandCount; ++i) {
    connectToZK(args[1]);
  } else {
    connectToZK(host);
  watch = cliCmd.parse(args).exec();
} else if (!commandMap.containsKey(cmd)) {
   usage();

代码示例来源:origin: apache/hbase

/**
  * 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);
  }
 }
}

代码示例来源:origin: apache/zookeeper

protected boolean processCmd(MyCommandOptions co) throws CliException, IOException, InterruptedException {
  boolean watch = false;
  try {
    watch = processZKCmd(co);
    exitCode = ExitCode.EXECUTION_FINISHED.getValue();
  } catch (CliException ex) {
    exitCode = ex.getExitCode();
    System.err.println(ex.getMessage());
  }
  return watch;
}

代码示例来源:origin: apache/zookeeper

@Override
public void setUp() throws Exception {
  super.setUp();
  zk = createClient();
  zkMain = new ZooKeeperMain(zk);
}

代码示例来源:origin: apache/zookeeper

private int completeCommand(String buffer, String token,
    List<String> candidates)
{
  for (String cmd : ZooKeeperMain.getCommands()) {
    if (cmd.startsWith( token )) {
      candidates.add(cmd);
    }
  }
  return buffer.lastIndexOf(" ")+1;
}

代码示例来源:origin: apache/zookeeper

public ZooKeeperMain(String args[]) throws IOException, InterruptedException {
  cl.parseOptions(args);
  System.out.println("Connecting to " + cl.getOption("server"));
  connectToZK(cl.getOption("server"));
}

代码示例来源:origin: apache/zookeeper

checkIfParentQuota(zk, path);

代码示例来源:origin: apache/zookeeper

@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);
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

while ((line = (String)readLine.invoke(console, getPrompt())) != null) {
    executeLine(line);
    executeLine(line);
processCmd(cl);

代码示例来源:origin: apache/zookeeper

@Test
public void testDelete() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  String cmdstring1 = "create -e /node2 data";
  String cmdstring2 = "delete /node2";
  String cmdstring3 = "ls /node2";
  zkMain.cl.parseCommand(cmdstring1);
  Assert.assertTrue(zkMain.processZKCmd(zkMain.cl));
  zkMain.cl.parseCommand(cmdstring2);
  Assert.assertFalse(zkMain.processZKCmd(zkMain.cl));
  zkMain.cl.parseCommand(cmdstring3);
  Assert.assertFalse("", zkMain.processCmd(zkMain.cl));
}

代码示例来源:origin: javahongxi/whatsmars

public static void main(String[] args) throws Exception {
    ZooKeeperMain.main(args);
    // 列出根节点下的所有子节点:ls /
    // 列出某节点下的所有子节点:ls /dubbo
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

public static void main(String args[])
  throws KeeperException, IOException, InterruptedException
{
  ZooKeeperMain main = new ZooKeeperMain(args);
  main.run();
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

public void executeLine(String line)
throws InterruptedException, IOException, KeeperException {
 if (!line.equals("")) {
  cl.parseCommand(line);
  addToHistory(commandCount,line);
  processCmd(cl);
  commandCount++;
 }
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com