Skip to content

Commit 8456a11

Browse files
cvictorychickenlj
authored andcommitted
Merge pull request #4014, Zipkin compatible.
fixes #3728.
1 parent 086fdcb commit 8456a11

File tree

6 files changed

+176
-1
lines changed

6 files changed

+176
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.alibaba.dubbo.remoting.exchange;
19+
20+
/**
21+
* 2019-04-18
22+
*/
23+
@Deprecated
24+
public interface ResponseCallback extends org.apache.dubbo.remoting.exchange.ResponseCallback {
25+
}

dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/Invocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ default org.apache.dubbo.rpc.Invocation getOriginal() {
2929
return null;
3030
}
3131

32-
class CompatibleInvocation implements Invocation {
32+
class CompatibleInvocation implements Invocation, org.apache.dubbo.rpc.Invocation {
3333

3434
private org.apache.dubbo.rpc.Invocation delegate;
3535

dubbo-compatible/src/main/java/com/alibaba/dubbo/rpc/RpcContext.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,33 @@
1919

2020
@Deprecated
2121
public class RpcContext extends org.apache.dubbo.rpc.RpcContext {
22+
23+
24+
public static RpcContext getContext() {
25+
return newInstance(org.apache.dubbo.rpc.RpcContext.getContext());
26+
}
27+
28+
private static RpcContext newInstance(org.apache.dubbo.rpc.RpcContext rpcContext) {
29+
RpcContext copy = new RpcContext();
30+
copy.getAttachments().putAll(rpcContext.getAttachments());
31+
copy.get().putAll(rpcContext.get());
32+
copy.setFuture(rpcContext.getFuture());
33+
copy.setUrls(rpcContext.getUrls());
34+
copy.setUrl(rpcContext.getUrl());
35+
copy.setMethodName(rpcContext.getMethodName());
36+
copy.setParameterTypes(rpcContext.getParameterTypes());
37+
copy.setArguments(rpcContext.getArguments());
38+
copy.setLocalAddress(rpcContext.getLocalAddress());
39+
copy.setRemoteAddress(rpcContext.getRemoteAddress());
40+
copy.setRemoteApplicationName(rpcContext.getRemoteApplicationName());
41+
copy.setInvokers(rpcContext.getInvokers());
42+
copy.setInvoker(rpcContext.getInvoker());
43+
copy.setInvocation(rpcContext.getInvocation());
44+
45+
copy.setRequest(rpcContext.getRequest());
46+
copy.setResponse(rpcContext.getResponse());
47+
copy.setAsyncContext(rpcContext.getAsyncContext());
48+
49+
return copy;
50+
}
2251
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.alibaba.dubbo.rpc.protocol.dubbo;
19+
20+
import org.apache.dubbo.remoting.exchange.ResponseFuture;
21+
22+
/**
23+
* 2019-04-18
24+
*/
25+
public class FutureAdapter<V> extends org.apache.dubbo.rpc.protocol.dubbo.FutureAdapter<V> {
26+
public FutureAdapter(ResponseFuture future) {
27+
super(future);
28+
}
29+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.alibaba.dubbo.rpc.support;
19+
20+
import com.alibaba.dubbo.common.URL;
21+
import com.alibaba.dubbo.rpc.Invocation;
22+
23+
import java.lang.reflect.Method;
24+
import java.lang.reflect.Type;
25+
import java.util.Map;
26+
27+
/**
28+
* 2019-04-18
29+
*/
30+
public class RpcUtils extends org.apache.dubbo.rpc.support.RpcUtils {
31+
32+
33+
public static Class<?> getReturnType(Invocation invocation) {
34+
return org.apache.dubbo.rpc.support.RpcUtils.getReturnType(invocation);
35+
}
36+
37+
// TODO why not get return type when initialize Invocation?
38+
public static Type[] getReturnTypes(Invocation invocation) {
39+
return org.apache.dubbo.rpc.support.RpcUtils.getReturnTypes(invocation);
40+
}
41+
42+
public static Long getInvocationId(Invocation inv) {
43+
return org.apache.dubbo.rpc.support.RpcUtils.getInvocationId(inv);
44+
}
45+
46+
/**
47+
* Idempotent operation: invocation id will be added in async operation by default
48+
*
49+
* @param url
50+
* @param inv
51+
*/
52+
public static void attachInvocationIdIfAsync(URL url, Invocation inv) {
53+
org.apache.dubbo.rpc.support.RpcUtils.attachInvocationIdIfAsync(url.getOriginalURL(), inv);
54+
}
55+
56+
57+
public static String getMethodName(Invocation invocation) {
58+
return org.apache.dubbo.rpc.support.RpcUtils.getMethodName(invocation);
59+
}
60+
61+
public static Object[] getArguments(Invocation invocation) {
62+
return org.apache.dubbo.rpc.support.RpcUtils.getArguments(invocation);
63+
}
64+
65+
public static Class<?>[] getParameterTypes(Invocation invocation) {
66+
return org.apache.dubbo.rpc.support.RpcUtils.getParameterTypes(invocation);
67+
}
68+
69+
public static boolean isAsync(URL url, Invocation inv) {
70+
return org.apache.dubbo.rpc.support.RpcUtils.isAsync(url.getOriginalURL(), inv);
71+
}
72+
73+
public static boolean isReturnTypeFuture(Invocation inv) {
74+
return org.apache.dubbo.rpc.support.RpcUtils.isReturnTypeFuture(inv);
75+
}
76+
77+
public static boolean hasFutureReturnType(Method method) {
78+
return org.apache.dubbo.rpc.support.RpcUtils.hasFutureReturnType(method);
79+
}
80+
81+
public static boolean isOneway(URL url, Invocation inv) {
82+
return org.apache.dubbo.rpc.support.RpcUtils.isOneway(url.getOriginalURL(), inv);
83+
}
84+
85+
public static Map<String, String> getNecessaryAttachments(Invocation inv) {
86+
return org.apache.dubbo.rpc.support.RpcUtils.getNecessaryAttachments(inv);
87+
}
88+
}

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,10 @@ public static AsyncContext startAsync() throws IllegalStateException {
758758
return currentContext.asyncContext;
759759
}
760760

761+
protected void setAsyncContext(AsyncContext asyncContext) {
762+
this.asyncContext = asyncContext;
763+
}
764+
761765
public boolean isAsyncStarted() {
762766
if (this.asyncContext == null) {
763767
return false;

0 commit comments

Comments
 (0)