This is an automated email from the ASF dual-hosted git repository.

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/cloud-native by this push:
     new 2a30b22  fix review issue and refactor metadata
2a30b22 is described below

commit 2a30b22c9c0987a355358725e431f5c7b4ed8d8a
Author: cvictory <shenglic...@gmail.com>
AuthorDate: Wed Aug 14 18:27:16 2019 +0800

    fix review issue and refactor metadata
---
 .../org/apache/dubbo/bootstrap/DubboBootstrap.java |  3 +-
 .../bootstrap/DubboServiceConsumerBootstrap.java   |  6 ++
 .../bootstrap/DubboServiceProviderBootstrap.java   | 10 ++-
 .../org/apache/dubbo/common/lang/Prioritized.java  |  6 +-
 .../identifier/ServiceMetadataIdentifier.java      |  4 +-
 .../report/support/AbstractMetadataReport.java     |  2 +-
 .../store/InMemoryWritableMetadataService.java     |  2 +-
 .../store/RemoteWritableMetadataService.java       |  2 +
 .../RemoteWritableMetadataServiceDelegate.java     | 95 ++++++++++++++++++++++
 ...g.apache.dubbo.metadata.WritableMetadataService |  2 +-
 ...ExportedServicesRevisionMetadataCustomizer.java |  4 +-
 ...MetadataServiceURLParamsMetadataCustomizer.java |  4 +-
 .../metadata/RefreshServiceMetadataCustomizer.java |  2 +-
 ...bscribedServicesRevisionMetadataCustomizer.java |  5 +-
 .../proxy/BaseMetadataServiceProxyFactory.java     |  2 +-
 .../metadata/proxy/RemoteMetadataServiceProxy.java |  6 +-
 .../zookeeper/curator/CuratorZookeeperClient.java  |  2 +-
 17 files changed, 136 insertions(+), 21 deletions(-)

diff --git 
a/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java 
b/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java
index 8a4cc22..db5963a 100644
--- 
a/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java
+++ 
b/dubbo-bootstrap/src/main/java/org/apache/dubbo/bootstrap/DubboBootstrap.java
@@ -81,6 +81,7 @@ import static 
org.apache.dubbo.common.constants.CommonConstants.METADATA_KEY;
 import static 
org.apache.dubbo.common.constants.CommonConstants.METADATA_REMOTE;
 import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;
 import static org.apache.dubbo.config.context.ConfigManager.getInstance;
+import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.MEATADATA_STORED_TYPE_KEY;
 import static org.apache.dubbo.remoting.Constants.CLIENT_KEY;
 
 /**
@@ -792,7 +793,7 @@ public class DubboBootstrap implements Lifecycle {
 
     private ServiceInstance initServiceInstance(String serviceName, String 
host, int port, String metadataType) {
         this.serviceInstance = new DefaultServiceInstance(serviceName, host, 
port);
-        this.serviceInstance.getMetadata().put(METADATA_KEY, metadataType);
+        this.serviceInstance.getMetadata().put(MEATADATA_STORED_TYPE_KEY, 
metadataType);
         return this.serviceInstance;
     }
 
diff --git 
a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
 
b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
index fe216ab..cc0e16b 100644
--- 
a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
+++ 
b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceConsumerBootstrap.java
@@ -17,10 +17,16 @@
 package org.apache.dubbo.bootstrap;
 
 import org.apache.dubbo.bootstrap.rest.UserService;
+import org.apache.dubbo.config.ApplicationConfig;
 import org.apache.dubbo.config.MetadataReportConfig;
 import org.apache.dubbo.config.ReferenceConfig;
 import org.apache.dubbo.config.context.ConfigManager;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.dubbo.common.constants.CommonConstants.METADATA_KEY;
+
 /**
  * Dubbo Provider Bootstrap
  *
diff --git 
a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
 
b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
index 9bafe00..d0b7e4a 100644
--- 
a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
+++ 
b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
@@ -18,12 +18,17 @@ package org.apache.dubbo.bootstrap;
 
 import org.apache.dubbo.bootstrap.rest.UserService;
 import org.apache.dubbo.bootstrap.rest.UserServiceImpl;
+import org.apache.dubbo.config.ApplicationConfig;
 import org.apache.dubbo.config.MetadataReportConfig;
 import org.apache.dubbo.config.ProtocolConfig;
 import org.apache.dubbo.config.RegistryConfig;
 import org.apache.dubbo.config.ServiceConfig;
 
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.dubbo.common.constants.CommonConstants.METADATA_KEY;
 
 /**
  * Dubbo Provider Bootstrap
@@ -61,9 +66,10 @@ public class DubboServiceProviderBootstrap {
         userService.setProtocol(restProtocol);
 //        userService.setRegistries(Arrays.asList(interfaceRegistry, 
serviceRegistry));
 
-
+        ApplicationConfig applicationConfig = new 
ApplicationConfig("dubbo-provider-demo");
+        applicationConfig.setMetadata("remote");
         new DubboBootstrap()
-                .application("dubbo-provider-demo")
+                .application(applicationConfig)
                 // Zookeeper in service registry type
 //                .registry("zookeeper", builder -> 
builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
                 // Nacos
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/lang/Prioritized.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/lang/Prioritized.java
index b25ff48..98bf3f8 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/lang/Prioritized.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/lang/Prioritized.java
@@ -54,6 +54,10 @@ public interface Prioritized extends Comparable<Prioritized> 
{
      * The minimum priority
      */
     int MIN_PRIORITY = Integer.MAX_VALUE;
+    /**
+     * Normal Priority
+     */
+    int NORMAL_PRIORITY = 0;
 
     /**
      * Get the priority
@@ -61,7 +65,7 @@ public interface Prioritized extends Comparable<Prioritized> {
      * @return the default is {@link #MIN_PRIORITY minimum one}
      */
     default int getPriority() {
-        return MIN_PRIORITY;
+        return NORMAL_PRIORITY;
     }
 
     @Override
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
index a04492a..65c7b4e 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/ServiceMetadataIdentifier.java
@@ -22,12 +22,13 @@ public class ServiceMetadataIdentifier extends 
BaseServiceMetadataIdentifier {
     public ServiceMetadataIdentifier() {
     }
 
-    public ServiceMetadataIdentifier(String serviceInterface, String version, 
String group, String side, String revision) {
+    public ServiceMetadataIdentifier(String serviceInterface, String version, 
String group, String side, String revision, String protocol) {
         this.serviceInterface = serviceInterface;
         this.version = version;
         this.group = group;
         this.side = side;
         this.revision = revision;
+        this.protocol = protocol;
     }
 
 
@@ -36,7 +37,6 @@ public class ServiceMetadataIdentifier extends 
BaseServiceMetadataIdentifier {
         this.version = url.getParameter(VERSION_KEY);
         this.group = url.getParameter(GROUP_KEY);
         this.side = url.getParameter(SIDE_KEY);
-        this.revision = (url.getParameter(REVISION_KEY));
         this.protocol = url.getProtocol();
     }
 
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
index f70e13e..7f46eef 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
@@ -296,7 +296,7 @@ public abstract class AbstractMetadataReport implements 
MetadataReport {
         if (syncReport) {
             doSaveMetadata(metadataIdentifier, url);
         } else {
-            reportCacheExecutor.execute(() -> doSaveMetadata(new 
ServiceMetadataIdentifier(url), url));
+            reportCacheExecutor.execute(() -> 
doSaveMetadata(metadataIdentifier, url));
         }
     }
 
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/InMemoryWritableMetadataService.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/InMemoryWritableMetadataService.java
index ce8fea5..7c34e67 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/InMemoryWritableMetadataService.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/InMemoryWritableMetadataService.java
@@ -58,7 +58,7 @@ public class InMemoryWritableMetadataService extends 
BaseWritableMetadataService
 
     @Override
     public SortedSet<String> getSubscribedURLs() {
-        return getAllUnmodifiableServiceURLs(subscribedServiceURLs);
+        return super.getSubscribedURLs();
     }
 
     @Override
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataService.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataService.java
index a2aa24f..90181ee 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataService.java
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataService.java
@@ -129,6 +129,7 @@ public class RemoteWritableMetadataService extends 
BaseWritableMetadataService i
     public boolean unexportURL(URL url) {
         ServiceMetadataIdentifier metadataIdentifier = new 
ServiceMetadataIdentifier(url);
         metadataIdentifier.setRevision(exportedRevision);
+        metadataIdentifier.setProtocol(url.getProtocol());
         return throwableAction(getMetadataReport()::removeServiceMetadata, 
metadataIdentifier);
     }
 
@@ -174,6 +175,7 @@ public class RemoteWritableMetadataService extends 
BaseWritableMetadataService i
                 // refresh revision in urls
                 ServiceMetadataIdentifier metadataIdentifier = new 
ServiceMetadataIdentifier(url);
                 metadataIdentifier.setRevision(exportedRevision);
+                metadataIdentifier.setProtocol(url.getProtocol());
 
                 boolean tmpResult = 
throwableAction(getMetadataReport()::saveServiceMetadata, metadataIdentifier, 
url);
                 if (!tmpResult) result = tmpResult;
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceDelegate.java
 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceDelegate.java
new file mode 100644
index 0000000..3885429
--- /dev/null
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceDelegate.java
@@ -0,0 +1,95 @@
+package org.apache.dubbo.metadata.store;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.metadata.WritableMetadataService;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.function.BiFunction;
+
+/**
+ * 2019-08-14
+ *
+ * @since 2.7.5
+ */
+public class RemoteWritableMetadataServiceDelegate implements 
WritableMetadataService {
+    List<WritableMetadataService> metadataServiceList = new ArrayList<>(2);
+
+    public RemoteWritableMetadataServiceDelegate() {
+        metadataServiceList.add(WritableMetadataService.getDefaultExtension());
+        metadataServiceList.add(new RemoteWritableMetadataService());
+    }
+
+    private WritableMetadataService getInMemoryWritableMetadataService() {
+        for (WritableMetadataService writableMetadataService : 
metadataServiceList) {
+            if (writableMetadataService instanceof 
InMemoryWritableMetadataService) {
+                return writableMetadataService;
+            }
+        }
+        return metadataServiceList.get(0);
+    }
+
+    @Override
+    public boolean exportURL(URL url) {
+        return doFunction(WritableMetadataService::exportURL, url);
+    }
+
+    @Override
+    public boolean unexportURL(URL url) {
+        return doFunction(WritableMetadataService::unexportURL, url);
+    }
+
+    @Override
+    public boolean subscribeURL(URL url) {
+        return doFunction(WritableMetadataService::subscribeURL, url);
+    }
+
+    @Override
+    public boolean unsubscribeURL(URL url) {
+        return doFunction(WritableMetadataService::unsubscribeURL, url);
+    }
+
+    @Override
+    public boolean refreshMetadata(String exportedRevision, String 
subscribedRevision) {
+        boolean result = true;
+        for (WritableMetadataService writableMetadataService : 
metadataServiceList) {
+            result &= 
writableMetadataService.refreshMetadata(exportedRevision, subscribedRevision);
+        }
+        return result;
+    }
+
+    @Override
+    public void publishServiceDefinition(URL providerUrl) {
+        for (WritableMetadataService writableMetadataService : 
metadataServiceList) {
+            writableMetadataService.publishServiceDefinition(providerUrl);
+        }
+    }
+
+    @Override
+    public SortedSet<String> getExportedURLs(String serviceInterface, String 
group, String version, String protocol) {
+        return 
getInMemoryWritableMetadataService().getExportedURLs(serviceInterface, group, 
version, protocol);
+    }
+    @Override
+    public SortedSet<String> getSubscribedURLs() {
+        return getInMemoryWritableMetadataService().getSubscribedURLs();
+    }
+
+    @Override
+    public String getServiceDefinition(String interfaceName, String version, 
String group) {
+        return 
getInMemoryWritableMetadataService().getServiceDefinition(interfaceName, 
version, group);
+    }
+
+    @Override
+    public String getServiceDefinition(String serviceKey) {
+        return 
getInMemoryWritableMetadataService().getServiceDefinition(serviceKey);
+    }
+
+    private boolean doFunction(BiFunction<WritableMetadataService, URL, 
Boolean> func, URL url) {
+        boolean result = true;
+        for (WritableMetadataService writableMetadataService : 
metadataServiceList) {
+            result &= func.apply(writableMetadataService, url);
+        }
+        return result;
+    }
+}
diff --git 
a/dubbo-metadata/dubbo-metadata-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.WritableMetadataService
 
b/dubbo-metadata/dubbo-metadata-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.WritableMetadataService
index cbf9324..bf1b63c 100644
--- 
a/dubbo-metadata/dubbo-metadata-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.WritableMetadataService
+++ 
b/dubbo-metadata/dubbo-metadata-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.WritableMetadataService
@@ -1,2 +1,2 @@
 default=org.apache.dubbo.metadata.store.InMemoryWritableMetadataService
-remote=org.apache.dubbo.metadata.store.RemoteWritableMetadataService
\ No newline at end of file
+remote=org.apache.dubbo.metadata.store.RemoteWritableMetadataServiceDelegate
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java
index 4887457..31dac6b 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ExportedServicesRevisionMetadataCustomizer.java
@@ -29,8 +29,8 @@ import java.util.SortedSet;
 
 import static java.lang.String.valueOf;
 import static java.util.Objects.hash;
-import static org.apache.dubbo.common.constants.CommonConstants.METADATA_KEY;
 import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.EXPORTED_SERVICES_REVISION_KEY;
+import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.MEATADATA_STORED_TYPE_KEY;
 
 /**
  * The customizer to a add the metadata that the reversion of Dubbo exported 
services calculates.
@@ -49,7 +49,7 @@ public class ExportedServicesRevisionMetadataCustomizer 
extends ServiceInstanceM
     @Override
     protected String buildMetadataValue(ServiceInstance serviceInstance) {
         WritableMetadataService writableMetadataService = 
WritableMetadataService.getExtension(
-                serviceInstance.getMetadata().get(METADATA_KEY)
+                serviceInstance.getMetadata().get(MEATADATA_STORED_TYPE_KEY)
         );
         SortedSet<String> exportedURLs = 
writableMetadataService.getExportedURLs();
         Object[] data = exportedURLs.stream()
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java
index cf5cc51..b1baa65 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceURLParamsMetadataCustomizer.java
@@ -24,8 +24,8 @@ import 
org.apache.dubbo.registry.client.ServiceInstanceMetadataCustomizer;
 
 import java.util.SortedSet;
 
-import static org.apache.dubbo.common.constants.CommonConstants.METADATA_KEY;
 import static org.apache.dubbo.metadata.MetadataService.toURLs;
+import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.MEATADATA_STORED_TYPE_KEY;
 import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.METADATA_SERVICE_URL_PARAMS_KEY;
 import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getMetadataServiceParameter;
 
@@ -47,7 +47,7 @@ public class MetadataServiceURLParamsMetadataCustomizer 
extends ServiceInstanceM
     public String buildMetadataValue(ServiceInstance serviceInstance) {
 
         WritableMetadataService writableMetadataService = 
WritableMetadataService.getExtension(
-                serviceInstance.getMetadata().get(METADATA_KEY)
+                serviceInstance.getMetadata().get(MEATADATA_STORED_TYPE_KEY)
         );
 
         String serviceInterface = MetadataService.class.getName();
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/RefreshServiceMetadataCustomizer.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/RefreshServiceMetadataCustomizer.java
index 5681b98..5fd089e 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/RefreshServiceMetadataCustomizer.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/RefreshServiceMetadataCustomizer.java
@@ -20,7 +20,7 @@ import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataU
 public class RefreshServiceMetadataCustomizer implements 
ServiceInstanceCustomizer {
 
     public int getPriority() {
-        return MAX_PRIORITY;
+        return MIN_PRIORITY;
     }
 
     @Override
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SubscribedServicesRevisionMetadataCustomizer.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SubscribedServicesRevisionMetadataCustomizer.java
index 7197e10..ca89b26 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SubscribedServicesRevisionMetadataCustomizer.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/SubscribedServicesRevisionMetadataCustomizer.java
@@ -29,8 +29,7 @@ import java.util.SortedSet;
 
 import static java.lang.String.valueOf;
 import static java.util.Objects.hash;
-import static org.apache.dubbo.common.constants.CommonConstants.METADATA_KEY;
-import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.EXPORTED_SERVICES_REVISION_KEY;
+import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.MEATADATA_STORED_TYPE_KEY;
 import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.SUBSCRIBER_SERVICES_REVISION_KEY;
 
 /**
@@ -50,7 +49,7 @@ public class SubscribedServicesRevisionMetadataCustomizer 
extends ServiceInstanc
     @Override
     protected String buildMetadataValue(ServiceInstance serviceInstance) {
         WritableMetadataService writableMetadataService = 
WritableMetadataService.getExtension(
-                serviceInstance.getMetadata().get(METADATA_KEY)
+                serviceInstance.getMetadata().get(MEATADATA_STORED_TYPE_KEY)
         );
         SortedSet<String> subscribedURLs = 
writableMetadataService.getSubscribedURLs();
         Object[] data = subscribedURLs.stream()
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/BaseMetadataServiceProxyFactory.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/BaseMetadataServiceProxyFactory.java
index b56e99b..14405bf 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/BaseMetadataServiceProxyFactory.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/BaseMetadataServiceProxyFactory.java
@@ -17,7 +17,7 @@ abstract class BaseMetadataServiceProxyFactory implements 
MetadataServiceProxyFa
 
     public final MetadataService getProxy(ServiceInstance serviceInstance) {
         return proxies.computeIfAbsent(serviceInstance.getServiceName() + "##" 
+
-                
serviceInstance.getMetadata().getOrDefault(ServiceInstanceMetadataUtils.EXPORTED_SERVICES_REVISION_KEY,
 ""), id -> createProxy(serviceInstance));
+                
ServiceInstanceMetadataUtils.getExportedServicesRevision(serviceInstance), id 
-> createProxy(serviceInstance));
     }
 
     protected abstract MetadataService createProxy(ServiceInstance 
serviceInstance);
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/RemoteMetadataServiceProxy.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/RemoteMetadataServiceProxy.java
index a67368b..44c7144 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/RemoteMetadataServiceProxy.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/proxy/RemoteMetadataServiceProxy.java
@@ -34,7 +34,8 @@ public class RemoteMetadataServiceProxy implements 
MetadataService {
 
     public RemoteMetadataServiceProxy(ServiceInstance serviceInstance) {
         this.serviceName = serviceInstance.getServiceName();
-        this.revision = 
serviceInstance.getMetadata().getOrDefault(ServiceInstanceMetadataUtils.EXPORTED_SERVICES_REVISION_KEY,
 "");
+        this.revision = serviceInstance.getMetadata()
+                
.getOrDefault(ServiceInstanceMetadataUtils.EXPORTED_SERVICES_REVISION_KEY, "");
     }
 
     @Override
@@ -45,7 +46,8 @@ public class RemoteMetadataServiceProxy implements 
MetadataService {
     // TODO, protocol should be used
     @Override
     public SortedSet<String> getExportedURLs(String serviceInterface, String 
group, String version, String protocol) {
-        return toSortedStrings(getMetadataReport().getExportedURLs(new 
ServiceMetadataIdentifier(serviceInterface, group, version, PROVIDER_SIDE, 
revision)));
+        return toSortedStrings(getMetadataReport().getExportedURLs(
+                new ServiceMetadataIdentifier(serviceInterface, group, 
version, PROVIDER_SIDE, revision, protocol)));
     }
 
     private static SortedSet<String> toSortedStrings(Collection<String> 
values) {
diff --git 
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
 
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
index 75aa256..2df67de 100644
--- 
a/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
+++ 
b/dubbo-remoting/dubbo-remoting-zookeeper/src/main/java/org/apache/dubbo/remoting/zookeeper/curator/CuratorZookeeperClient.java
@@ -149,7 +149,7 @@ public class CuratorZookeeperClient extends 
AbstractZookeeperClient<CuratorZooke
     @Override
     public void delete(String path) {
         try {
-            client.delete().forPath(path);
+            client.delete().deletingChildrenIfNeeded().forPath(path);
         } catch (NoNodeException e) {
         } catch (Exception e) {
             throw new IllegalStateException(e.getMessage(), e);

Reply via email to