gpt4 book ai didi

io.goudai.registry.ZooKeeRegistry类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:58:28 26 4
gpt4 key购买 nike

本文整理了Java中io.goudai.registry.ZooKeeRegistry类的一些代码示例,展示了ZooKeeRegistry类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeRegistry类的具体详情如下:
包路径:io.goudai.registry.ZooKeeRegistry
类名称: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);
  }
}

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