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

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

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

URL.getPort介绍

暂无

代码示例

代码示例来源:origin: liuyangming/ByteTCC

private RemoteCoordinator getParticipantByRemoteAddr(Invoker<?> invoker, InvocationDef invocationDef) {
  RemoteCoordinatorRegistry participantRegistry = RemoteCoordinatorRegistry.getInstance();
  URL targetUrl = invoker.getUrl();
  String targetAddr = targetUrl.getIp();
  int targetPort = targetUrl.getPort();
  RemoteAddr remoteAddr = new RemoteAddr();
  remoteAddr.setServerHost(targetAddr);
  remoteAddr.setServerPort(targetPort);
  if (participantRegistry.containsPhysicalInstance(remoteAddr) == false) {
    this.initializeRemoteParticipantIfNecessary(remoteAddr);
  }
  RemoteNode invocationContext = new RemoteNode();
  invocationContext.setServerHost(targetAddr);
  invocationContext.setServerPort(targetPort);
  RemoteCoordinator remoteCoordinator = participantRegistry.getPhysicalInstance(remoteAddr);
  DubboRemoteCoordinator dubboCoordinator = new DubboRemoteCoordinator();
  dubboCoordinator.setInvocationContext(invocationContext);
  dubboCoordinator.setRemoteCoordinator(remoteCoordinator);
  dubboCoordinator.setCoordinatorType(DubboRemoteCoordinator.KEY_PARTICIPANT_TYPE_EXACT);
  RemoteCoordinator participant = (RemoteCoordinator) Proxy.newProxyInstance(
      DubboRemoteCoordinator.class.getClassLoader(), new Class[] { RemoteCoordinator.class }, dubboCoordinator);
  dubboCoordinator.setProxyCoordinator(participant);
  return participant;
}

代码示例来源:origin: liuyangming/ByteTCC

RemoteAddr remoteAddr = new RemoteAddr();
remoteAddr.setServerHost(invokerUrl.getHost());
remoteAddr.setServerPort(invokerUrl.getPort());

代码示例来源:origin: liuyangming/ByteTCC

int targetPort = targetUrl.getPort();

代码示例来源:origin: io.eventcenter/ec-remote-dubbo

boolean filterWithDevMode(URL url){
  if(!devMode){
    return true;
  }
  final String remoteAddress = new StringBuilder(url.getHost()).append(":").append(url.getPort()).toString();
  if(remoteAddress.contains(LOCAL_IP1) || remoteAddress.contains(LOCAL_IP2)) {
    return true;
  }
  return remoteAddress.contains(NetUtils.getLocalHost());
}

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

public InetSocketAddress getRemoteAddress() {
  if (client == null){
    return InetSocketAddress.createUnresolved(url.getHost(), url.getPort());
  } else {
    return client.getRemoteAddress();
  }
}
public ResponseFuture request(Object request, int timeout) throws RemotingException {

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

@Override
public InetSocketAddress getRemoteAddress() {
  if (client == null) {
    return InetSocketAddress.createUnresolved(url.getHost(), url.getPort());
  } else {
    return client.getRemoteAddress();
  }
}

代码示例来源:origin: io.eventcenter/ec-remote-dubbo

public static RegistryServiceFactory buildWith(URL url, String applicationName){
  RegistryServiceFactory factory = buildWith(url, applicationName, null);
  factory.getReferenceConfig().setUrl(new StringBuilder("dubbo://").append(url.getHost()).append(":").append(url.getPort()).toString());
  return factory;
}

代码示例来源:origin: io.eventcenter/ec-remote-dubbo

public static PublisherGroupFactory buildWith(URL url, String remoteEvents){
  PublisherGroupFactory factory = buildWith(url, remoteEvents, null);
  factory.getReferenceConfig().setUrl(new StringBuilder("dubbo://").append(url.getHost()).append(":").append(url.getPort()).toString());
  return factory;
}

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

public ConsulRegistry(URL url) {
  super(url);
  if (url.isAnyHost()) {
    throw new IllegalStateException("registry address == null");
  }
  consulClient = new ConsulClient(url.getHost(), url.getPort());
}

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

public ConsulRegistry(URL url) {
  super(url);
  if (url.isAnyHost()) {
    throw new IllegalStateException("registry address == null");
  }
  consulClient = new ConsulClient(url.getHost(), url.getPort());
}

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

private static boolean isClientSide(Channel channel) {
  InetSocketAddress address = channel.getRemoteAddress();
  URL url = channel.getUrl();
  return url.getPort() == address.getPort() && 
        NetUtils.filterLocalHost(url.getIp())
        .equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
}

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

private static boolean isClientSide(Channel channel) {
  InetSocketAddress address = channel.getRemoteAddress();
  URL url = channel.getUrl();
  return url.getPort() == address.getPort() && 
        NetUtils.filterLocalHost(url.getIp())
        .equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
}

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

private boolean isClientSide(Channel channel) {
  InetSocketAddress address = channel.getRemoteAddress();
  URL url = channel.getUrl();
  return url.getPort() == address.getPort() &&
      NetUtils.filterLocalHost(channel.getUrl().getIp())
          .equals(NetUtils.filterLocalHost(address.getAddress().getHostAddress()));
}

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

/**
 * 根据motan的url生成consul的serivce id。 serviceid 包括ip+port+rpc服务的接口类名
 *
 * @param url url
 * @return consul service id
 */
public static String convertConsulSerivceId(URL url) {
  if (url == null) {
    return null;
  }
  return convertServiceId(url.getHost(), url.getPort(), url.getPath());
}

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

@Override
  public void close() {
    super.close();

    ServletManager.getInstance().removeServletContext(url.getPort());

    try {
      tomcat.stop();
    } catch (Exception e) {
      logger.warn(e.getMessage(), e);
    }
  }
}

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

public void close() {
  super.close();
  // modified by lishen
  ServletManager.getInstance().removeServletContext(url.getPort());
  if (server != null) {
    try {
      server.stop();
    } catch (Exception e) {
      logger.warn(e.getMessage(), e);
    }
  }
}

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

public void close() {
    super.close();

    ServletManager.getInstance().removeServletContext(url.getPort());

    try {
      tomcat.stop();
    } catch (Exception e) {
      logger.warn(e.getMessage(), e);
    }
  }
}

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

public WrappedChannelHandler(ChannelHandler handler, URL url) {
  this.handler = handler;
  this.url = url;
  executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url);
  String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY;
  if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) {
    componentKey = Constants.CONSUMER_SIDE;
  }
  DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
  dataStore.put(componentKey, Integer.toString(url.getPort()), executor);
}

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

protected String getAddr(URL url) {
  String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost());
  if (url.getParameter(Constants.ANYHOST_KEY, false)) {
    bindIp = Constants.ANYHOST_VALUE;
  }
  return NetUtils.getIpByHost(bindIp) + ":" + url.getParameter(Constants.BIND_PORT_KEY, url.getPort());
}

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

protected String getAddr(URL url) {
  String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost());
  if (url.getParameter(Constants.ANYHOST_KEY, false)) {
    bindIp = Constants.ANYHOST_VALUE;
  }
  return NetUtils.getIpByHost(bindIp) + ":" + url.getParameter(Constants.BIND_PORT_KEY, url.getPort());
}

相关文章

微信公众号

最新文章

更多