本文整理了Java中com.alipay.sofa.rpc.registry.zk.ZookeeperRegistryHelper.convertConsumerToUrl()
方法的一些代码示例,展示了ZookeeperRegistryHelper.convertConsumerToUrl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperRegistryHelper.convertConsumerToUrl()
方法的具体详情如下:
包路径:com.alipay.sofa.rpc.registry.zk.ZookeeperRegistryHelper
类名称:ZookeeperRegistryHelper
方法名:convertConsumerToUrl
暂无
代码示例来源:origin: alipay/sofa-rpc
/**
* 获取注册配置
*
* @param config consumer config
* @return
*/
private AbstractInterfaceConfig getRegisterConfig(ConsumerConfig config) {
String url = ZookeeperRegistryHelper.convertConsumerToUrl(config);
String addr = url.substring(0, url.indexOf("?"));
for (Map.Entry<ConsumerConfig, String> consumerUrl : consumerUrls.entrySet()) {
if (consumerUrl.getValue().contains(addr)) {
return consumerUrl.getKey();
}
}
return null;
}
代码示例来源:origin: alipay/sofa-rpc
/**
* 获取注册配置
*
* @param config consumer config
* @return
*/
private AbstractInterfaceConfig getRegisterConfig(ConsumerConfig config) {
String url = ZookeeperRegistryHelper.convertConsumerToUrl(config);
String addr = url.substring(0, url.indexOf("?"));
for (Map.Entry<ConsumerConfig, String> consumerUrl : consumerUrls.entrySet()) {
if (consumerUrl.getValue().contains(addr)) {
return consumerUrl.getKey();
}
}
return null;
}
代码示例来源: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: com.alipay.sofa/sofa-rpc-all
/**
* 获取注册配置
*
* @param config consumer config
* @return
*/
private AbstractInterfaceConfig getRegisterConfig(ConsumerConfig config) {
String url = ZookeeperRegistryHelper.convertConsumerToUrl(config);
String addr = url.substring(0, url.indexOf("?"));
for (Map.Entry<ConsumerConfig, String> consumerUrl : consumerUrls.entrySet()) {
if (consumerUrl.getValue().contains(addr)) {
return consumerUrl.getKey();
}
}
return null;
}
代码示例来源: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);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!