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

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

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

URL.getUri介绍

暂无

代码示例

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

protected String getRegistryUri(URL url) {
  String registryUri = url.getUri();
  return registryUri;
}

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

public String toFullStr() {
  StringBuilder builder = new StringBuilder();
  builder.append(getUri()).append("?");
  for (Map.Entry<String, String> entry : parameters.entrySet()) {
    String name = entry.getKey();
    String value = entry.getValue();
    builder.append(name).append("=").append(value).append("&");
  }
  return builder.toString();
}

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

public String toSimpleString() {
  return getUri() + "?group=" + getGroup();
}

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

protected void returnObject(Channel channel) {
  if (channel == null) {
    return;
  }
  try {
    pool.returnObject(channel);
  } catch (Exception ie) {
    LoggerUtil.error(this.getClass().getSimpleName() + " return client Error: url=" + url.getUri(), ie);
  }
}

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

protected void invalidateObject(Channel nettyChannel) {
  if (nettyChannel == null) {
    return;
  }
  try {
    pool.invalidateObject(nettyChannel);
  } catch (Exception ie) {
    LoggerUtil.error(this.getClass().getSimpleName() + " invalidate client Error: url=" + url.getUri(), ie);
  }
}

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

@Override
public synchronized void close(int timeout) {
  try {
    state = ChannelState.CLOSE;
    if (channel != null) {
      channel.close();
    }
  } catch (Exception e) {
    LoggerUtil.error("NettyChannel close Error: " + nettyClient.getUrl().getUri() + " local=" + localAddress, e);
  }
}

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

private void createConnections() {
  for (int i = 0; i < poolConfig.minIdle; i++) {
    try {
      pool.addObject();
    } catch (Exception e) {
      LoggerUtil.error("NettyClient init pool create connect Error: url=" + url.getUri(), e);
    }
  }
}

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

private void createConnections() {
  for (Channel channel : channels) {
    try {
      channel.open();
    } catch (Exception e) {
      LoggerUtil.error("NettyClient init pool create connect Error: url=" + url.getUri(), e);
    }
  }
}

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

@Override
  public void run() {
    createConnections();
    LoggerUtil.info("async initPool success!" + getUrl().getUri());
  }
});

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

@Override
public void destroyObject(final Object obj) throws Exception {
  if (obj instanceof NettyChannel) {
    NettyChannel client = (NettyChannel) obj;
    URL url = nettyClient.getUrl();
    try {
      client.close();
      LoggerUtil.info(factoryName + " client disconnect Success: " + url.getUri());
    } catch (Exception e) {
      LoggerUtil.error(factoryName + " client disconnect Error: " + url.getUri(), e);
    }
  }
}

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

protected Channel borrowObject() throws Exception {
  Channel nettyChannel = (Channel) pool.borrowObject();
  if (nettyChannel != null && nettyChannel.isAvailable()) {
    return nettyChannel;
  }
  invalidateObject(nettyChannel);
  String errorMsg = this.getClass().getSimpleName() + " borrowObject Error: url=" + url.getUri();
  LoggerUtil.error(errorMsg);
  throw new MotanServiceException(errorMsg);
}

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

@Override
protected Response doCall(Request request) {
  if (exporter == null) {
    throw new MotanServiceException("InjvmReferer call Error: provider not exist, url=" + url.getUri(),
        MotanErrorMsgConstant.SERVICE_UNFOUND);
  }
  return exporter.getProvider().call(request);
}

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

@Override
  public void run() {
    for (Referer<?> referer : referers) {
      try {
        referer.destroy();
      } catch (Exception e) {
        LoggerUtil.error("RefererSupports delayDestroy Error: url=" + referer.getUrl().getUri(), e);
      }
    }
  }
}, DELAY_TIME, TimeUnit.MILLISECONDS);

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

@Override
public synchronized void close(int timeout) {
  try {
    state = ChannelState.CLOSE;
    if (channel != null) {
      channel.close();
    }
  } catch (Exception e) {
    LoggerUtil
        .error("NettyChannel close Error: " + nettyClient.getUrl().getUri() + " local=" + localAddress, e);
  }
}

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

@Override
protected Response doCall(Request request) {
  try {
    // 为了能够实现跨group请求,需要使用server端的group。
    request.setAttachment(URLParamType.group.getName(), serviceUrl.getGroup());
    return client.request(request);
  } catch (TransportException exception) {
    throw new MotanServiceException("DefaultRpcReferer call Error: url=" + url.getUri(), exception);
  }
}

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

/**
 * call before invoke the request
 * 
 * @param url
 * @param request
 */
public static void beforeCall(URL url, Request request) {
  String uri = url.getUri();
  onBeforeCall(getServiceStat(uri));
  onBeforeCall(getMethodStat(uri, request.getMethodName(), request.getParamtersDesc()));
}

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

@Override
public Response request(Request request) throws TransportException {
  if (!isAvailable()) {
    throw new MotanServiceException("NettyChannel is unavailable: url=" + url.getUri() + MotanFrameworkUtil.toString(request));
  }
  boolean isAsync = false;
  Object async = RpcContext.getContext().getAttribute(MotanConstants.ASYNC_SUFFIX);
  if (async != null && async instanceof Boolean) {
    isAsync = (Boolean) async;
  }
  return request(request, isAsync);
}

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

/**
 * call after invoke the request
 * 
 * @param url
 * @param request
 * @param success
 * @param procTimeMills
 */
public static void afterCall(URL url, Request request, boolean success, long procTimeMills) {
  String uri = url.getUri();
  onAfterCall(getServiceStat(uri), success, procTimeMills);
  onAfterCall(getMethodStat(uri, request.getMethodName(), request.getParamtersDesc()), success, procTimeMills);
}

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

@Override
public Response request(Request request) throws TransportException {
  if (!isAvailable()) {
    throw new MotanServiceException("NettyChannel is unavaliable: url=" + url.getUri()
        + MotanFrameworkUtil.toString(request));
  }
  boolean isAsync = false;
  Object async = RpcContext.getContext().getAttribute(MotanConstants.ASYNC_SUFFIX);
  if(async != null && async instanceof Boolean){
    isAsync = (Boolean)async;
  }
  return request(request, isAsync);
}

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

@Override
protected Response doCall(Request request) {
  try {
    // use server end group
    request.setAttachment(URLParamType.group.getName(), serviceUrl.getGroup());
    request.setAttachment(M2_PROXY_PROTOCOL, this.url.getProtocol()); // add proxy protocol for request agent
    return client.request(request);
  } catch (TransportException exception) {
    throw new MotanServiceException("DefaultRpcReferer call Error: url=" + url.getUri(), exception);
  }
}

相关文章