changes serve for 3.0
This commit is contained in:
parent
de380d5169
commit
549f97ccf3
|
|
@ -34,6 +34,11 @@ import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
|
|||
*/
|
||||
public class MockDirInvocation implements Invocation {
|
||||
|
||||
@Override
|
||||
public String getTargetServiceUniqueName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return "echo";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ public interface Invocation extends org.apache.dubbo.rpc.Invocation {
|
|||
this.delegate = invocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetServiceUniqueName() {
|
||||
return delegate.getTargetServiceUniqueName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodName() {
|
||||
return delegate.getMethodName();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import com.alibaba.dubbo.cache.CacheFactory;
|
|||
import com.alibaba.dubbo.common.URL;
|
||||
import com.alibaba.dubbo.rpc.Invocation;
|
||||
import com.alibaba.dubbo.rpc.Invoker;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
|
@ -49,6 +48,11 @@ public class CacheTest {
|
|||
}
|
||||
|
||||
static class NullInvocation implements Invocation {
|
||||
@Override
|
||||
public String getTargetServiceUniqueName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodName() {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@ public class LegacyInvocation implements Invocation {
|
|||
this.arg0 = arg0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetServiceUniqueName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return "echo";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ public class MockInvocation implements Invocation {
|
|||
this.arg0 = arg0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetServiceUniqueName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return "echo";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,9 +356,11 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
|
||||
serviceMetadata.getAttachments().putAll(map);
|
||||
|
||||
ApplicationModel.initConsumerModel(URL.buildKey(interfaceName, group, version), buildConsumerModel(attributes, serviceMetadata));
|
||||
|
||||
ref = createProxy(map);
|
||||
|
||||
ApplicationModel.initConsumerModel(serviceMetadata.getServiceKey(), buildConsumerModel(attributes, serviceMetadata));
|
||||
|
||||
serviceMetadata.setTarget(ref);
|
||||
serviceMetadata.addAttribute(PROXY_CLASS_REF, ref);
|
||||
initialized = true;
|
||||
|
|
@ -417,7 +419,7 @@ public class ReferenceConfig<T> extends AbstractReferenceConfig {
|
|||
}
|
||||
} else { // assemble URL from register center's configuration
|
||||
// if protocols not injvm checkRegistry
|
||||
if (!LOCAL_PROTOCOL.equalsIgnoreCase(getProtocol())){
|
||||
if (!LOCAL_PROTOCOL.equalsIgnoreCase(getProtocol())) {
|
||||
checkRegistry();
|
||||
List<URL> us = loadRegistries(false);
|
||||
if (CollectionUtils.isNotEmpty(us)) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.apache.dubbo.registry;
|
|||
|
||||
import org.apache.dubbo.common.URL;
|
||||
import org.apache.dubbo.common.extension.SPI;
|
||||
import org.apache.dubbo.rpc.cluster.Directory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -29,7 +30,8 @@ public interface AddressListener {
|
|||
*
|
||||
* @param addresses provider address list
|
||||
* @param registryDirectoryUrl
|
||||
* @param registryDirectory
|
||||
*/
|
||||
List<URL> notify(List<URL> addresses, URL registryDirectoryUrl);
|
||||
List<URL> notify(List<URL> addresses, URL registryDirectoryUrl, Directory registryDirectory);
|
||||
|
||||
}
|
||||
|
|
@ -238,7 +238,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
|
|||
List<AddressListener> supportedListeners = addressListenerExtensionLoader.getActivateExtension(getUrl(), (String[]) null);
|
||||
if (supportedListeners != null && !supportedListeners.isEmpty()) {
|
||||
for (AddressListener addressListener : supportedListeners) {
|
||||
providerURLs = addressListener.notify(providerURLs, getUrl());
|
||||
providerURLs = addressListener.notify(providerURLs, getUrl(),this);
|
||||
}
|
||||
}
|
||||
refreshOverrideAndInvoker(providerURLs);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ import java.util.Map;
|
|||
*/
|
||||
public interface Invocation {
|
||||
|
||||
String getTargetServiceUniqueName();
|
||||
|
||||
/**
|
||||
* get method name.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ public class RpcInvocation implements Invocation, Serializable {
|
|||
|
||||
private static final long serialVersionUID = -4355285085441097045L;
|
||||
|
||||
private String targetServiceUniqueName;
|
||||
|
||||
private String methodName;
|
||||
|
||||
private Class<?>[] parameterTypes;
|
||||
|
|
@ -86,11 +88,13 @@ public class RpcInvocation implements Invocation, Serializable {
|
|||
setAttachment(APPLICATION_KEY, url.getParameter(APPLICATION_KEY));
|
||||
}
|
||||
}
|
||||
this.targetServiceUniqueName = invocation.getTargetServiceUniqueName();
|
||||
}
|
||||
|
||||
public RpcInvocation(Invocation invocation) {
|
||||
this(invocation.getMethodName(), invocation.getParameterTypes(),
|
||||
invocation.getArguments(), invocation.getAttachments(), invocation.getInvoker());
|
||||
this.targetServiceUniqueName = invocation.getTargetServiceUniqueName();
|
||||
}
|
||||
|
||||
public RpcInvocation(Method method, Object[] arguments) {
|
||||
|
|
@ -141,6 +145,15 @@ public class RpcInvocation implements Invocation, Serializable {
|
|||
return attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetServiceUniqueName() {
|
||||
return targetServiceUniqueName;
|
||||
}
|
||||
|
||||
public void setTargetServiceUniqueName(String targetServiceUniqueName) {
|
||||
this.targetServiceUniqueName = targetServiceUniqueName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,10 @@ public class GenericFilter extends ListenableFilter {
|
|||
args[0].getClass().getName());
|
||||
}
|
||||
}
|
||||
return invoker.invoke(new RpcInvocation(method, args, inv.getAttachments(), inv.getAttributes()));
|
||||
RpcInvocation rpcInvocation = new RpcInvocation(method, args, inv.getAttachments(), inv.getAttributes());
|
||||
rpcInvocation.setTargetServiceUniqueName(inv.getTargetServiceUniqueName());
|
||||
|
||||
return invoker.invoke(rpcInvocation);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RpcException(e.getMessage(), e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ public class InvokerInvocationHandler implements InvocationHandler {
|
|||
if ("equals".equals(methodName) && parameterTypes.length == 1) {
|
||||
return invoker.equals(args[0]);
|
||||
}
|
||||
RpcInvocation rpcInvocation = new RpcInvocation(method, args);
|
||||
rpcInvocation.setTargetServiceUniqueName(invoker.getUrl().getServiceKey());
|
||||
|
||||
return invoker.invoke(new RpcInvocation(method, args)).recreate();
|
||||
return invoker.invoke(rpcInvocation).recreate();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
|
|||
*/
|
||||
public class MockInvocation implements Invocation {
|
||||
|
||||
@Override
|
||||
public String getTargetServiceUniqueName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return "echo";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,12 @@ import java.io.OutputStream;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.dubbo.common.URL.buildKey;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
|
||||
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
|
||||
import static org.apache.dubbo.rpc.protocol.dubbo.CallbackServiceCodec.decodeInvocationArgument;
|
||||
import static org.apache.dubbo.remoting.Constants.DUBBO_VERSION_KEY;
|
||||
import static org.apache.dubbo.rpc.protocol.dubbo.CallbackServiceCodec.decodeInvocationArgument;
|
||||
|
||||
public class DecodeableRpcInvocation extends RpcInvocation implements Codec, Decodeable {
|
||||
|
||||
|
|
@ -138,7 +140,10 @@ public class DecodeableRpcInvocation extends RpcInvocation implements Codec, Dec
|
|||
}
|
||||
|
||||
setArguments(args);
|
||||
|
||||
String targetServiceName = buildKey((String) getAttachment(PATH_KEY),
|
||||
(String) getAttachment(GROUP_KEY),
|
||||
(String) getAttachment(VERSION_KEY));
|
||||
setTargetServiceUniqueName(targetServiceName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IOException(StringUtils.toString("Read invocation data failed.", e));
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Reference in New Issue