本文整理了Java中com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient
类的一些代码示例,展示了ZooKeeperClusterClient
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperClusterClient
类的具体详情如下:
包路径:com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient
类名称:ZooKeeperClusterClient
暂无
代码示例来源:origin: com.linkedin/norbert_2.8.1
public static void main(String[] args) {
InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
ClusterClient cc = new ZooKeeperClusterClient(null, args[0], args[1], 30000);
NetworkClientConfig config = new NetworkClientConfig();
config.setClusterClient(cc);
NetworkClient nc = new NettyNetworkClient(config, new RoundRobinLoadBalancerFactory());
// PartitionedNetworkClient<Integer> nc = new NettyPartitionedNetworkClient<Integer>(config, new IntegerConsistentHashPartitionedLoadBalancerFactory());
// nc.registerRequest(NorbertExampleProtos.Ping.getDefaultInstance(), NorbertExampleProtos.PingResponse.getDefaultInstance());
Node node = cc.getNodeWithId(1);
Future<Ping> f = nc.sendRequestToNode(new Ping(System.currentTimeMillis()), node, new PingSerializer());
try {
Ping pong = f.get(750, TimeUnit.MILLISECONDS);
System.out.println(String.format("Ping took %dms", System.currentTimeMillis() - pong.timestamp));
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
cc.shutdown();
}
}
代码示例来源:origin: com.linkedin/norbert
public static void main(String[] args) {
InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
ClusterClient cc = new ZooKeeperClusterClient(null, args[0], args[1], 30000);
NetworkClientConfig config = new NetworkClientConfig();
config.setClusterClient(cc);
NetworkClient nc = new NettyNetworkClient(config, new RoundRobinLoadBalancerFactory());
// PartitionedNetworkClient<Integer> nc = new NettyPartitionedNetworkClient<Integer>(config, new IntegerConsistentHashPartitionedLoadBalancerFactory());
// nc.registerRequest(NorbertExampleProtos.Ping.getDefaultInstance(), NorbertExampleProtos.PingResponse.getDefaultInstance());
Node node = cc.getNodeWithId(1);
Future<Ping> f = nc.sendRequestToNode(new Ping(System.currentTimeMillis()), node, new PingSerializer());
try {
Ping pong = f.get(750, TimeUnit.MILLISECONDS);
System.out.println(String.format("Ping took %dms", System.currentTimeMillis() - pong.timestamp));
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
cc.shutdown();
}
}
代码示例来源:origin: com.linkedin/norbert_2.8.1
private static void configCluster(String serviceName, String zkConnectStr)
final ClusterClient cc = new ZooKeeperClusterClient(serviceName, zkConnectStr, 30000);
cc.awaitConnectionUninterruptibly();
代码示例来源:origin: com.linkedin/norbert
private static void configCluster(String serviceName, String zkConnectStr)
final ClusterClient cc = new ZooKeeperClusterClient(serviceName, zkConnectStr, 30000);
cc.awaitConnectionUninterruptibly();
内容来源于网络,如有侵权,请联系作者删除!