本文整理了Java中com.weibo.api.motan.rpc.URL.getIdentity()
方法的一些代码示例,展示了URL.getIdentity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URL.getIdentity()
方法的具体详情如下:
包路径:com.weibo.api.motan.rpc.URL
类名称:URL
方法名:getIdentity
[英]返回一个service or referer的identity,如果两个url的identity相同,则表示相同的一个service或者referer
[中]返回一个服务或推荐人的身份如果两个网址的身份相同,则表示相同的一个服务或者推荐人
代码示例来源:origin: weibocom/motan
private static MockInfo getServiceStat(URL url) {
MockInfo info = mockServices.get(url.getIdentity());
if (info == null) {
info = new MockInfo(url);
mockServices.putIfAbsent(url.getIdentity(), info);
info = mockServices.get(url.getIdentity());
}
return info;
}
代码示例来源:origin: weibocom/motan
private String getIdentities(List<URL> urls) {
if (urls == null || urls.isEmpty()) {
return "[]";
}
StringBuilder builder = new StringBuilder();
builder.append("[");
for (URL u : urls) {
builder.append(u.getIdentity()).append(",");
}
builder.setLength(builder.length() - 1);
builder.append("]");
return builder.toString();
}
代码示例来源:origin: weibocom/motan
protected boolean serviceExists(URL url) {
return existingServices.contains(url.getIdentity());
}
代码示例来源:origin: weibocom/motan
@Override
public String statisticCallback() {
//避免消息泛滥,如果节点是可用状态,并且堆积的请求不超过100的话,那么就不记录log了
if (isAvailable() && callbackMap.size() < 100) {
return null;
}
return String.format("identity: %s available: %s concurrent_count: %s", url.getIdentity(), isAvailable(), callbackMap.size());
}
代码示例来源:origin: weibocom/motan
/**
* 统计回调接口
*/
@Override
public String statisticCallback() {
//避免消息泛滥,如果节点是可用状态,并且堆积的请求不超过100的话,那么就不记录log了
if (isAvailable() && callbackMap.size() < 100) {
return null;
}
return String.format("identity: %s available: %s concurrent_count: %s", url.getIdentity(), isAvailable(),
callbackMap.size());
}
代码示例来源:origin: weibocom/motan
private void afterUnexport() {
exported.set(false);
for (Exporter<T> ep : exporters) {
existingServices.remove(ep.getProvider().getUrl().getIdentity());
exporters.remove(ep);
}
exporters.clear();
registereUrls.clear();
}
代码示例来源:origin: weibocom/motan
private void afterExport() {
exported.set(true);
for (Exporter<T> ep : exporters) {
existingServices.add(ep.getProvider().getUrl().getIdentity());
}
}
代码示例来源:origin: weibocom/motan
public static <T> void delayDestroy(final List<Referer<T>> referers) {
if (referers == null || referers.isEmpty()) {
return;
}
scheduledExecutor.schedule(new Runnable() {
@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);
LoggerUtil.info("RefererSupports delayDestroy Success: size={} service={} urls={}", referers.size(), referers.get(0).getUrl()
.getIdentity(), getServerPorts(referers));
}
代码示例来源:origin: weibocom/motan
@Override
public String statisticCallback() {
return String.format("identity: %s connectionCount: %s taskCount: %s queueCount: %s maxThreadCount: %s maxTaskCount: %s",
url.getIdentity(), channelManage.getChannels().size(), standardThreadExecutor.getSubmittedTasksCount(),
standardThreadExecutor.getQueue().size(), standardThreadExecutor.getMaximumPoolSize(),
standardThreadExecutor.getMaxSubmittedTaskCount());
}
代码示例来源:origin: weibocom/motan
/**
* 统计回调接口
*/
@Override
public String statisticCallback() {
return String.format(
"identity: %s connectionCount: %s taskCount: %s queueCount: %s maxThreadCount: %s maxTaskCount: %s",
url.getIdentity(), channelManage.getChannels().size(), standardThreadExecutor.getSubmittedTasksCount(),
standardThreadExecutor.getQueue().size(), standardThreadExecutor.getMaximumPoolSize(),
standardThreadExecutor.getMaxSubmittedTaskCount());
}
代码示例来源:origin: weibocom/motan
/**
* 增加调用失败的次数:
* <p>
* <pre>
* 如果连续失败的次数 >= maxClientConnection, 那么把client设置成不可用状态
* </pre>
*/
void incrErrorCount() {
long count = errorCount.incrementAndGet();
// 如果节点是可用状态,同时当前连续失败的次数超过连接数,那么把该节点标示为不可用
if (count >= connections && state.isAliveState()) {
synchronized (this) {
count = errorCount.longValue();
if (count >= connections && state.isAliveState()) {
LoggerUtil.error("NettyClient unavailable Error: url=" + url.getIdentity() + " "
+ url.getServerPortStr());
state = ChannelState.UNALIVE;
}
}
}
}
代码示例来源:origin: weibocom/motan
@Override
public void unregister(URL url) {
if (url == null) {
LoggerUtil.warn("[{}] unregister with malformed param, url is null", registryClassName);
return;
}
LoggerUtil.info("[{}] Url ({}) will unregister to Registry [{}]", registryClassName, url, registryUrl.getIdentity());
doUnregister(removeUnnecessaryParmas(url.createCopy()));
registeredServiceUrls.remove(url);
}
代码示例来源:origin: weibocom/motan
@Override
public void subscribe(URL url, NotifyListener listener) {
if (url == null || listener == null) {
LoggerUtil.warn("[{}] subscribe with malformed param, url:{}, listener:{}", registryClassName, url, listener);
return;
}
LoggerUtil.info("[{}] Listener ({}) will subscribe to url ({}) in Registry [{}]", registryClassName, listener, url,
registryUrl.getIdentity());
doSubscribe(url.createCopy(), listener);
}
代码示例来源:origin: weibocom/motan
@Override
public void unsubscribe(URL url, NotifyListener listener) {
if (url == null || listener == null) {
LoggerUtil.warn("[{}] unsubscribe with malformed param, url:{}, listener:{}", registryClassName, url, listener);
return;
}
LoggerUtil.info("[{}] Listener ({}) will unsubscribe from url ({}) in Registry [{}]", registryClassName, listener, url,
registryUrl.getIdentity());
doUnsubscribe(url.createCopy(), listener);
}
代码示例来源:origin: weibocom/motan
@Override
public void available(URL url) {
LoggerUtil.info("[{}] Url ({}) will set to available to Registry [{}]", registryClassName, url, registryUrl.getIdentity());
if (url != null) {
doAvailable(removeUnnecessaryParmas(url.createCopy()));
} else {
doAvailable(null);
}
}
代码示例来源:origin: weibocom/motan
@Override
public void unavailable(URL url) {
LoggerUtil.info("[{}] Url ({}) will set to unavailable to Registry [{}]", registryClassName, url, registryUrl.getIdentity());
if (url != null) {
doUnavailable(removeUnnecessaryParmas(url.createCopy()));
} else {
doUnavailable(null);
}
}
代码示例来源:origin: weibocom/motan
@Override
public void register(URL url) {
if (url == null) {
LoggerUtil.warn("[{}] register with malformed param, url is null", registryClassName);
return;
}
LoggerUtil.info("[{}] Url ({}) will register to Registry [{}]", registryClassName, url, registryUrl.getIdentity());
doRegister(removeUnnecessaryParmas(url.createCopy()));
registeredServiceUrls.add(url);
// available if heartbeat switcher already open
if (MotanSwitcherUtil.isOpen(MotanConstants.REGISTRY_HEARTBEAT_SWITCHER)) {
available(url);
}
}
代码示例来源:origin: weibocom/motan
public void destroy() {
URL subscribeUrl = toSubscribeUrl(url);
for (URL ru : registryUrls) {
try {
Registry registry = getRegistry(ru);
registry.unsubscribe(subscribeUrl, this);
if (!MotanConstants.NODE_TYPE_REFERER.equals(url.getParameter(URLParamType.nodeType.getName()))) {
registry.unregister(url);
}
} catch (Exception e) {
LoggerUtil.warn(String.format("Unregister or unsubscribe false for url (%s), registry= %s", url, ru.getIdentity()), e);
}
}
try {
getCluster().destroy();
} catch (Exception e) {
LoggerUtil.warn(String.format("Exception when destroy cluster: %s", getCluster().getUrl()));
}
}
代码示例来源:origin: weibocom/motan
private byte[] encodeMessage(Object message) throws IOException {
byte[] data = null;
if (message instanceof Response) {
try {
data = codec.encode(client, message);
} catch (Exception e) {
LoggerUtil.error("NettyEncoder encode error, identity=" + client.getUrl().getIdentity(), e);
long requestId = getRequestId(message);
Response response = buildExceptionResponse(requestId, e);
data = codec.encode(client, response);
}
} else {
data = codec.encode(client, message);
}
return data;
}
代码示例来源:origin: weibocom/motan
private static byte[] encodeMessage(Channel channel, Codec codec, Object msg) throws IOException {
byte[] data;
if (msg instanceof Response) {
try {
data = codec.encode(channel, msg);
} catch (Exception e) {
LoggerUtil.error("NettyEncoder encode error, identity=" + channel.getUrl().getIdentity(), e);
long requestId = getRequestId(msg);
Response response = buildExceptionResponse(requestId, e);
data = codec.encode(channel, response);
}
} else {
data = codec.encode(channel, msg);
}
MotanFrameworkUtil.logRequestEvent(getRequestId(msg), "after encode rpc " + (msg instanceof Request ? "request " : "response ") + channel.getUrl().getServerPortStr(), System.currentTimeMillis());
return data;
}
内容来源于网络,如有侵权,请联系作者删除!