Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touzizhuo03
Dubbo
提交
2d444775
D
Dubbo
项目概览
touzizhuo03
/
Dubbo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dubbo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2d444775
编写于
7月 10, 2012
作者:
L
liangfei0201
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
DUBBO-480 统一异步调用各参数的key为async=true和return=false
上级
10a3d8bd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
20 deletion
+16
-20
dubbo-common/src/main/java/com/alibaba/dubbo/common/Constants.java
...mon/src/main/java/com/alibaba/dubbo/common/Constants.java
+4
-8
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
...c-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
+4
-4
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java
.../java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java
+2
-2
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/RpcUtils.java
...src/main/java/com/alibaba/dubbo/rpc/support/RpcUtils.java
+6
-6
未找到文件。
dubbo-common/src/main/java/com/alibaba/dubbo/common/Constants.java
浏览文件 @
2d444775
...
...
@@ -272,8 +272,12 @@ public class Constants {
public
static
final
String
CLIENT_KEY
=
"client"
;
public
static
final
String
ID_KEY
=
"id"
;
public
static
final
String
ASYNC_KEY
=
"async"
;
public
static
final
String
RETURN_KEY
=
"return"
;
public
static
final
String
TOKEN_KEY
=
"token"
;
public
static
final
String
METHOD_KEY
=
"method"
;
...
...
@@ -503,8 +507,6 @@ public class Constants {
public
static
final
String
ON_DISCONNECT_KEY
=
"ondisconnect"
;
public
static
final
String
RETURN_KEY
=
"return"
;
public
static
final
String
ON_INVOKE_METHOD_KEY
=
"oninvoke.method"
;
public
static
final
String
ON_RETURN_METHOD_KEY
=
"onreturn.method"
;
...
...
@@ -568,11 +570,5 @@ public class Constants {
/*
* private Constants(){ }
*/
public
static
class
Attachments
{
public
static
final
String
IS_ASYNC_KEY
=
"attachments.async"
;
public
static
final
String
IS_ONEWAY_KEY
=
"attachments.oneway"
;
public
static
final
String
INVOCATIONID_KEY
=
"attachments.invocation.id"
;
}
}
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java
浏览文件 @
2d444775
...
...
@@ -564,7 +564,7 @@ public class RpcContext {
public
<
T
>
Future
<
T
>
asyncCall
(
Callable
<
T
>
callable
)
{
try
{
try
{
setAttachment
(
Constants
.
A
ttachments
.
IS_A
SYNC_KEY
,
Boolean
.
TRUE
.
toString
());
setAttachment
(
Constants
.
ASYNC_KEY
,
Boolean
.
TRUE
.
toString
());
final
T
o
=
callable
.
call
();
//local调用会直接返回结果.
if
(
o
!=
null
)
{
...
...
@@ -581,7 +581,7 @@ public class RpcContext {
}
catch
(
Exception
e
)
{
throw
new
RpcException
(
e
);
}
finally
{
removeAttachment
(
Constants
.
A
ttachments
.
IS_A
SYNC_KEY
);
removeAttachment
(
Constants
.
ASYNC_KEY
);
}
}
catch
(
final
RpcException
e
)
{
return
new
Future
<
T
>()
{
...
...
@@ -613,13 +613,13 @@ public class RpcContext {
*/
public
void
asyncCall
(
Runnable
runable
)
{
try
{
setAttachment
(
Constants
.
Attachments
.
IS_ONEWAY_KEY
,
Boolean
.
TRU
E
.
toString
());
setAttachment
(
Constants
.
RETURN_KEY
,
Boolean
.
FALS
E
.
toString
());
runable
.
run
();
}
catch
(
Throwable
e
)
{
//FIXME 异常是否应该放在future中?
throw
new
RpcException
(
"oneway call error ."
+
e
.
getMessage
(),
e
);
}
finally
{
removeAttachment
(
Constants
.
Attachments
.
IS_ONEWAY
_KEY
);
removeAttachment
(
Constants
.
RETURN
_KEY
);
}
}
}
\ No newline at end of file
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/protocol/AbstractInvoker.java
浏览文件 @
2d444775
...
...
@@ -116,7 +116,7 @@ public abstract class AbstractInvoker<T> implements Invoker<T> {
}
public
String
toString
()
{
return
getInterface
()
+
" -> "
+
getUrl
()==
null
?
" "
:
getUrl
().
toString
(
);
return
getInterface
()
+
" -> "
+
(
getUrl
()
==
null
?
""
:
getUrl
().
toString
()
);
}
public
Result
invoke
(
Invocation
inv
)
throws
RpcException
{
...
...
@@ -135,7 +135,7 @@ public abstract class AbstractInvoker<T> implements Invoker<T> {
invocation
.
addAttachmentsIfAbsent
(
context
);
}
if
(
getUrl
().
getMethodParameter
(
invocation
.
getMethodName
(),
Constants
.
ASYNC_KEY
,
false
)){
invocation
.
setAttachment
(
Constants
.
A
ttachments
.
IS_A
SYNC_KEY
,
Boolean
.
TRUE
.
toString
());
invocation
.
setAttachment
(
Constants
.
ASYNC_KEY
,
Boolean
.
TRUE
.
toString
());
}
RpcUtils
.
attachInvocationIdIfAsync
(
getUrl
(),
invocation
);
...
...
dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/support/RpcUtils.java
浏览文件 @
2d444775
...
...
@@ -82,7 +82,7 @@ public class RpcUtils {
private
static
final
AtomicLong
INVOKE_ID
=
new
AtomicLong
(
0
);
public
static
Long
getInvocationId
(
Invocation
inv
)
{
String
id
=
inv
.
getAttachment
(
Constants
.
Attachments
.
INVOCATION
ID_KEY
);
String
id
=
inv
.
getAttachment
(
Constants
.
ID_KEY
);
return
id
==
null
?
null
:
new
Long
(
id
);
}
...
...
@@ -93,7 +93,7 @@ public class RpcUtils {
*/
public
static
void
attachInvocationIdIfAsync
(
URL
url
,
Invocation
inv
){
if
(
isAttachInvocationId
(
url
,
inv
)
&&
getInvocationId
(
inv
)
==
null
&&
inv
instanceof
RpcInvocation
)
{
((
RpcInvocation
)
inv
).
setAttachment
(
Constants
.
Attachments
.
INVOCATION
ID_KEY
,
String
.
valueOf
(
INVOKE_ID
.
getAndIncrement
()));
((
RpcInvocation
)
inv
).
setAttachment
(
Constants
.
ID_KEY
,
String
.
valueOf
(
INVOKE_ID
.
getAndIncrement
()));
}
}
...
...
@@ -152,10 +152,10 @@ public class RpcUtils {
public
static
boolean
isAsync
(
URL
url
,
Invocation
inv
)
{
boolean
isAsync
;
//如果Java代码中设置优先.
if
(
Boolean
.
TRUE
.
toString
().
equals
(
inv
.
getAttachment
(
Constants
.
Attachments
.
IS_
ASYNC_KEY
)))
{
if
(
Boolean
.
FALSE
.
toString
().
equals
(
inv
.
getAttachment
(
Constants
.
ASYNC_KEY
)))
{
isAsync
=
true
;
}
else
{
isAsync
=
url
.
getMethodParameter
(
getMethodName
(
inv
),
Constants
.
ASYNC_KEY
,
fals
e
);
isAsync
=
url
.
getMethodParameter
(
getMethodName
(
inv
),
Constants
.
ASYNC_KEY
,
tru
e
);
}
return
isAsync
;
}
...
...
@@ -163,10 +163,10 @@ public class RpcUtils {
public
static
boolean
isOneway
(
URL
url
,
Invocation
inv
)
{
boolean
isOneway
;
//如果Java代码中设置优先.
if
(
Boolean
.
TRUE
.
toString
().
equals
(
inv
.
getAttachment
(
Constants
.
Attachments
.
IS_ONEWAY
_KEY
)))
{
if
(
Boolean
.
FALSE
.
toString
().
equals
(
inv
.
getAttachment
(
Constants
.
RETURN
_KEY
)))
{
isOneway
=
true
;
}
else
{
isOneway
=
url
.
getMethodParameter
(
getMethodName
(
inv
),
Constants
.
RETURN_KEY
,
fals
e
);
isOneway
=
!
url
.
getMethodParameter
(
getMethodName
(
inv
),
Constants
.
RETURN_KEY
,
tru
e
);
}
return
isOneway
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录