Skip to content

Commit

Permalink
Polish apache#6315 : Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Jun 12, 2020
1 parent 2c92015 commit 2fbc068
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void main(String[] args) throws Exception {

DubboBootstrap bootstrap = DubboBootstrap.getInstance()
.application("consul-dubbo-consumer", app -> app.metadata(REMOTE_METADATA_STORAGE_TYPE))
.registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:8500?registry-type=service&subscribed-services=consul-dubbo-provider").useAsMetadataCenter(true))
.registry("zookeeper", builder -> builder.address("consul://127.0.0.1:8500?registry-type=service&subscribed-services=consul-dubbo-provider").useAsMetadataCenter(true))
.reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
.reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

import static org.apache.dubbo.common.config.configcenter.DynamicConfigurationFactory.getDynamicConfigurationFactory;
import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
import static org.apache.dubbo.metadata.MetadataConstants.DEFAULT_PATH_TAG;
import static org.apache.dubbo.metadata.MetadataConstants.EXPORTED_URLS_TAG;

/**
Expand All @@ -47,15 +45,12 @@ public class ConfigCenterBasedMetadataReport extends AbstractMetadataReport {

private final String group;

private final long timeout;

private final DynamicConfiguration dynamicConfiguration;

public ConfigCenterBasedMetadataReport(URL reportServerURL, KeyTypeEnum keyTypeEnum) {
super(reportServerURL);
this.keyType = keyTypeEnum;
this.group = reportServerURL.getParameter(GROUP_KEY, DEFAULT_ROOT);
this.timeout = reportServerURL.getParameter(TIMEOUT_KEY, 1L);
String extensionName = reportServerURL.getProtocol();
DynamicConfigurationFactory dynamicConfigurationFactory = getDynamicConfigurationFactory(extensionName);
dynamicConfiguration = dynamicConfigurationFactory.getDynamicConfiguration(reportServerURL);
Expand Down Expand Up @@ -105,17 +100,17 @@ public String getServiceDefinition(MetadataIdentifier metadataIdentifier) {
@Override
public boolean saveExportedURLs(String serviceName, String exportedServicesRevision, String exportedURLsContent) {
String key = buildExportedURLsMetadataKey(serviceName, exportedServicesRevision);
return dynamicConfiguration.publishConfig(key, exportedURLsContent);
return dynamicConfiguration.publishConfig(key, group, exportedURLsContent);
}

@Override
public String getExportedURLsContent(String serviceName, String exportedServicesRevision) {
String key = buildExportedURLsMetadataKey(serviceName, exportedServicesRevision);
return dynamicConfiguration.getConfig(key, group, timeout);
return dynamicConfiguration.getConfig(key, group);
}

private String buildExportedURLsMetadataKey(String serviceName, String exportedServicesRevision) {
return keyType.build(DEFAULT_PATH_TAG, EXPORTED_URLS_TAG, serviceName, exportedServicesRevision);
return keyType.build(EXPORTED_URLS_TAG, serviceName, exportedServicesRevision);
}

protected void saveMetadata(BaseMetadataIdentifier metadataIdentifier, String value) {
Expand All @@ -130,12 +125,12 @@ protected void saveMetadata(MetadataIdentifier metadataIdentifier, String value)

protected String getMetadata(MetadataIdentifier metadataIdentifier) {
String key = getKey(metadataIdentifier);
return dynamicConfiguration.getConfig(key, group, timeout);
return dynamicConfiguration.getConfig(key, group);
}

protected String getMetadata(SubscriberMetadataIdentifier metadataIdentifier) {
String key = getKey(metadataIdentifier);
return dynamicConfiguration.getConfig(key, group, timeout);
return dynamicConfiguration.getConfig(key, group);
}

protected void removeMetadata(MetadataIdentifier metadataIdentifier) {
Expand Down

0 comments on commit 2fbc068

Please sign in to comment.