Skip to content

Commit

Permalink
fix compatible with zipkin. apache#3728
Browse files Browse the repository at this point in the history
  • Loading branch information
cvictory committed Apr 19, 2019
1 parent 9a96ac2 commit d2c5ffc
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.dubbo.remoting.exchange;

/**
* 2019-04-18
*/
@Deprecated
public interface ResponseCallback extends org.apache.dubbo.remoting.exchange.ResponseCallback {
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ default org.apache.dubbo.rpc.Invocation getOriginal() {
return null;
}

class CompatibleInvocation implements Invocation {
class CompatibleInvocation implements Invocation, org.apache.dubbo.rpc.Invocation {

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* rpcContext work for additional information regarding copyright ownership.
* The ASF licenses rpcContext file to You under the Apache License, Version 2.0
* (the "License"); you may not use rpcContext file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
Expand All @@ -19,4 +19,33 @@

@Deprecated
public class RpcContext extends org.apache.dubbo.rpc.RpcContext {


public static RpcContext getContext() {
return newInstance(org.apache.dubbo.rpc.RpcContext.getContext());
}

private static RpcContext newInstance(org.apache.dubbo.rpc.RpcContext rpcContext) {
RpcContext copy = new RpcContext();
copy.getAttachments().putAll(rpcContext.getAttachments());
copy.get().putAll(rpcContext.get());
copy.setFuture(rpcContext.getFuture());
copy.setUrls(rpcContext.getUrls());
copy.setUrl(rpcContext.getUrl());
copy.setMethodName(rpcContext.getMethodName());
copy.setParameterTypes(rpcContext.getParameterTypes());
copy.setArguments(rpcContext.getArguments());
copy.setLocalAddress(rpcContext.getLocalAddress());
copy.setRemoteAddress(rpcContext.getRemoteAddress());
copy.setRemoteApplicationName(rpcContext.getRemoteApplicationName());
copy.setInvokers(rpcContext.getInvokers());
copy.setInvoker(rpcContext.getInvoker());
copy.setInvocation(rpcContext.getInvocation());

copy.setRequest(rpcContext.getRequest());
copy.setResponse(rpcContext.getResponse());
copy.setAsyncContext(rpcContext.getAsyncContext());

return copy;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.dubbo.rpc.protocol.dubbo;

import org.apache.dubbo.remoting.exchange.ResponseFuture;

/**
* 2019-04-18
*/
public class FutureAdapter<V> extends org.apache.dubbo.rpc.protocol.dubbo.FutureAdapter<V> {
public FutureAdapter(ResponseFuture future) {
super(future);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.dubbo.rpc.support;

import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.rpc.Invocation;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Map;

/**
* 2019-04-18
*/
public class RpcUtils extends org.apache.dubbo.rpc.support.RpcUtils {


public static Class<?> getReturnType(Invocation invocation) {
return org.apache.dubbo.rpc.support.RpcUtils.getReturnType(invocation);
}

// TODO why not get return type when initialize Invocation?
public static Type[] getReturnTypes(Invocation invocation) {
return org.apache.dubbo.rpc.support.RpcUtils.getReturnTypes(invocation);
}

public static Long getInvocationId(Invocation inv) {
return org.apache.dubbo.rpc.support.RpcUtils.getInvocationId(inv);
}

/**
* Idempotent operation: invocation id will be added in async operation by default
*
* @param url
* @param inv
*/
public static void attachInvocationIdIfAsync(URL url, Invocation inv) {
org.apache.dubbo.rpc.support.RpcUtils.attachInvocationIdIfAsync(url.getOriginalURL(), inv);
}


public static String getMethodName(Invocation invocation) {
return org.apache.dubbo.rpc.support.RpcUtils.getMethodName(invocation);
}

public static Object[] getArguments(Invocation invocation) {
return org.apache.dubbo.rpc.support.RpcUtils.getArguments(invocation);
}

public static Class<?>[] getParameterTypes(Invocation invocation) {
return org.apache.dubbo.rpc.support.RpcUtils.getParameterTypes(invocation);
}

public static boolean isAsync(URL url, Invocation inv) {
return org.apache.dubbo.rpc.support.RpcUtils.isAsync(url.getOriginalURL(), inv);
}

public static boolean isReturnTypeFuture(Invocation inv) {
return org.apache.dubbo.rpc.support.RpcUtils.isReturnTypeFuture(inv);
}

public static boolean hasFutureReturnType(Method method) {
return org.apache.dubbo.rpc.support.RpcUtils.hasFutureReturnType(method);
}

public static boolean isOneway(URL url, Invocation inv) {
return org.apache.dubbo.rpc.support.RpcUtils.isOneway(url.getOriginalURL(), inv);
}

public static Map<String, String> getNecessaryAttachments(Invocation inv) {
return org.apache.dubbo.rpc.support.RpcUtils.getNecessaryAttachments(inv);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,10 @@ public static AsyncContext startAsync() throws IllegalStateException {
return currentContext.asyncContext;
}

protected void setAsyncContext(AsyncContext asyncContext) {
this.asyncContext = asyncContext;
}

public boolean isAsyncStarted() {
if (this.asyncContext == null) {
return false;
Expand Down

0 comments on commit d2c5ffc

Please sign in to comment.