本文整理了Java中com.weibo.api.motan.rpc.URL.getPath()
方法的一些代码示例,展示了URL.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL.getPath()
方法的具体详情如下:
包路径:com.weibo.api.motan.rpc.URL
类名称:URL
方法名:getPath
暂无
代码示例来源:origin: weibocom/motan
public void removeProvider(URL url) {
providerMap.remove(url.getPath());
}
代码示例来源:origin: weibocom/motan
/**
* 根据url获取cluster信息,cluster 信息包括协议和path(rpc服务中的接口类)。
*
* @param url
* @return
*/
public static String getUrlClusterInfo(URL url) {
return url.getProtocol() + "-" + url.getPath();
}
代码示例来源:origin: weibocom/motan
public static String toServicePath(URL url) {
return toGroupPath(url) + MotanConstants.PATH_SEPARATOR + url.getPath();
}
代码示例来源:origin: weibocom/motan
@Override
@SuppressWarnings("unchecked")
public <T> T getProxy(Class<T> clz, List<Cluster<T>> clusters) {
return (T) new RefererCommonHandler(clusters.get(0).getUrl().getPath(), clusters);
}
}
代码示例来源:origin: weibocom/motan
public static String getYarPath(Class<?> interfaceClazz, URL url) {
if (interfaceClazz != null) {
YarConfig config = interfaceClazz.getAnnotation(YarConfig.class);
if (config != null && StringUtils.isNotBlank(config.path())) {
return config.path();
}
}
// '/group/urlpath' as default
return "/" + url.getGroup() + "/" + url.getPath();
}
代码示例来源:origin: weibocom/motan
/**
* 目前根据 group/interface/version 来唯一标示一个服务
*
* @param url
* @return
*/
public static String getServiceKey(URL url) {
return getServiceKey(url.getGroup(), url.getPath(), url.getVersion());
}
代码示例来源: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
private String getRegistryKey(URL url) {
String keyPrefix = url.getPath();
String nodeType = url.getParameter(URLParamType.nodeType.getName());
if (nodeType != null) {
return keyPrefix + MotanConstants.PATH_SEPARATOR + nodeType;
} else {
LoggerUtil.warn("Url need a nodeType as param in localRegistry, url={}", url);
return keyPrefix;
}
}
代码示例来源:origin: weibocom/motan
/**
* 根据motan的url生成consul的serivce id。 serviceid 包括ip+port+rpc服务的接口类名
*
* @param url
* @return
*/
public static String convertConsulSerivceId(URL url) {
if (url == null) {
return null;
}
return convertServiceId(url.getHost(), url.getPort(), url.getPath());
}
代码示例来源:origin: weibocom/motan
String host = u.getHost();
int port = u.getPort();
String path = u.getPath();
Map<String, String> parameters = new HashMap<String, String>(u.getParameters());
if ((protocol == null || protocol.length() == 0) && defaultProtocol != null && defaultProtocol.length() > 0) {
代码示例来源:origin: weibocom/motan
public AbstractClient(URL url) {
this.url = url;
this.codec =
ExtensionLoader.getExtensionLoader(Codec.class).getExtension(
url.getParameter(URLParamType.codec.getName(), URLParamType.codec.getValue()));
LoggerUtil.info("init nettyclient. url:" + url.getHost() + "-" + url.getPath() + ", use codec:" + codec.getClass().getSimpleName());
}
代码示例来源:origin: weibocom/motan
/**
* protocol key: protocol://host:port/group/interface/version
*
* @param url
* @return
*/
public static String getProtocolKey(URL url) {
return url.getProtocol() + MotanConstants.PROTOCOL_SEPARATOR + url.getServerPortStr() + MotanConstants.PATH_SEPARATOR
+ url.getGroup() + MotanConstants.PATH_SEPARATOR + url.getPath() + MotanConstants.PATH_SEPARATOR + url.getVersion();
}
代码示例来源:origin: weibocom/motan
@SuppressWarnings("rawtypes")
public void addProvider(Provider provider) {
providerMap.put(provider.getUrl().getPath(), provider);
Method[] methods = provider.getInterface().getMethods();
for (Method m : methods) {
MethodInfo newMethodInfo = new MethodInfo(m.getName(), ReflectUtil.getMethodParamDesc(m), m);
if (methodDescMap.get(newMethodInfo.getMethodName()) == null) {
methodDescMap.put(newMethodInfo.getMethodName(), newMethodInfo);
} else {
MethodInfo old = methodDescMap.get(newMethodInfo.getMethodName());
if (!old.isDuplicate()) {
methodDescMap.put(old.getMethodName() + old.getMethodDesc(), old);
methodDescMap.put(newMethodInfo.getMethodName(), MethodInfo.DUP_METHOD);
}
methodDescMap.put(newMethodInfo.getMethodName() + newMethodInfo.getMethodDesc(), newMethodInfo);
}
}
}
代码示例来源:origin: weibocom/motan
String path = serviceUrl.getPath();
代码示例来源:origin: weibocom/motan
/**
* check if this url can serve the refUrl.
*
* @param refUrl
* @return
*/
public boolean canServe(URL refUrl) {
if (refUrl == null || !this.getPath().equals(refUrl.getPath())) {
return false;
}
if (!ObjectUtils.equals(protocol, refUrl.protocol)) {
return false;
}
if (!StringUtils.equals(this.getParameter(URLParamType.nodeType.getName()), MotanConstants.NODE_TYPE_SERVICE)) {
return false;
}
String version = getParameter(URLParamType.version.getName(), URLParamType.version.getValue());
String refVersion = refUrl.getParameter(URLParamType.version.getName(), URLParamType.version.getValue());
if (!version.equals(refVersion)) {
return false;
}
// check serialize
String serialize = getParameter(URLParamType.serialize.getName(), URLParamType.serialize.getValue());
String refSerialize = refUrl.getParameter(URLParamType.serialize.getName(), URLParamType.serialize.getValue());
if (!serialize.equals(refSerialize)) {
return false;
}
// 由于需要提供跨group访问rpc的能力,所以不再验证group是否一致。
return true;
}
代码示例来源:origin: weibocom/motan
/**
* 返回一个service or referer的identity,如果两个url的identity相同,则表示相同的一个service或者referer
*
* @return
*/
public String getIdentity() {
return protocol + MotanConstants.PROTOCOL_SEPARATOR + host + ":" + port +
"/" + getParameter(URLParamType.group.getName(), URLParamType.group.getValue()) + "/" +
getPath() + "/" + getParameter(URLParamType.version.getName(), URLParamType.version.getValue()) +
"/" + getParameter(URLParamType.nodeType.getName(), URLParamType.nodeType.getValue());
}
代码示例来源:origin: weibocom/motan
LoggerUtil.warn(String.format("refer:%s", this.url.getPath() + "/" + this.url.getVersion()), "No services");
代码示例来源:origin: com.weibo/motan-registry-consul
/**
* 根据url获取cluster信息,cluster 信息包括协议和path(rpc服务中的接口类)。
*
* @param url
* @return
*/
public static String getUrlClusterInfo(URL url) {
return url.getProtocol() + "-" + url.getPath();
}
代码示例来源:origin: com.weibo/motan-registry-zookeeper
public static String toServicePath(URL url) {
return toGroupPath(url) + MotanConstants.PATH_SEPARATOR + url.getPath();
}
代码示例来源:origin: com.weibo/motan-registry-consul
/**
* 根据motan的url生成consul的serivce id。 serviceid 包括ip+port+rpc服务的接口类名
*
* @param url
* @return
*/
public static String convertConsulSerivceId(URL url) {
if (url == null) {
return null;
}
return convertServiceId(url.getHost(), url.getPort(), url.getPath());
}
内容来源于网络,如有侵权,请联系作者删除!