com.weibo.api.motan.rpc.URL.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(146)

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

URL.<init>介绍

暂无

代码示例

代码示例来源:origin: weibocom/motan

private void registerDirectUrl(String ip, Integer port) {
  URL url = new URL(MotanConstants.REGISTRY_PROTOCOL_DIRECT,ip,port,"");
  directUrls.add(url);
}

代码示例来源:origin: weibocom/motan

public LocalRegistryService() {
  this(new URL(MotanConstants.REGISTRY_PROTOCOL_LOCAL, NetUtils.LOCALHOST, MotanConstants.DEFAULT_INT_VALUE,
      RegistryService.class.getName()));
}

代码示例来源:origin: weibocom/motan

public URL createCopy() {
  Map<String, String> params = new HashMap<String, String>();
  if (this.parameters != null) {
    params.putAll(this.parameters);
  }
  return new URL(protocol, host, port, path, params);
}

代码示例来源:origin: weibocom/motan

return new URL(protocol, host, port, path, parameters);

代码示例来源:origin: weibocom/motan

private List<URL> mergeResult(URL url, Map<String, Integer> weights) {
  List<URL> finalResult = new ArrayList<URL>();
  if (weights.size() > 1) {
    // 将所有group及权重拼接成一个rule的URL,并作为第一个元素添加到最终结果中
    URL ruleUrl = new URL("rule", url.getHost(), url.getPort(), url.getPath());
    StringBuilder weightsBuilder = new StringBuilder(64);
    for (Map.Entry<String, Integer> entry : weights.entrySet()) {
      weightsBuilder.append(entry.getKey()).append(':').append(entry.getValue()).append(',');
    }
    ruleUrl.addParameter(URLParamType.weights.getName(), weightsBuilder.deleteCharAt(weightsBuilder.length() - 1).toString());
    finalResult.add(ruleUrl);
  }
  for (String key : weights.keySet()) {
    if (groupServiceCache.containsKey(key)) {
      finalResult.addAll(groupServiceCache.get(key));
    } else {
      URL urlTemp = url.createCopy();
      urlTemp.addParameter(URLParamType.group.getName(), key);
      finalResult.addAll(discoverOneGroup(urlTemp));
      registry.subscribeService(urlTemp, this);
    }
  }
  return finalResult;
}

代码示例来源:origin: weibocom/motan

u = new URL(protocol, host, port, path, parameters);

代码示例来源:origin: weibocom/motan

new URL(MotanConstants.REGISTRY_PROTOCOL_LOCAL, NetUtils.LOCALHOST, MotanConstants.DEFAULT_INT_VALUE,
        RegistryService.class.getName());
if (StringUtils.isNotBlank(directUrl)) {

代码示例来源:origin: weibocom/motan

/**
 * 根据service生成motan使用的
 *
 * @param service
 * @return
 */
public static URL buildUrl(ConsulService service) {
  URL url = null;
  for (String tag : service.getTags()) {
    if (tag.startsWith(ConsulConstants.CONSUL_TAG_MOTAN_URL)) {
      String encodeUrl = tag.substring(tag.indexOf("_") + 1);
      url = URL.valueOf(StringTools.urlDecode(encodeUrl));
    }
  }
  if (url == null) {
    Map<String, String> params = new HashMap<String, String>();
    String group = service.getName().substring(ConsulConstants.CONSUL_SERVICE_MOTAN_PRE.length());
    params.put(URLParamType.group.getName(), group);
    params.put(URLParamType.nodeType.getName(), MotanConstants.NODE_TYPE_SERVICE);
    String protocol = ConsulUtils.getProtocolFromTag(service.getTags().get(0));
    url = new URL(protocol, service.getAddress(), service.getPort(),
        ConsulUtils.getPathFromServiceId(service.getId()), params);
  }
  return url;
}

代码示例来源:origin: weibocom/motan

URL refUrl = new URL(protocol.getName(), localIp, MotanConstants.DEFAULT_INT_VALUE, path, params);
ClusterSupport<T> clusterSupport = createClusterSupport(refUrl, configHandler, registryUrls);

代码示例来源:origin: weibocom/motan

collectMethodConfigParams(map, this.getMethods());
URL serviceUrl = new URL(protocolName, hostAddress, port, interfaceClass.getName(), map);
        new URL(MotanConstants.REGISTRY_PROTOCOL_LOCAL, hostAddress, MotanConstants.DEFAULT_INT_VALUE,
            RegistryService.class.getName());

代码示例来源:origin: com.weibo/motan-registry-consul

/**
 * 根据service生成motan使用的
 *
 * @param service
 * @return
 */
public static URL buildUrl(ConsulService service) {
  URL url = null;
  for (String tag : service.getTags()) {
    if (tag.startsWith(ConsulConstants.CONSUL_TAG_MOTAN_URL)) {
      String encodeUrl = tag.substring(tag.indexOf("_") + 1);
      url = URL.valueOf(StringTools.urlDecode(encodeUrl));
    }
  }
  if (url == null) {
    Map<String, String> params = new HashMap<String, String>();
    String group = service.getName().substring(ConsulConstants.CONSUL_SERVICE_MOTAN_PRE.length());
    params.put(URLParamType.group.getName(), group);
    params.put(URLParamType.nodeType.getName(), MotanConstants.NODE_TYPE_SERVICE);
    String protocol = ConsulUtils.getProtocolFromTag(service.getTags().get(0));
    url = new URL(protocol, service.getAddress(), service.getPort(),
        ConsulUtils.getPathFromServiceId(service.getId()), params);
  }
  return url;
}

相关文章