gpt4 book ai didi

org.apache.zookeeper.ZooKeeperMain.executeLine()方法的使用及代码示例

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

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

ZooKeeperMain.executeLine介绍

暂无

代码示例

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

Method readLine = consoleC.getMethod("readLine", String.class);
while ((line = (String)readLine.invoke(console, getPrompt())) != null) {
  executeLine(line);
  executeLine(line);

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

Method readLine = consoleC.getMethod("readLine", String.class);
while ((line = (String)readLine.invoke(console, getPrompt())) != null) {
  executeLine(line);
  executeLine(line);

代码示例来源: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: apache/zookeeper

@Test
public void testSortedLs() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  zkMain.executeLine("create /aa1");
  zkMain.executeLine("create /aa2");
  zkMain.executeLine("create /aa3");
  zkMain.executeLine("create /test1");
  zkMain.executeLine("create /zk1");
  LsCommand cmd = new LsCommand();
  cmd.setZk(zk);
  cmd.parse("ls /".split(" "));
  List<String> expected = new ArrayList<String>();
  expected.add("[aa1, aa2, aa3, test1, zk1, zookeeper]");
  runCommandExpect(cmd, expected);
}

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

@Test
public void testCliCommandsNotEchoingUsage() throws Exception {
  // setup redirect out/err streams to get System.in/err, use this judiciously!
  final PrintStream systemErr = System.err; // get current err
  final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
  System.setErr(new PrintStream(errContent));
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  String cmd1 = "printwatches";
  zkMain.executeLine(cmd1);
  String cmd2 = "history";
  zkMain.executeLine(cmd2);
  String cmd3 = "redo";
  zkMain.executeLine(cmd3);
  // revert redirect of out/err streams - important step!
  System.setErr(systemErr);
  if (errContent.toString().contains("ZooKeeper -server host:port cmd args")) {
    fail("CLI commands (history, redo, connect, printwatches) display usage info!");
  }
}

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

@Test
public void testLsrCommand() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  zkMain.executeLine("create /a");
  zkMain.executeLine("create /a/b");
  zkMain.executeLine("create /a/c");
  zkMain.executeLine("create /a/b/d");
  zkMain.executeLine("create /a/c/e");
  zkMain.executeLine("create /a/f");
  LsCommand cmd = new LsCommand();
  cmd.setZk(zk);
  cmd.parse("ls -R /a".split(" "));
  List<String> expected = new ArrayList<String>();
  expected.add("/a");
  expected.add("/a/b");
  expected.add("/a/c");
  expected.add("/a/f");
  expected.add("/a/b/d");
  expected.add("/a/c/e");
  runCommandExpect(cmd, expected);
}

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

@Test
public void testRedoWithNegativeCmdNumber() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  String cmd1 = "redo -1";
  // setup redirect out/err streams to get System.in/err, use this
  // judiciously!
  final PrintStream systemErr = System.err; // get current err
  final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
  System.setErr(new PrintStream(errContent));
  try {
    zkMain.executeLine(cmd1);
    Assert.assertEquals("Command index out of range", errContent
        .toString().trim());
  } finally {
    // revert redirect of out/err streams - important step!
    System.setErr(systemErr);
  }
}

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

@Test
public void testLsrLeafCommand() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  zkMain.executeLine("create /b");
  zkMain.executeLine("create /b/c");
  LsCommand cmd = new LsCommand();
  cmd.setZk(zk);
  cmd.parse("ls -R /b/c".split(" "));
  List<String> expected = new ArrayList<String>();
  expected.add("/b/c");
  runCommandExpect(cmd, expected);
}

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

@Test
public void testCheckInvalidAcls() throws Exception {
   final ZooKeeper zk = createClient();
    ZooKeeperMain zkMain = new ZooKeeperMain(zk);
    String cmdstring = "create -s -e /node data ip:scheme:gggsd"; //invalid acl's
    // For Invalid ACls should not throw exception
    zkMain.executeLine(cmdstring);
}

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

@Test
public void testLsrNonexistantZnodeCommand() throws Exception {
  final ZooKeeper zk = createClient();
  ZooKeeperMain zkMain = new ZooKeeperMain(zk);
  zkMain.executeLine("create /b");
  zkMain.executeLine("create /b/c");
  LsCommand cmd = new LsCommand();
  cmd.setZk(zk);
  cmd.parse("ls -R /b/c/d".split(" "));
  try {
    runCommandExpect(cmd, new ArrayList<String>());
    Assert.fail("Path doesn't exists so, command should fail.");
  } catch (CliWrapperException e) {
    Assert.assertEquals(KeeperException.Code.NONODE, ((KeeperException)e.getCause()).code());
  }
}

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

Method readLine = consoleC.getMethod("readLine", String.class);
while ((line = (String)readLine.invoke(console, getPrompt())) != null) {
  executeLine(line);
  executeLine(line);

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