com.alibaba.dubbo.common.URL.getAddress()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(132)

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

URL.getAddress介绍

暂无

代码示例

代码示例来源:origin: codingapi/tx-lcn

static <T> Invoker<T> chooseInvoker(List<Invoker<T>> invokers, URL url, Invocation invocation, TxLcnLoadBalance loadBalance) {
  String localKey = RpcContext.getContext().getLocalAddressString();
  List<String> appList = sleuthParamListener.beforeBalance(localKey);
  Invoker<T> chooseInvoker = null;
  for (Invoker<T> tInvoker : invokers) {
    String serverKey = tInvoker.getUrl().getAddress();
    for (String appKey : appList) {
      if (appKey.equals(serverKey)) {
        chooseInvoker = tInvoker;
      }
    }
  }
  if (chooseInvoker == null) {
    Invoker<T> invoker = loadBalance.select(invokers, url, invocation);
    sleuthParamListener.afterNewBalance(invoker.getUrl().getAddress());
    return invoker;
  } else {
    return chooseInvoker;
  }
  
}

代码示例来源:origin: remoting/dubbox

/**
   * append thread name with url address
   * @return new url with updated thread name
   */
  public static URL setThreadName(URL url, String defaultName) {
    String name = url.getParameter(Constants.THREAD_NAME_KEY, defaultName);
    name = new StringBuilder(32).append(name).append("-").append(url.getAddress()).toString();
    url = url.addParameter(Constants.THREAD_NAME_KEY, name);
    return url;
  }
}

代码示例来源:origin: remoting/dubbox

/**
   * append thread name with url address
   * @return new url with updated thread name
   */
  public static URL setThreadName(URL url, String defaultName) {
    String name = url.getParameter(Constants.THREAD_NAME_KEY, defaultName);
    name = new StringBuilder(32).append(name).append("-").append(url.getAddress()).toString();
    url = url.addParameter(Constants.THREAD_NAME_KEY, name);
    return url;
  }
}

代码示例来源:origin: net.jahhan/dubbo-remoting-api

protected ExecutorService createExecutor() {
  return Executors.newCachedThreadPool(new NamedThreadFactory(
      CLIENT_THREAD_POOL_NAME + CLIENT_THREAD_POOL_ID.incrementAndGet() + "-" + getUrl().getAddress(), true));
}

代码示例来源:origin: com.alibaba/dubbo

public String getBackupAddress(int defaultPort) {
  StringBuilder address = new StringBuilder(appendDefaultPort(getAddress(), defaultPort));
  String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
  if (backups != null && backups.length > 0) {
    for (String backup : backups) {
      address.append(",");
      address.append(appendDefaultPort(backup, defaultPort));
    }
  }
  return address.toString();
}

代码示例来源:origin: remoting/dubbox

public String getBackupAddress(int defaultPort) {
  StringBuilder address = new StringBuilder(appendDefaultPort(getAddress(), defaultPort));
  String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
  if (backups != null && backups.length > 0) {
    for (String backup : backups) {
      address.append(",");
      address.append(appendDefaultPort(backup, defaultPort));
    }
  }
  return address.toString();
}

代码示例来源:origin: com.alibaba/dubbo-common

public String getBackupAddress(int defaultPort) {
  StringBuilder address = new StringBuilder(appendDefaultPort(getAddress(), defaultPort));
  String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
  if (backups != null && backups.length > 0) {
    for (String backup : backups) {
      address.append(",");
      address.append(appendDefaultPort(backup, defaultPort));
    }
  }
  return address.toString();
}

代码示例来源:origin: remoting/dubbox

public String getBackupAddress(int defaultPort) {
  StringBuilder address = new StringBuilder(appendDefaultPort(getAddress(), defaultPort));
  String[] backups = getParameter(Constants.BACKUP_KEY, new String[0]);
  if (backups != null && backups.length > 0) {
    for (String backup : backups) {
      address.append(",");
      address.append(appendDefaultPort(backup, defaultPort));
    }
  }
  return address.toString();
}

代码示例来源:origin: com.alibaba/dubbo

/**
   * append thread name with url address
   *
   * @return new url with updated thread name
   */
  public static URL setThreadName(URL url, String defaultName) {
    String name = url.getParameter(Constants.THREAD_NAME_KEY, defaultName);
    name = name + "-" + url.getAddress();
    url = url.addParameter(Constants.THREAD_NAME_KEY, name);
    return url;
  }
}

代码示例来源:origin: com.alibaba/dubbo-common

/**
   * append thread name with url address
   *
   * @return new url with updated thread name
   */
  public static URL setThreadName(URL url, String defaultName) {
    String name = url.getParameter(Constants.THREAD_NAME_KEY, defaultName);
    name = name + "-" + url.getAddress();
    url = url.addParameter(Constants.THREAD_NAME_KEY, name);
    return url;
  }
}

代码示例来源:origin: cqyijifu/watcher

@Override
public Object doMonitor(Map<String, Object> params) throws Throwable {
  Map<String, Object> result = Maps.newHashMap();
  
  Collection<Registry> regsitries = AbstractRegistryFactory.getRegistries();
  if (regsitries.size() == 0) {
    throw WatcherException.throwIt("no registry found");
  }
  for (Registry registry : regsitries) {
    result.put(registry.getUrl().getAddress(), registry.isAvailable());
  }
  return result;
}

代码示例来源:origin: linux-china/dubbo3

public Statistics(URL url) {
  this.url = url;
  this.application = url.getParameter(MonitorService.APPLICATION);
  this.service = url.getParameter(MonitorService.INTERFACE);
  this.method = url.getParameter(MonitorService.METHOD);
  this.group = url.getParameter(MonitorService.GROUP);
  this.version = url.getParameter(MonitorService.VERSION);
  this.client = url.getParameter(MonitorService.CONSUMER, url.getAddress());
  this.server = url.getParameter(MonitorService.PROVIDER, url.getAddress());
}

代码示例来源:origin: linux-china/dubbo3

public Statistics(URL url) {
  this.url = url;
  this.application = url.getParameter(MonitorService.APPLICATION);
  this.service = url.getParameter(MonitorService.INTERFACE);
  this.method = url.getParameter(MonitorService.METHOD);
  this.group = url.getParameter(MonitorService.GROUP);
  this.version = url.getParameter(MonitorService.VERSION);
  this.client = url.getParameter(MonitorService.CONSUMER, url.getAddress());
  this.server = url.getParameter(MonitorService.PROVIDER, url.getAddress());
}

代码示例来源:origin: net.jahhan/dubbo-monitor-default

public Statistics(URL url) {
  this.url = url;
  this.application = url.getParameter(MonitorService.APPLICATION);
  this.service = url.getParameter(MonitorService.INTERFACE);
  this.method = url.getParameter(MonitorService.METHOD);
  this.group = url.getParameter(MonitorService.GROUP);
  this.version = url.getParameter(MonitorService.VERSION);
  this.client = url.getParameter(MonitorService.CONSUMER, url.getAddress());
  this.server = url.getParameter(MonitorService.PROVIDER, url.getAddress());
}

代码示例来源:origin: com.alibaba/dubbo

public Statistics(URL url) {
  this.url = url;
  this.application = url.getParameter(MonitorService.APPLICATION);
  this.service = url.getParameter(MonitorService.INTERFACE);
  this.method = url.getParameter(MonitorService.METHOD);
  this.group = url.getParameter(MonitorService.GROUP);
  this.version = url.getParameter(MonitorService.VERSION);
  this.client = url.getParameter(MonitorService.CONSUMER, url.getAddress());
  this.server = url.getParameter(MonitorService.PROVIDER, url.getAddress());
}

代码示例来源:origin: com.alibaba/dubbo

protected void checkInvokers(List<Invoker<T>> invokers, Invocation invocation) {
  if (invokers == null || invokers.isEmpty()) {
    throw new RpcException("Failed to invoke the method "
        + invocation.getMethodName() + " in the service " + getInterface().getName()
        + ". No provider available for the service " + directory.getUrl().getServiceKey()
        + " from registry " + directory.getUrl().getAddress()
        + " on the consumer " + NetUtils.getLocalHost()
        + " using the dubbo version " + Version.getVersion()
        + ". Please check if the providers have been started and registered.");
  }
}

代码示例来源:origin: net.jahhan/dubbo-cluster

protected void checkInvokers(List<Invoker<T>> invokers, Invocation invocation) {
  if (invokers == null || invokers.size() == 0) {
    throw new JahhanException("Failed to invoke the method " + invocation.getMethodName()
        + " in the service " + getInterface().getName() + ". No provider available for the service "
        + directory.getUrl().getServiceKey() + " from registry " + directory.getUrl().getAddress()
        + " on the consumer " + NetUtils.getLocalHost() + " using the dubbo version " + Version.getVersion()
        + ". Please check if the providers have been started and registered.");
  }
}

代码示例来源:origin: hutai123/dubbox

protected void checkInvokers(List<Invoker<T>> invokers, Invocation invocation) {
  if (invokers == null || invokers.size() == 0) {
    throw new RpcException("Failed to invoke the method "
        + invocation.getMethodName() + " in the service " + getInterface().getName() 
        + ". No provider available for the service " + directory.getUrl().getServiceKey()
        + " from registry " + directory.getUrl().getAddress() 
        + " on the consumer " + NetUtils.getLocalHost()
        + " using the dubbo version " + Version.getVersion()
        + ". Please check if the providers have been started and registered.");
  }
}

代码示例来源:origin: com.alibaba/dubbo-cluster

protected void checkInvokers(List<Invoker<T>> invokers, Invocation invocation) {
  if (invokers == null || invokers.isEmpty()) {
    throw new RpcException("Failed to invoke the method "
        + invocation.getMethodName() + " in the service " + getInterface().getName()
        + ". No provider available for the service " + directory.getUrl().getServiceKey()
        + " from registry " + directory.getUrl().getAddress()
        + " on the consumer " + NetUtils.getLocalHost()
        + " using the dubbo version " + Version.getVersion()
        + ". Please check if the providers have been started and registered.");
  }
}

代码示例来源:origin: hutai123/dubbox

protected void checkInvokers(List<Invoker<T>> invokers, Invocation invocation) {
  if (invokers == null || invokers.size() == 0) {
    throw new RpcException("Failed to invoke the method "
        + invocation.getMethodName() + " in the service " + getInterface().getName() 
        + ". No provider available for the service " + directory.getUrl().getServiceKey()
        + " from registry " + directory.getUrl().getAddress() 
        + " on the consumer " + NetUtils.getLocalHost()
        + " using the dubbo version " + Version.getVersion()
        + ". Please check if the providers have been started and registered.");
  }
}

相关文章

微信公众号

最新文章

更多