com.xjeffrose.xio.core.ZkClient.fromExhibitor()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(152)

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

ZkClient.fromExhibitor介绍

暂无

代码示例

代码示例来源:origin: xjdr/xio

public static ZkClient buildZkClient(ApplicationConfig applicationConfig) {
 String zookeeperCluster = applicationConfig.getZookeeperCluster();
 ZkClient zkClient;
 if (zookeeperCluster.isEmpty()) {
  zkClient = new NullZkClient();
 } else {
  if (zookeeperCluster.startsWith("exhibitor:")) {
   String[] values = zookeeperCluster.replace("exhibitor:", "").split(":");
   int restPort = Integer.parseInt(values[0]);
   Collection<String> serverSet = Arrays.asList(values[1].split(","));
   zkClient = ZkClient.fromExhibitor(serverSet, restPort);
  } else {
   zkClient = new ZkClient(zookeeperCluster);
  }
 }
 return zkClient;
}

代码示例来源:origin: xjdr/xio

@Test
public void testFromExhibitor() throws Exception {
 MockWebServer server = new MockWebServer();
 server.enqueue(
   new MockResponse()
     .setBody(
       "count=5&server0=10.10.1.1&server1=10.10.1.2&server2=10.10.1.3&server3=10.10.1.4&server4=10.10.1.5&port=2181")
     .setHeader("Content-Type", "application/x-www-form-urlencoded"));
 server.start();
 ZkClient client = ZkClient.fromExhibitor(Arrays.asList("127.0.0.1"), server.getPort());
 assertEquals(
   "10.10.1.1:2181,10.10.1.2:2181,10.10.1.3:2181,10.10.1.4:2181,10.10.1.5:2181",
   client.getConnectionString());
 server.shutdown();
}

相关文章