本文整理了Java中io.goudai.registry.ZooKeeRegistry
类的一些代码示例,展示了ZooKeeRegistry
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeRegistry
类的具体详情如下:
包路径:io.goudai.registry.ZooKeeRegistry
类名称:ZooKeeRegistry
[英]Created by freeman on 2016/2/21.
[中]弗里曼于2016年2月21日创作。
代码示例来源:origin: goudai/gd-rpc
@Override
public List<URL> lookup(Protocol protocol) {
List<URL> result = new ArrayList<>();
try {
String path = check(protocol, protocol.getType());
Set<String> strings = new HashSet<>(this.client.getChildren().forPath(path));
strings.forEach(s -> result.add(URL.valueOf(s)));
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
// log.warn("The available service is not found, please check the registration center or service provider. {}",
// protocol);
}
return result;
}
代码示例来源:origin: goudai/gd-rpc
@Override
public void startup() {
this.connector.startup();
this.reactor.startup();
this.registry.startup();
Invoker invoker = new KeyPooledClusterInvoker(new ZooKeeRegistry(), new Balance() {},connector);
proxyServiceFactory = new JavaProxyServiceFactory(invoker);
}
代码示例来源:origin: goudai/gd-rpc
@Override
public void unRegister(Protocol protocol) {
try {
String path = check(protocol, protocol.getType()) + "/" + URLEncoder.encode(protocol.value(), "utf-8");
if (this.client.checkExists().forPath(path) != null) {
this.client.delete().forPath(path);
}
} catch (Exception e) {
throw new RuntimeException("unregistry service fail!service=[" + protocol.getService() + "]", e);
}
}
代码示例来源:origin: goudai/gd-rpc
@Override
public void register(Protocol protocol) {
try {
String path = check(protocol, protocol.getType()) + "/" + URLEncoder.encode(protocol.value(), "utf-8");
log.info("register path " + path);
if (this.client.checkExists().forPath(path) != null) {
this.client.delete().forPath(path);
log.info("delete path {}", path);
}
this.client.create().withMode(CreateMode.EPHEMERAL).forPath(path);
log.info("create EPHEMERAL path {}", path);
} catch (Exception e) {
throw new RuntimeException("registry service fail!service=[" + protocol.getService() + "]", e);
}
}
代码示例来源:origin: goudai/gd-rpc
@Override
public void unSubscribe(Protocol protocol) {
try {
String path = check(protocol, protocol.getType());
PathChildrenCache removed = pathChildrenCacheMap.remove(path);
if (removed != null) {
CloseableUtils.closeQuietly(removed);
}
} catch (Exception e) {
throw new RuntimeException("unsubscribe service fail!service=[" + protocol.getService() + "]", e);
}
}
代码示例来源:origin: goudai/gd-rpc
@Override
public void subscribe(Protocol protocol, Callback callback) {
try {
String path = check(protocol, protocol.getType());
synchronized (path) {
PathChildrenCache cache = pathChildrenCacheMap.get(path);
if (cache == null) {
cache = PathChildrenCacheUtil.pathChildrenCache(this.client, path, false, callback);
cache.start();
log.info("subscribe path {}", path);
pathChildrenCacheMap.put(path, cache);
}
}
} catch (Exception e) {
throw new RuntimeException("subscribe service fail!service=[" + protocol.getService() + "]", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!