本文整理了Java中com.weibo.api.motan.rpc.URL.getGroup()
方法的一些代码示例,展示了URL.getGroup()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL.getGroup()
方法的具体详情如下:
包路径:com.weibo.api.motan.rpc.URL
类名称:URL
方法名:getGroup
暂无
代码示例来源:origin: weibocom/motan
public static String toGroupPath(URL url) {
return MotanConstants.ZOOKEEPER_REGISTRY_NAMESPACE + MotanConstants.PATH_SEPARATOR + url.getGroup();
}
代码示例来源:origin: weibocom/motan
@Override
protected void unsubscribeCommand(URL url, CommandListener listener) {
ConcurrentHashMap<URL, CommandListener> listeners = commandListeners.get(url.getGroup());
if (listeners != null) {
synchronized (listeners) {
listeners.remove(url);
}
}
}
代码示例来源:origin: weibocom/motan
private void addCommandListener(URL url, CommandListener commandListener) {
String group = url.getGroup();
ConcurrentHashMap<URL, CommandListener> map = commandListeners.get(group);
if (map == null) {
commandListeners.putIfAbsent(group, new ConcurrentHashMap<URL, CommandListener>());
map = commandListeners.get(group);
}
synchronized (map) {
map.put(url, commandListener);
}
}
代码示例来源:origin: weibocom/motan
public String toSimpleString() {
return getUri() + "?group=" + getGroup();
}
代码示例来源:origin: weibocom/motan
private void startListenerThreadIfNewCommand(URL url) {
String group = url.getGroup();
if (!lookupGroupCommands.containsKey(group)) {
String command = lookupGroupCommands.putIfAbsent(group, "");
if (command == null) {
CommandLookupThread lookupThread = new CommandLookupThread(group);
lookupThread.setDaemon(true);
lookupThread.start();
}
}
}
代码示例来源:origin: weibocom/motan
@Override
protected String discoverCommand(URL url) {
String group = url.getGroup();
String command = lookupCommandUpdate(group);
updateCommandCache(group, command, false);
return command;
}
代码示例来源: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
@Override
protected List<URL> discoverService(URL url) {
String service = ConsulUtils.getUrlClusterInfo(url);
String group = url.getGroup();
List<URL> serviceUrls = new ArrayList<URL>();
ConcurrentHashMap<String, List<URL>> serviceMap = serviceCache.get(group);
if (serviceMap == null) {
synchronized (group.intern()) {
serviceMap = serviceCache.get(group);
if (serviceMap == null) {
ConcurrentHashMap<String, List<URL>> groupUrls = lookupServiceUpdate(group);
updateServiceCache(group, groupUrls, false);
serviceMap = serviceCache.get(group);
}
}
}
if (serviceMap != null) {
serviceUrls = serviceMap.get(service);
}
return serviceUrls;
}
代码示例来源:origin: weibocom/motan
/**
* if new group registed, start a new lookup thread
* each group start a lookup thread to discover service
*
* @param url
*/
private void startListenerThreadIfNewService(URL url) {
String group = url.getGroup();
if (!lookupGroupServices.containsKey(group)) {
Long value = lookupGroupServices.putIfAbsent(group, 0L);
if (value == null) {
ServiceLookupThread lookupThread = new ServiceLookupThread(group);
lookupThread.setDaemon(true);
lookupThread.start();
}
}
}
代码示例来源: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
/**
* 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
@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
public static void putMethodSign(Provider<?> provider, List<Method> methods) {
String group = provider.getUrl().getGroup();
String interfaceName = provider.getInterface().getName();
String version = provider.getUrl().getVersion();
for (Method method : methods) {
MethodInfo temp = new MethodInfo(group, interfaceName, method.getName(), ReflectUtil.getMethodParamDesc(method), version);
String sign = temp.getSign();
MethodInfo priInfo = SIGN_METHOD_MAP.putIfAbsent(sign, temp);
if (priInfo != null && !temp.equals(priInfo)) {// 方法签名冲突
throw new MotanFrameworkException("add method sign conflict! " + temp.toString() + " with " + priInfo.toString(),
MotanErrorMsgConstant.FRAMEWORK_DECODE_ERROR);
} else {
LoggerUtil.info("add method sign:" + sign + ", methodinfo:" + temp.toString());
}
}
}
代码示例来源: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);
}
}
代码示例来源:origin: weibocom/motan
/**
* 根据服务的url生成consul对应的service
*
* @param url
* @return
*/
public static ConsulService buildService(URL url) {
ConsulService service = new ConsulService();
service.setAddress(url.getHost());
service.setId(ConsulUtils.convertConsulSerivceId(url));
service.setName(ConsulUtils.convertGroupToServiceName(url.getGroup()));
service.setPort(url.getPort());
service.setTtl(ConsulConstants.TTL);
List<String> tags = new ArrayList<String>();
tags.add(ConsulConstants.CONSUL_TAG_MOTAN_PROTOCOL + url.getProtocol());
tags.add(ConsulConstants.CONSUL_TAG_MOTAN_URL + StringTools.urlEncode(url.toFullStr()));
service.setTags(tags);
return service;
}
代码示例来源:origin: weibocom/motan
request.setAttachment(URLParamType.clientGroup.getName(), cluster.getUrl().getGroup());
代码示例来源:origin: com.weibo/motan-registry-consul
@Override
protected void unsubscribeCommand(URL url, CommandListener listener) {
ConcurrentHashMap<URL, CommandListener> listeners = commandListeners.get(url.getGroup());
if (listeners != null) {
synchronized (listeners) {
listeners.remove(url);
}
}
}
代码示例来源:origin: com.weibo/motan-registry-consul
private void addCommandListener(URL url, CommandListener commandListener) {
String group = url.getGroup();
ConcurrentHashMap<URL, CommandListener> map = commandListeners.get(group);
if (map == null) {
commandListeners.putIfAbsent(group, new ConcurrentHashMap<URL, CommandListener>());
map = commandListeners.get(group);
}
synchronized (map) {
map.put(url, commandListener);
}
}
代码示例来源:origin: com.weibo/motan-registry-consul
private void startListenerThreadIfNewCommand(URL url) {
String group = url.getGroup();
if (!lookupGroupCommands.containsKey(group)) {
String command = lookupGroupCommands.putIfAbsent(group, "");
if (command == null) {
CommandLookupThread lookupThread = new CommandLookupThread(group);
lookupThread.setDaemon(true);
lookupThread.start();
}
}
}
代码示例来源:origin: com.weibo/motan-registry-consul
@Override
protected String discoverCommand(URL url) {
String group = url.getGroup();
String command = lookupCommandUpdate(group);
updateCommandCache(group, command, false);
return command;
}
内容来源于网络,如有侵权,请联系作者删除!