本文整理了Java中org.apache.dubbo.common.Version
类的一些代码示例,展示了Version
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version
类的具体详情如下:
包路径:org.apache.dubbo.common.Version
类名称:Version
[英]Version
[中]版本
代码示例来源:origin: apache/incubator-dubbo
private String appendContextMessage(String msg) {
return " [DUBBO] " + msg + ", dubbo version: " + Version.getVersion() + ", current host: " + NetUtils.getLocalHost();
}
代码示例来源:origin: apache/incubator-dubbo
static void appendRuntimeParameters(Map<String, String> map) {
map.put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
map.put(Constants.RELEASE_KEY, Version.getVersion());
map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
if (ConfigUtils.getPid() > 0) {
map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid()));
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
RemoteInvocation invocation;
/*
package was renamed to 'org.apache.dubbo' in v2.7.0, so only provider versions after v2.7.0 can
recognize org.apache.xxx.HttpRemoteInvocation'.
*/
if (Version.isRelease270OrHigher(url.getParameter(Constants.RELEASE_KEY))) {
invocation = new HttpRemoteInvocation(methodInvocation);
} else {
/*
The customized 'com.alibaba.dubbo.rpc.protocol.http.HttpRemoteInvocation' was firstly introduced
in v2.6.3. The main purpose is to support transformation of attachments in HttpProtocol, see
https://github.com/apache/incubator-dubbo/pull/1827. To guarantee interoperability with lower
versions, we need to check if the provider is v2.6.3 or higher before sending customized
HttpRemoteInvocation.
*/
if (Version.isRelease263OrHigher(url.getParameter(Constants.DUBBO_VERSION_KEY))) {
invocation = new com.alibaba.dubbo.rpc.protocol.http.HttpRemoteInvocation(methodInvocation);
} else {
invocation = new RemoteInvocation(methodInvocation);
}
}
if (isGeneric) {
invocation.addAttribute(Constants.GENERIC_KEY, generic);
}
return invocation;
}
});
代码示例来源:origin: apache/incubator-dubbo
@Override
protected void encodeResponseData(Channel channel, ObjectOutput out, Object data, String version) throws IOException {
Result result = (Result) data;
// currently, the version value in Response records the version of Request
boolean attach = Version.isSupportResponseAttachment(version);
Throwable th = result.getException();
if (th == null) {
Object ret = result.getValue();
if (ret == null) {
out.writeByte(attach ? RESPONSE_NULL_VALUE_WITH_ATTACHMENTS : RESPONSE_NULL_VALUE);
} else {
out.writeByte(attach ? RESPONSE_VALUE_WITH_ATTACHMENTS : RESPONSE_VALUE);
out.writeObject(ret);
}
} else {
out.writeByte(attach ? RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS : RESPONSE_WITH_EXCEPTION);
out.writeObject(th);
}
if (attach) {
// returns current version of Response to consumer side.
result.getAttachments().put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
out.writeObject(result.getAttachments());
}
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
try {
NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler);
if (logger.isDebugEnabled()) {
logger.debug("IdleStateEvent triggered, send heartbeat to channel " + channel);
}
Request req = new Request();
req.setVersion(Version.getProtocolVersion());
req.setTwoWay(true);
req.setEvent(Request.HEARTBEAT_EVENT);
channel.send(req);
} finally {
NettyChannel.removeChannelIfDisconnected(ctx.channel());
}
} else {
super.userEventTriggered(ctx, evt);
}
}
代码示例来源:origin: apache/incubator-dubbo
/**
* Check the framework release version number to decide if it's 2.6.3 or higher
*
* Because response attachments feature is firstly introduced in 2.6.3
* and moreover we have no other approach to know the framework's version, so we use
* isSupportResponseAttachment to decide if it's v2.6.3.
*/
public static boolean isRelease263OrHigher(String version) {
return isSupportResponseAttachment(version);
}
代码示例来源:origin: apache/incubator-dubbo
public static void checkDuplicate(Class<?> cls) {
checkDuplicate(cls, false);
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void send(Object message, boolean sent) throws RemotingException {
if (closed) {
throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message + ", cause: The channel " + this + " is closed!");
}
if (message instanceof Request
|| message instanceof Response
|| message instanceof String) {
channel.send(message, sent);
} else {
Request request = new Request();
request.setVersion(Version.getProtocolVersion());
request.setTwoWay(false);
request.setData(message);
channel.send(request, sent);
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
protected void encodeResponseData(Channel channel, ObjectOutput out, Object data, String version) throws IOException {
Result result = (Result) data;
// currently, the version value in Response records the version of Request
boolean attach = Version.isSupportResponseAttachment(version);
Throwable th = result.getException();
if (th == null) {
Object ret = result.getValue();
if (ret == null) {
out.writeByte(attach ? RESPONSE_NULL_VALUE_WITH_ATTACHMENTS : RESPONSE_NULL_VALUE);
} else {
out.writeByte(attach ? RESPONSE_VALUE_WITH_ATTACHMENTS : RESPONSE_VALUE);
out.writeObject(ret);
}
} else {
out.writeByte(attach ? RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS : RESPONSE_WITH_EXCEPTION);
out.writeObject(th);
}
if (attach) {
// returns current version of Response to consumer side.
result.getAttachments().put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
out.writeObject(result.getAttachments());
}
}
}
代码示例来源:origin: apache/incubator-dubbo
/**
* Check the framework release version number to decide if it's 2.6.3 or higher
*
* Because response attachments feature is firstly introduced in 2.6.3
* and moreover we have no other approach to know the framework's version, so we use
* isSupportResponseAttachment to decide if it's v2.6.3.
*/
public static boolean isRelease263OrHigher(String version) {
return isSupportResponseAttachment(version);
}
代码示例来源:origin: apache/incubator-dubbo
public static void checkDuplicate(Class<?> cls) {
checkDuplicate(cls, false);
}
代码示例来源:origin: apache/incubator-dubbo
private String appendContextMessage(String msg) {
return " [DUBBO] " + msg + ", dubbo version: " + Version.getVersion() + ", current host: " + NetUtils.getLocalHost();
}
代码示例来源:origin: apache/incubator-dubbo
static void appendRuntimeParameters(Map<String, String> map) {
map.put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
map.put(Constants.RELEASE_KEY, Version.getVersion());
map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
if (ConfigUtils.getPid() > 0) {
map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid()));
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void send(Object message, boolean sent) throws RemotingException {
if (closed) {
throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message + ", cause: The channel " + this + " is closed!");
}
if (message instanceof Request
|| message instanceof Response
|| message instanceof String) {
channel.send(message, sent);
} else {
Request request = new Request();
request.setVersion(Version.getProtocolVersion());
request.setTwoWay(false);
request.setData(message);
channel.send(request, sent);
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
RemoteInvocation invocation;
/*
package was renamed to 'org.apache.dubbo' in v2.7.0, so only provider versions after v2.7.0 can
recognize org.apache.xxx.HttpRemoteInvocation'.
*/
if (Version.isRelease270OrHigher(url.getParameter(Constants.RELEASE_KEY))) {
invocation = new HttpRemoteInvocation(methodInvocation);
} else {
/*
The customized 'com.alibaba.dubbo.rpc.protocol.http.HttpRemoteInvocation' was firstly introduced
in v2.6.3. The main purpose is to support transformation of attachments in HttpProtocol, see
https://github.com/apache/incubator-dubbo/pull/1827. To guarantee interoperability with lower
versions, we need to check if the provider is v2.6.3 or higher before sending customized
HttpRemoteInvocation.
*/
if (Version.isRelease263OrHigher(url.getParameter(Constants.DUBBO_VERSION_KEY))) {
invocation = new com.alibaba.dubbo.rpc.protocol.http.HttpRemoteInvocation(methodInvocation);
} else {
invocation = new RemoteInvocation(methodInvocation);
}
}
if (isGeneric) {
invocation.addAttribute(Constants.GENERIC_KEY, generic);
}
return invocation;
}
});
代码示例来源:origin: org.apache.dubbo/dubbo-rpc-dubbo
@Override
protected void encodeResponseData(Channel channel, ObjectOutput out, Object data, String version) throws IOException {
Result result = (Result) data;
// currently, the version value in Response records the version of Request
boolean attach = Version.isSupportResponseAttachment(version);
Throwable th = result.getException();
if (th == null) {
Object ret = result.getValue();
if (ret == null) {
out.writeByte(attach ? RESPONSE_NULL_VALUE_WITH_ATTACHMENTS : RESPONSE_NULL_VALUE);
} else {
out.writeByte(attach ? RESPONSE_VALUE_WITH_ATTACHMENTS : RESPONSE_VALUE);
out.writeObject(ret);
}
} else {
out.writeByte(attach ? RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS : RESPONSE_WITH_EXCEPTION);
out.writeObject(th);
}
if (attach) {
// returns current version of Response to consumer side.
result.getAttachments().put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
out.writeObject(result.getAttachments());
}
}
}
代码示例来源:origin: org.apache.dubbo/dubbo
/**
* Check the framework release version number to decide if it's 2.6.3 or higher
*
* Because response attachments feature is firstly introduced in 2.6.3
* and moreover we have no other approach to know the framework's version, so we use
* isSupportResponseAttachment to decide if it's v2.6.3.
*/
public static boolean isRelease263OrHigher(String version) {
return isSupportResponseAttachment(version);
}
代码示例来源:origin: apache/incubator-dubbo
public static void checkDuplicate(Class<?> cls, boolean failOnError) {
checkDuplicate(cls.getName().replace('.', '/') + ".class", failOnError);
}
代码示例来源:origin: apache/incubator-dubbo
protected void checkWhetherDestroyed() {
if (destroyed.get()) {
throw new RpcException("Rpc cluster invoker for " + getInterface() + " on consumer " + NetUtils.getLocalHost()
+ " use dubbo version " + Version.getVersion()
+ " is now destroyed! Can not invoke any more.");
}
}
代码示例来源:origin: org.apache.dubbo/dubbo
static void appendRuntimeParameters(Map<String, String> map) {
map.put(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion());
map.put(Constants.RELEASE_KEY, Version.getVersion());
map.put(Constants.TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
if (ConfigUtils.getPid() > 0) {
map.put(Constants.PID_KEY, String.valueOf(ConfigUtils.getPid()));
}
}
内容来源于网络,如有侵权,请联系作者删除!