com.alipay.sofa.rpc.registry.zk.ZookeeperRegistryHelper.buildConsumerPath()方法的使用及代码示例

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

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

ZookeeperRegistryHelper.buildConsumerPath介绍

暂无

代码示例

代码示例来源:origin: alipay/sofa-rpc

/***
 * 订阅
 * @param config
 */
protected void subscribeConsumerUrls(ConsumerConfig config) {
  // 注册Consumer节点
  String url = null;
  if (config.isRegister()) {
    try {
      String consumerPath = buildConsumerPath(rootPath, config);
      if (consumerUrls.containsKey(config)) {
        url = consumerUrls.get(config);
      } else {
        url = ZookeeperRegistryHelper.convertConsumerToUrl(config);
        consumerUrls.put(config, url);
      }
      String encodeUrl = URLEncoder.encode(url, "UTF-8");
      getAndCheckZkClient().create().creatingParentContainersIfNeeded()
        .withMode(CreateMode.EPHEMERAL) // Consumer临时节点
        .forPath(consumerPath + CONTEXT_SEP + encodeUrl);
    } catch (KeeperException.NodeExistsException nodeExistsException) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn("consumer has exists in zookeeper, consumer=" + url);
      }
    } catch (Exception e) {
      throw new SofaRpcRuntimeException("Failed to register consumer to zookeeperRegistry!", e);
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

/***
 * 订阅
 * @param config
 */
protected void subscribeConsumerUrls(ConsumerConfig config) {
  // 注册Consumer节点
  String url = null;
  if (config.isRegister()) {
    try {
      String consumerPath = buildConsumerPath(rootPath, config);
      if (consumerUrls.containsKey(config)) {
        url = consumerUrls.get(config);
      } else {
        url = ZookeeperRegistryHelper.convertConsumerToUrl(config);
        consumerUrls.put(config, url);
      }
      String encodeUrl = URLEncoder.encode(url, "UTF-8");
      getAndCheckZkClient().create().creatingParentContainersIfNeeded()
        .withMode(CreateMode.EPHEMERAL) // Consumer临时节点
        .forPath(consumerPath + CONTEXT_SEP + encodeUrl);
    } catch (KeeperException.NodeExistsException nodeExistsException) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn("consumer has exists in zookeeper, consumer=" + url);
      }
    } catch (Exception e) {
      throw new SofaRpcRuntimeException("Failed to register consumer to zookeeperRegistry!", e);
    }
  }
}

代码示例来源:origin: alipay/sofa-rpc

String url = consumerUrls.remove(config);
if (url != null) {
  String consumerPath = buildConsumerPath(rootPath, config);
  url = URLEncoder.encode(url, "UTF-8");
  getAndCheckZkClient().delete().forPath(consumerPath + CONTEXT_SEP + url);

代码示例来源:origin: alipay/sofa-rpc

String url = consumerUrls.remove(config);
if (url != null) {
  String consumerPath = buildConsumerPath(rootPath, config);
  url = URLEncoder.encode(url, "UTF-8");
  getAndCheckZkClient().delete().forPath(consumerPath + CONTEXT_SEP + url);

代码示例来源:origin: com.alipay.sofa/sofa-rpc-all

/***
 * 订阅
 * @param config
 */
protected void subscribeConsumerUrls(ConsumerConfig config) {
  // 注册Consumer节点
  String url = null;
  if (config.isRegister()) {
    try {
      String consumerPath = buildConsumerPath(rootPath, config);
      if (consumerUrls.containsKey(config)) {
        url = consumerUrls.get(config);
      } else {
        url = ZookeeperRegistryHelper.convertConsumerToUrl(config);
        consumerUrls.put(config, url);
      }
      String encodeUrl = URLEncoder.encode(url, "UTF-8");
      getAndCheckZkClient().create().creatingParentContainersIfNeeded()
        .withMode(CreateMode.EPHEMERAL) // Consumer临时节点
        .forPath(consumerPath + CONTEXT_SEP + encodeUrl);
    } catch (KeeperException.NodeExistsException nodeExistsException) {
      if (LOGGER.isWarnEnabled()) {
        LOGGER.warn("consumer has exists in zookeeper, consumer=" + url);
      }
    } catch (Exception e) {
      throw new SofaRpcRuntimeException("Failed to register consumer to zookeeperRegistry!", e);
    }
  }
}

代码示例来源:origin: com.alipay.sofa/sofa-rpc-all

String url = consumerUrls.remove(config);
if (url != null) {
  String consumerPath = buildConsumerPath(rootPath, config);
  url = URLEncoder.encode(url, "UTF-8");
  getAndCheckZkClient().delete().forPath(consumerPath + CONTEXT_SEP + url);

相关文章