gpt4 book ai didi

org.apache.hadoop.hbase.zookeeper.ZKMainServer.parse()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 18:05:31 25 4
gpt4 key购买 nike

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

ZKMainServer.parse介绍

暂无

代码示例

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

ZKMainServer parser = new ZKMainServer();
Configuration c = HBaseConfiguration.create();
assertEquals("localhost:" + c.get(HConstants.ZOOKEEPER_CLIENT_PORT), parser.parse(c));
final String port = "1234";
c.set(HConstants.ZOOKEEPER_CLIENT_PORT, port);
c.set("hbase.zookeeper.quorum", "example.com");
assertEquals("example.com:" + port, parser.parse(c));
c.set("hbase.zookeeper.quorum", "example1.com,example2.com,example3.com");
String ensemble = parser.parse(c);
assertTrue(port, ensemble.matches("(example[1-3]\\.com:1234,){2}example[1-3]\\.com:" + port));
ensemble = parser.parse(c);
assertEquals(ensemble, "example1.com:5678,example2.com:9012,example3.com:3456");
ensemble = parser.parse(c);
assertEquals(ensemble, "example1.com:5678,example2.com:9012,example3.com:" + port);
ensemble = parser.parse(c);
assertEquals("[2001:db8:1::242:ac11:2]:2181," +
       "[2001:db8:1::242:ac11:3]:5678", ensemble);
ensemble = parser.parse(c);
assertEquals("[1001:db8:1::242:ac11:8]:1234, [2001:db8:1::242:df23:2]:9876," +
       "[2001:db8:1::242:ac11:3]:5678", ensemble);
 ensemble = parser.parse(c);
 Assert.fail("IPv6 address should be 8 groups.");
} catch (IllegalArgumentException e) {

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

@Test
 public void testHostPortParse() {
  ZKMainServer parser = new ZKMainServer();
  Configuration c = HBaseConfiguration.create();
  assertEquals("localhost:" + c.get(HConstants.ZOOKEEPER_CLIENT_PORT), parser.parse(c));
  final String port = "1234";
  c.set(HConstants.ZOOKEEPER_CLIENT_PORT, port);
  c.set("hbase.zookeeper.quorum", "example.com");
  assertEquals("example.com:" + port, parser.parse(c));
  c.set("hbase.zookeeper.quorum", "example1.com,example2.com,example3.com");
  String ensemble = parser.parse(c);
  assertTrue(port, ensemble.matches("(example[1-3]\\.com:1234,){2}example[1-3]\\.com:" + port));

  // multiple servers with its own port
  c.set("hbase.zookeeper.quorum", "example1.com:5678,example2.com:9012,example3.com:3456");
  ensemble = parser.parse(c);
  assertEquals(ensemble, "example1.com:5678,example2.com:9012,example3.com:3456");

  // some servers without its own port, which will be assigned the default client port
  c.set("hbase.zookeeper.quorum", "example1.com:5678,example2.com:9012,example3.com");
  ensemble = parser.parse(c);
  assertEquals(ensemble, "example1.com:5678,example2.com:9012,example3.com:" + port);
 }
}

代码示例来源:origin: com.aliyun.hbase/alihbase-zookeeper

@Test
 public void testHostPortParse() {
  ZKMainServer parser = new ZKMainServer();
  Configuration c = HBaseConfiguration.create();
  assertEquals("localhost:" + c.get(HConstants.ZOOKEEPER_CLIENT_PORT), parser.parse(c));
  final String port = "1234";
  c.set(HConstants.ZOOKEEPER_CLIENT_PORT, port);
  c.set("hbase.zookeeper.quorum", "example.com");
  assertEquals("example.com:" + port, parser.parse(c));
  c.set("hbase.zookeeper.quorum", "example1.com,example2.com,example3.com");
  String ensemble = parser.parse(c);
  assertTrue(port, ensemble.matches("(example[1-3]\\.com:1234,){2}example[1-3]\\.com:" + port));

  // multiple servers with its own port
  c.set("hbase.zookeeper.quorum", "example1.com:5678,example2.com:9012,example3.com:3456");
  ensemble = parser.parse(c);
  assertEquals(ensemble, "example1.com:5678,example2.com:9012,example3.com:3456");

  // some servers without its own port, which will be assigned the default client port
  c.set("hbase.zookeeper.quorum", "example1.com:5678,example2.com:9012,example3.com");
  ensemble = parser.parse(c);
  assertEquals(ensemble, "example1.com:5678,example2.com:9012,example3.com:" + port);
 }
}

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

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

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