Adjust the acquisition of the app, group, and version value of the url (#8582)

* Adjust the acquisition of the app, group, and version value of the url

* FIX
This commit is contained in:
灼华 2021-08-27 13:50:53 +08:00 committed by GitHub
parent 31e1aa6b59
commit d386cd5f07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 17 deletions

View File

@ -17,7 +17,6 @@
package org.apache.dubbo.rpc.cluster.router.condition.config;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
/**
* Application level router, "application.condition-router"
@ -30,7 +29,7 @@ public class AppRouter extends ListenableRouter {
private static final int APP_ROUTER_DEFAULT_PRIORITY = 150;
public AppRouter(URL url) {
super(url, url.getParameter(CommonConstants.APPLICATION_KEY));
super(url, url.getApplication());
this.setPriority(APP_ROUTER_DEFAULT_PRIORITY);
}
}

View File

@ -51,13 +51,11 @@ import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZATION_BEAN;
import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZATION_DEFAULT;
import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZATION_NATIVE_JAVA;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.config.Constants.SHUTDOWN_TIMEOUT_KEY;
import static org.apache.dubbo.remoting.Constants.BIND_IP_KEY;
import static org.apache.dubbo.remoting.Constants.BIND_PORT_KEY;
@ -184,10 +182,10 @@ public class ServiceConfigTest {
service.export();
String serviceVersion = service.getVersion();
String serviceVersion2 = service.toUrl().getParameter(VERSION_KEY);
String serviceVersion2 = service.toUrl().getVersion();
String group = service.getGroup();
String group2 = service.toUrl().getParameter(GROUP_KEY);
String group2 = service.toUrl().getGroup();
assertEquals(serviceVersion2, serviceVersion);
assertEquals(group, group2);

View File

@ -17,7 +17,6 @@
package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.metadata.WritableMetadataService;
import org.apache.dubbo.registry.Registry;
@ -49,7 +48,7 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListen
* Checks if the registry is checked application
*/
private boolean isCheckedApplication(Registry registry){
return registry.getUrl().getParameter(CommonConstants.APPLICATION_KEY)
return registry.getUrl().getApplication()
.equals(MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest
.PROVIDER_APPLICATION_NAME);
}

View File

@ -32,7 +32,7 @@ public class AccessKeyAuthenticator implements Authenticator {
@Override
public void sign(Invocation invocation, URL url) {
String currentTime = String.valueOf(System.currentTimeMillis());
String consumer = url.getParameter(CommonConstants.APPLICATION_KEY);
String consumer = url.getApplication();
AccessKeyPair accessKeyPair = getAccessKeyPair(invocation, url);
invocation.setAttachment(Constants.REQUEST_SIGNATURE_KEY, getSignature(url, invocation, accessKeyPair.getSecretKey(), currentTime));
invocation.setAttachment(Constants.REQUEST_TIMESTAMP_KEY, currentTime);

View File

@ -58,7 +58,7 @@ class AccessKeyAuthenticatorTest {
when(helper.getAccessKeyPair(invocation, url)).thenReturn(accessKeyPair);
helper.sign(invocation, url);
assertEquals(String.valueOf(invocation.getAttachment(CommonConstants.CONSUMER)), url.getParameter(CommonConstants.APPLICATION_KEY));
assertEquals(String.valueOf(invocation.getAttachment(CommonConstants.CONSUMER)), url.getApplication());
assertNotNull(invocation.getAttachments().get(Constants.REQUEST_SIGNATURE_KEY));
assertEquals(invocation.getAttachments().get(Constants.REQUEST_SIGNATURE_KEY), "dubbo");
}

View File

@ -68,7 +68,7 @@ public class MultipleRegistry extends AbstractRegistry {
public MultipleRegistry(URL url, boolean initServiceRegistry, boolean initReferenceRegistry) {
super(url);
this.registryUrl = url;
this.applicationName = url.getParameter(CommonConstants.APPLICATION_KEY);
this.applicationName = url.getApplication();
init();
checkApplicationName(this.applicationName);
// This urls contain parameter and it donot inherit from the parameter of url in MultipleRegistry

View File

@ -45,7 +45,7 @@ public class MultipleServiceDiscovery implements ServiceDiscovery {
@Override
public void initialize(URL registryURL) throws Exception {
this.registryURL = registryURL;
this.applicationName = registryURL.getParameter(CommonConstants.APPLICATION_KEY);
this.applicationName = registryURL.getApplication();
Map<String, String> parameters = registryURL.getParameters();
for (String key : parameters.keySet()) {

View File

@ -30,9 +30,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
/**
* AccessLogData is a container for log event data. In internally uses map and store each filed of log as value. It
* does not generate any dynamic value e.g. time stamp, local jmv machine host address etc. It does not allow any null
@ -271,8 +268,8 @@ public final class AccessLogData {
public void buildAccessLogData(Invoker<?> invoker, Invocation inv) {
setServiceName(invoker.getInterface().getName());
setMethodName(inv.getMethodName());
setVersion(invoker.getUrl().getParameter(VERSION_KEY));
setGroup(invoker.getUrl().getParameter(GROUP_KEY));
setVersion(invoker.getUrl().getVersion());
setGroup(invoker.getUrl().getGroup());
setInvocationTime(new Date());
setTypes(inv.getParameterTypes());
setArguments(inv.getArguments());