本文整理了Java中com.colobu.rpcx.client.ZkServiceDiscovery
类的一些代码示例,展示了ZkServiceDiscovery
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkServiceDiscovery
类的具体详情如下:
包路径:com.colobu.rpcx.client.ZkServiceDiscovery
类名称:ZkServiceDiscovery
暂无
代码示例来源:origin: smallnest/rpcx-java
@Bean(destroyMethod = "close")
@ConditionalOnMissingBean
public RpcxConsumer rpcxConsumer() {
IServiceDiscovery serviceDiscovery = new ZkServiceDiscovery(rpcxBasePath, rpcxConsumerPackagePath);
IClient client = new NettyClient(serviceDiscovery);
return new RpcxConsumer(client);
}
代码示例来源:origin: smallnest/rpcx-java
/**
* 自动查找依赖的服务
*
* @param basePath
*/
public ZkServiceDiscovery(final String basePath, String consumerPackage) {
this.basePath = basePath;
//有多个业务提供方
Arrays.stream(consumerPackage.split(";")).forEach(it -> {
this.serviceNameSet.addAll(findConsumer(it));
});
this.serviceNameSet.stream().forEach(it -> this.map.put(it, new HashSet<>()));
zkServiceDiscovery(basePath);
}
代码示例来源:origin: smallnest/rpcx-java
/**
* 根据提供的服务名字
*/
public ZkServiceDiscovery(final String basePath, LanguageCode languageCode, final String... serviceNames) {
logger.info("ZkServiceDiscovery languageCode:{}", languageCode);
this.basePath = basePath;
Arrays.stream(serviceNames).forEach(it -> this.serviceNameSet.add(it));
zkServiceDiscovery(basePath);
}
代码示例来源:origin: smallnest/rpcx-java
private void zkServiceDiscovery(String basePath) {
this.serviceNameSet.stream().forEach(it -> {
Set<Pair<String, String>> set = ZkClient.ins().get(basePath, it).stream().map(it2 -> {
String addr = "";
try {
if (it2.getObject1().contains("@")) {
addr = it2.getObject1().split("@")[1];
} else {
addr = it2.getObject1();
}
} catch (Exception ex) {
}
return Pair.of(addr, it2.getObject2());
}).collect(Collectors.toSet());
this.map.put(it, set);
});
//监控zk
watch();
}
代码示例来源:origin: smallnest/rpcx-java
public static void main(String... args) {
IServiceDiscovery serviceDiscovery = new ZkServiceDiscovery("/youpin/services/","");
IClient client = new NettyClient(serviceDiscovery);
IArith arith = new ConsumerConfig(client).refer(IArith.class);
//// System.out.println(arith.sum(1111, 222));
//// System.out.println(arith.sum2(1111, 222));
for (int i = 0; i < 1; i++) {
System.out.println(arith.sum(11,22));
}
//
serviceDiscovery.close();
System.out.println("client call finish");
}
}
内容来源于网络,如有侵权,请联系作者删除!