You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2020/08/04 07:09:41 UTC

[dubbo] 04/27: metadata read & write

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

liujun pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit c682389634fed5f6b13bb6de0ab88e5757a7fe44
Author: ken.lj <ke...@gmail.com>
AuthorDate: Mon Jun 15 13:41:07 2020 +0800

    metadata read & write
---
 .../dubbo/config/bootstrap/DubboBootstrap.java     |   4 +-
 .../metadata/DefaultMetadataParamsFilter.java      |   3 +
 .../org/apache/dubbo/metadata/MetadataInfo.java    |  47 +++--
 .../apache/dubbo/metadata/RevisionResolver.java    |   2 +
 .../dubbo/metadata/WritableMetadataService.java    |   6 +-
 .../org/apache/dubbo/metadata/DemoService.java     |  30 ++-
 .../apache/dubbo/metadata/MetadataInfoTest.java    |  27 ++-
 .../dubbo/metadata/URLRevisionResolverTest.java    |  50 -----
 .../store/InMemoryWritableMetadataServiceTest.java | 111 -----------
 .../RemoteWritableMetadataServiceDelegateTest.java | 216 ---------------------
 .../store/RemoteWritableMetadataServiceTest.java   | 188 ------------------
 .../registry/client/ServiceDiscoveryRegistry.java  |   3 +-
 ...MetadataServiceURLParamsMetadataCustomizer.java |   8 +-
 .../registry/client/metadata/MetadataUtils.java    |  16 +-
 .../metadata/ProtocolPortsMetadataCustomizer.java  |   7 +-
 .../metadata/store/RemoteMetadataServiceImpl.java  |  10 +-
 ...g.apache.dubbo.metadata.WritableMetadataService |   1 +
 ...ient.metadata.proxy.MetadataServiceProxyFactory |   3 -
 .../registry/nacos/NacosServiceDiscovery.java      |   3 +-
 19 files changed, 84 insertions(+), 651 deletions(-)

diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/bootstrap/DubboBootstrap.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/bootstrap/DubboBootstrap.java
index 3bdffa9..dd28b81 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/bootstrap/DubboBootstrap.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/bootstrap/DubboBootstrap.java
@@ -97,7 +97,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_METADATA
 import static org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
 import static org.apache.dubbo.common.function.ThrowableAction.execute;
 import static org.apache.dubbo.common.utils.StringUtils.isNotEmpty;
-import static org.apache.dubbo.metadata.WritableMetadataService.getExtension;
+import static org.apache.dubbo.metadata.WritableMetadataService.getDefaultExtension;
 import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.setMetadataStorageType;
 import static org.apache.dubbo.remoting.Constants.CLIENT_KEY;
 
@@ -718,7 +718,7 @@ public class DubboBootstrap extends GenericEventListener {
      */
     private void initMetadataService() {
         startMetadataReport();
-        this.metadataService = getExtension(getMetadataType());
+        this.metadataService = getDefaultExtension();
         this.metadataServiceExporter = new ConfigurableMetadataServiceExporter(metadataService);
     }
 
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/DefaultMetadataParamsFilter.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/DefaultMetadataParamsFilter.java
index 7f4b85c..0563e43 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/DefaultMetadataParamsFilter.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/DefaultMetadataParamsFilter.java
@@ -16,6 +16,8 @@
  */
 package org.apache.dubbo.metadata;
 
+import org.apache.dubbo.common.extension.Activate;
+
 import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.DUBBO_VERSION_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
@@ -35,6 +37,7 @@ import static org.apache.dubbo.rpc.Constants.TOKEN_KEY;
 import static org.apache.dubbo.rpc.cluster.Constants.WARMUP_KEY;
 import static org.apache.dubbo.rpc.cluster.Constants.WEIGHT_KEY;
 
+@Activate
 public class DefaultMetadataParamsFilter implements MetadataParamsFilter {
     @Override
     public String[] include() {
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataInfo.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataInfo.java
index bf9aa68..01e3c09 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataInfo.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataInfo.java
@@ -17,15 +17,19 @@
 package org.apache.dubbo.metadata;
 
 import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.compiler.support.ClassUtils;
 import org.apache.dubbo.common.extension.ExtensionLoader;
 import org.apache.dubbo.common.utils.ArrayUtils;
 import org.apache.dubbo.common.utils.StringUtils;
 
 import java.io.Serializable;
+import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import static org.apache.dubbo.common.constants.CommonConstants.DOT_SEPARATOR;
 import static org.apache.dubbo.common.constants.CommonConstants.GROUP_CHAR_SEPERATOR;
@@ -39,6 +43,7 @@ public class MetadataInfo implements Serializable {
     private Map<String, ServiceInfo> services;
 
     public MetadataInfo() {
+        this.services = new HashMap<>();
     }
 
     public MetadataInfo(String app, String revision, Map<String, ServiceInfo> services) {
@@ -68,15 +73,6 @@ public class MetadataInfo implements Serializable {
         this.services.remove(key);
     }
 
-    public String revision() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(app);
-        for (Map.Entry<String, ServiceInfo> entry : services.entrySet()) {
-            sb.append(entry.getValue().toString());
-        }
-        return RevisionResolver.calRevision(sb.toString());
-    }
-
     public String getApp() {
         return app;
     }
@@ -86,6 +82,15 @@ public class MetadataInfo implements Serializable {
     }
 
     public String getRevision() {
+        if (revision != null) {
+            return revision;
+        }
+        StringBuilder sb = new StringBuilder();
+        sb.append(app);
+        for (Map.Entry<String, ServiceInfo> entry : services.entrySet()) {
+            sb.append(entry.getValue().toDescString());
+        }
+        this.revision = RevisionResolver.calRevision(sb.toString());
         return revision;
     }
 
@@ -159,10 +164,12 @@ public class MetadataInfo implements Serializable {
                             params.put(p, value);
                         }
                         String[] methods = url.getParameter(METHODS_KEY, (String[]) null);
-                        for (String method : methods) {
-                            String mValue = url.getMethodParameter(method, p);
-                            if (StringUtils.isNotEmpty(mValue)) {
-                                params.put(method + DOT_SEPARATOR + p, mValue);
+                        if (methods != null) {
+                            for (String method : methods) {
+                                String mValue = url.getMethodParameter(method, p);
+                                if (StringUtils.isNotEmpty(mValue)) {
+                                    params.put(method + DOT_SEPARATOR + p, mValue);
+                                }
                             }
                         }
                     }
@@ -277,5 +284,19 @@ public class MetadataInfo implements Serializable {
             }
             return value == null ? defaultValue : value;
         }
+
+        public String toDescString() {
+            return this.getMatchKey() + getMethodSignaturesString() + getParams();
+        }
+
+        private String getMethodSignaturesString() {
+            SortedSet<String> methodStrings = new TreeSet();
+
+            Method[] methods = ClassUtils.forName(name).getMethods();
+            for (Method method : methods) {
+                methodStrings.add(method.toString());
+            }
+            return methodStrings.toString();
+        }
     }
 }
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/RevisionResolver.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/RevisionResolver.java
index 76d8cfb..f8ebd3b 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/RevisionResolver.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/RevisionResolver.java
@@ -54,4 +54,6 @@ public class RevisionResolver {
         }
         return new String(str);
     }
+
+
 }
diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java
index b453842..0de9683 100644
--- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/WritableMetadataService.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.metadata;
 
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.extension.SPI;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 
 import static org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoader;
@@ -28,6 +29,7 @@ import static org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoad
  *
  * @since 2.7.5
  */
+@SPI("default")
 public interface WritableMetadataService extends MetadataService {
     /**
      * Gets the current Dubbo Service name
@@ -81,8 +83,4 @@ public interface WritableMetadataService extends MetadataService {
     static WritableMetadataService getDefaultExtension() {
         return getExtensionLoader(WritableMetadataService.class).getDefaultExtension();
     }
-
-    static WritableMetadataService getExtension(String name) {
-        return getExtensionLoader(WritableMetadataService.class).getOrDefaultExtension(name);
-    }
 }
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/DemoService.java
similarity index 53%
copy from dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java
copy to dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/DemoService.java
index bf8d9d2..33bcbc7 100644
--- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/DemoService.java
@@ -14,26 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.dubbo.registry.client.event.listener;
+package org.apache.dubbo.metadata;
 
-import org.apache.dubbo.registry.client.DefaultServiceInstanceTest;
-import org.apache.dubbo.registry.client.event.ServiceInstancePreRegisteredEvent;
+import org.apache.dubbo.metadata.rest.User;
+
+import java.util.List;
 
-import org.junit.jupiter.api.Test;
 
 /**
- * {@link CustomizableServiceInstanceListener} Test
- *
- * @since 2.7.5
+ * DemoService
  */
-public class CustomizableServiceInstanceListenerTest {
+public interface DemoService {
+
+    String sayName(String name);
+
+    void throwRuntimeException() throws RuntimeException;
+
+    List<User> getUsers(List<User> users);
 
-    private CustomizableServiceInstanceListener listener = new CustomizableServiceInstanceListener();
+    int echo(int i);
 
-    @Test
-    public void testOnEvent() {
-        ServiceInstancePreRegisteredEvent event = new ServiceInstancePreRegisteredEvent(this, DefaultServiceInstanceTest.createInstance());
-        // breaking test
-        listener.onEvent(event);
-    }
-}
+}
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/MetadataInfoTest.java
similarity index 56%
rename from dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java
rename to dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/MetadataInfoTest.java
index bf8d9d2..1d2f42e 100644
--- a/dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/CustomizableServiceInstanceListenerTest.java
+++ b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/MetadataInfoTest.java
@@ -14,26 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.dubbo.registry.client.event.listener;
+package org.apache.dubbo.metadata;
 
-import org.apache.dubbo.registry.client.DefaultServiceInstanceTest;
-import org.apache.dubbo.registry.client.event.ServiceInstancePreRegisteredEvent;
+import org.apache.dubbo.common.URL;
 
 import org.junit.jupiter.api.Test;
 
-/**
- * {@link CustomizableServiceInstanceListener} Test
- *
- * @since 2.7.5
- */
-public class CustomizableServiceInstanceListenerTest {
+public class MetadataInfoTest {
+    @Test
+    public void revisionTest() {
+        MetadataInfo metadataInfo = new MetadataInfo();
+        metadataInfo.setApp("demo");
 
-    private CustomizableServiceInstanceListener listener = new CustomizableServiceInstanceListener();
+        URL url = URL.valueOf("dubbo://10.230.11.211:20880/org.apache.dubbo.metadata.DemoService?timeout=1000&testKey=aaa");
+        MetadataInfo.ServiceInfo serviceInfo = new MetadataInfo.ServiceInfo(url);
+        metadataInfo.addService(serviceInfo);
 
-    @Test
-    public void testOnEvent() {
-        ServiceInstancePreRegisteredEvent event = new ServiceInstancePreRegisteredEvent(this, DefaultServiceInstanceTest.createInstance());
-        // breaking test
-        listener.onEvent(event);
+        System.out.println(serviceInfo.toDescString());
+        System.out.println(metadataInfo.getRevision());
     }
 }
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/URLRevisionResolverTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/URLRevisionResolverTest.java
deleted file mode 100644
index b36ebcb..0000000
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/URLRevisionResolverTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 org.apache.dubbo.metadata;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import static java.util.Arrays.asList;
-import static org.apache.dubbo.metadata.URLRevisionResolver.UNKNOWN_REVISION;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-/**
- * {@link URLRevisionResolver} Test
- *
- * @since 2.7.5
- */
-public class URLRevisionResolverTest {
-
-    private static final String URL = "dubbo://192.168.0.102:20881/org.apache.dubbo.metadata.URLRevisionResolverTest";
-
-    private final URLRevisionResolver resolver = URLRevisionResolver.INSTANCE;
-
-    @Test
-    public void testResolve() {
-        String revision = resolver.resolve(Arrays.<String>asList());
-        assertEquals(UNKNOWN_REVISION, revision);
-
-        revision = resolver.resolve((Collection<String>) null);
-        assertEquals(UNKNOWN_REVISION, revision);
-
-        revision = resolver.resolve(asList(URL));
-        assertEquals("2ca0638f189ce569", revision);
-    }
-}
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/InMemoryWritableMetadataServiceTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/InMemoryWritableMetadataServiceTest.java
deleted file mode 100644
index b7db3fb..0000000
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/InMemoryWritableMetadataServiceTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * 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 org.apache.dubbo.metadata.store;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.utils.NetUtils;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * 2019-08-29
- */
-public class InMemoryWritableMetadataServiceTest {
-
-    String interfaceName = "org.apache.dubbo.metadata.store.InterfaceNameTestService2", version = "0.9.9", group = null;
-    URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/?interface=" + interfaceName + "&version="
-            + version + "&application=vicpubprovder&side=provider");
-
-    @BeforeEach
-    public void before() {
-    }
-
-    @Test
-    public void testPublishServiceDefinition() {
-        InMemoryWritableMetadataService inMemoryWritableMetadataService = new InMemoryWritableMetadataService();
-        inMemoryWritableMetadataService.publishServiceDefinition(url);
-
-        String v = inMemoryWritableMetadataService.getServiceDefinition(interfaceName, version, group);
-        Assertions.assertNotNull(v);
-    }
-
-    @Test
-    public void testExportURL() {
-        InMemoryWritableMetadataService inMemoryWritableMetadataService = new InMemoryWritableMetadataService();
-        URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test567Service?version=1.0.44&application=vicpubprovder&side=provider");
-        inMemoryWritableMetadataService.exportURL(url);
-
-        Assertions.assertTrue(inMemoryWritableMetadataService.getExportedServiceURLs().size() == 1);
-        Assertions.assertEquals(inMemoryWritableMetadataService.getExportedServiceURLs().get(url.getServiceKey()).first(), url);
-    }
-
-    @Test
-    public void testSubscribeURL() {
-        InMemoryWritableMetadataService inMemoryWritableMetadataService = new InMemoryWritableMetadataService();
-        URL url = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test678Service?version=1.0.44&application=vicpubprovder&side=provider");
-        inMemoryWritableMetadataService.subscribeURL(url);
-
-        Assertions.assertTrue(inMemoryWritableMetadataService.getSubscribedServiceURLs().size() == 1);
-        Assertions.assertEquals(inMemoryWritableMetadataService.getSubscribedServiceURLs().get(url.getServiceKey()).first(), url);
-    }
-
-    @Test
-    public void testUnExportURL() {
-        InMemoryWritableMetadataService inMemoryWritableMetadataService = new InMemoryWritableMetadataService();
-        URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test567Service?version=1.0.44&application=vicpubprovder&side=provider");
-        inMemoryWritableMetadataService.exportURL(url);
-
-        Assertions.assertTrue(inMemoryWritableMetadataService.getExportedServiceURLs().size() == 1);
-        Assertions.assertEquals(inMemoryWritableMetadataService.getExportedServiceURLs().get(url.getServiceKey()).first(), url);
-
-        inMemoryWritableMetadataService.unexportURL(url);
-        Assertions.assertTrue(inMemoryWritableMetadataService.getExportedServiceURLs().size() == 0);
-    }
-
-    @Test
-    public void testUnSubscribeURL() {
-        InMemoryWritableMetadataService inMemoryWritableMetadataService = new InMemoryWritableMetadataService();
-        URL url = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test678Service?version=1.0.44&application=vicpubprovder&side=provider");
-        inMemoryWritableMetadataService.subscribeURL(url);
-
-        Assertions.assertTrue(inMemoryWritableMetadataService.getSubscribedServiceURLs().size() == 1);
-        Assertions.assertEquals(inMemoryWritableMetadataService.getSubscribedServiceURLs().get(url.getServiceKey()).first(), url);
-
-        inMemoryWritableMetadataService.unsubscribeURL(url);
-        Assertions.assertTrue(inMemoryWritableMetadataService.getSubscribedServiceURLs().size() == 0);
-    }
-
-}
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceDelegateTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceDelegateTest.java
deleted file mode 100644
index 7c95e31..0000000
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceDelegateTest.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * 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 org.apache.dubbo.metadata.store;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.utils.NetUtils;
-import org.apache.dubbo.metadata.WritableMetadataService;
-import org.apache.dubbo.metadata.report.MetadataReportInstance;
-import org.apache.dubbo.metadata.report.identifier.KeyTypeEnum;
-import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier;
-import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier;
-import org.apache.dubbo.metadata.test.JTestMetadataReport4Test;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.SortedSet;
-
-
-/**
- * 2019-08-27
- */
-public class RemoteWritableMetadataServiceDelegateTest {
-    static URL metadataURL = URL.valueOf("JTest://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Tes33tService?version=1.0.0&application=vic");
-
-    RemoteWritableMetadataServiceDelegate metadataReportService;
-
-    String interfaceName = "org.apache.dubbo.metadata.store.InterfaceNameTestService80", version = "0.6.9", group = null;
-    URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/?interface=" + interfaceName + "&version="
-            + version + "&application=vicpubprovder&side=provider");
-
-    @BeforeAll
-    public static void beforeAll() {
-        MetadataReportInstance.init(metadataURL);
-    }
-
-    @BeforeEach
-    public void before() {
-        metadataReportService = new RemoteWritableMetadataServiceDelegate();
-    }
-
-
-    @Test
-    public void testInstance() {
-        WritableMetadataService metadataReportService1 = WritableMetadataService.getExtension("remote");
-        WritableMetadataService metadataReportService2 = WritableMetadataService.getExtension("remote");
-        Assertions.assertSame(metadataReportService1, metadataReportService2);
-        Assertions.assertTrue(metadataReportService1 instanceof RemoteWritableMetadataServiceDelegate);
-    }
-
-    @Test
-    public void testPublishServiceDefinition() throws InterruptedException {
-        String interfaceName = "org.apache.dubbo.metadata.store.InterfaceNameTestService2", version = "0.9.9", group = null;
-        URL tmpUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/?interface=" + interfaceName + "&version="
-                + version + "&application=vicpubprovder&side=provider");
-        metadataReportService.publishServiceDefinition(tmpUrl);
-        Thread.sleep(150);
-        String v = metadataReportService.getServiceDefinition(interfaceName, version, group);
-        Assertions.assertNotNull(v);
-    }
-
-    @Test
-    public void testExportURL() throws InterruptedException {
-        URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test567Service?version=1.0.44&application=vicpubprovder&side=provider");
-        metadataReportService.exportURL(url);
-        Thread.sleep(100);
-        Assertions.assertTrue(getInMemoryWriableMetadataService().exportedServiceURLs.size() == 1);
-        Assertions.assertEquals(getInMemoryWriableMetadataService().exportedServiceURLs.get(url.getServiceKey()).first(), url);
-    }
-
-    @Test
-    public void testSubscribeURL() throws InterruptedException {
-        URL url = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test0678Service?version=1.3.144&application=vicpubprovder&side=provider");
-        int origSize = getInMemoryWriableMetadataService().subscribedServiceURLs.size();
-        metadataReportService.subscribeURL(url);
-        Thread.sleep(100);
-        int size = getInMemoryWriableMetadataService().subscribedServiceURLs.size();
-        Assertions.assertTrue(size - origSize == 1);
-        Assertions.assertEquals(getInMemoryWriableMetadataService().subscribedServiceURLs.get(url.getServiceKey()).first(), url);
-    }
-
-    @Test
-    public void testUnExportURL() throws InterruptedException {
-        URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test0567Service?version=1.2.44&application=vicpubprovder&side=provider");
-        int origSize = getInMemoryWriableMetadataService().exportedServiceURLs.size();
-        metadataReportService.exportURL(url);
-        Thread.sleep(100);
-        int size = getInMemoryWriableMetadataService().exportedServiceURLs.size();
-        Assertions.assertTrue(size - origSize == 1);
-        Assertions.assertEquals(getInMemoryWriableMetadataService().exportedServiceURLs.get(url.getServiceKey()).first(), url);
-
-        metadataReportService.unexportURL(url);
-        int unexportSize = getInMemoryWriableMetadataService().exportedServiceURLs.size();
-        Assertions.assertTrue(size - unexportSize == 1);
-    }
-
-    @Test
-    public void testUnSubscribeURL() throws InterruptedException {
-        URL url = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.Test0678Service?version=1.5.477&application=vicpubprovder&side=provider");
-        int origSize = getInMemoryWriableMetadataService().subscribedServiceURLs.size();
-        metadataReportService.subscribeURL(url);
-        Thread.sleep(100);
-        int size = getInMemoryWriableMetadataService().subscribedServiceURLs.size();
-        Assertions.assertTrue(size - origSize == 1);
-        Assertions.assertEquals(getInMemoryWriableMetadataService().subscribedServiceURLs.get(url.getServiceKey()).first(), url);
-
-        metadataReportService.unsubscribeURL(url);
-        Thread.sleep(100);
-        Assertions.assertTrue(getInMemoryWriableMetadataService().subscribedServiceURLs.size() == 0);
-    }
-
-    @Test
-    public void testRefreshMetadataService() throws InterruptedException {
-        URL publishUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadataService?version=1.6.8&application=vicpubprovder&side=provider");
-        URL publishUrl2 = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadata2Service?version=1.6.5&application=vicpubprovder&side=provider");
-        metadataReportService.exportURL(publishUrl);
-        metadataReportService.exportURL(publishUrl2);
-        String exportedRevision = "9999";
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) MetadataReportInstance.getMetadataReports(true);
-        int origSize = jTestMetadataReport4Test.store.size();
-        int num = countNum();
-        Assertions.assertTrue(metadataReportService.refreshMetadata(exportedRevision, "1109"));
-        Thread.sleep(200);
-        int size = jTestMetadataReport4Test.store.size();
-        Assertions.assertTrue(size - origSize == num);
-        Assertions.assertEquals(jTestMetadataReport4Test.store.get(getServiceMetadataIdentifier(publishUrl, exportedRevision).getUniqueKey(KeyTypeEnum.UNIQUE_KEY)), publishUrl.toFullString());
-        Assertions.assertEquals(jTestMetadataReport4Test.store.get(getServiceMetadataIdentifier(publishUrl2, exportedRevision).getUniqueKey(KeyTypeEnum.UNIQUE_KEY)), publishUrl2.toFullString());
-    }
-
-
-    // unstable test
-//    @Test
-//    public void testRefreshMetadataSubscription() throws InterruptedException {
-//        URL subscriberUrl1 = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadata00Service?version=2.0.8&application=vicpubprovder&side=provider");
-//        URL subscriberUrl2 = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadata09Service?version=2.0.5&application=vicpubprovder&side=provider");
-//        metadataReportService.subscribeURL(subscriberUrl1);
-//        metadataReportService.subscribeURL(subscriberUrl2);
-//        String exportedRevision = "9999";
-//        String subscriberRevision = "2099";
-//        String applicationName = "wriableMetadataService";
-//        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) MetadataReportInstance.getMetadataReport(true);
-//        int origSize = jTestMetadataReport4Test.store.size();
-//        ApplicationModel.setApplication(applicationName);
-//        Assertions.assertTrue(metadataReportService.refreshMetadata(exportedRevision, subscriberRevision));
-//        Thread.sleep(200);
-//        int size = jTestMetadataReport4Test.store.size();
-//        Assertions.assertTrue(size - origSize == 1);
-//        String r = jTestMetadataReport4Test.store.get(getSubscriberMetadataIdentifier(
-//                subscriberRevision).getUniqueKey(KeyTypeEnum.UNIQUE_KEY));
-//        Assertions.assertNotNull(r);
-//    }
-
-
-    private ServiceMetadataIdentifier getServiceMetadataIdentifier(URL publishUrl, String exportedRevision) {
-        ServiceMetadataIdentifier serviceMetadataIdentifier = new ServiceMetadataIdentifier(publishUrl);
-        serviceMetadataIdentifier.setRevision(exportedRevision);
-        serviceMetadataIdentifier.setProtocol(publishUrl.getProtocol());
-        return serviceMetadataIdentifier;
-    }
-
-    private SubscriberMetadataIdentifier getSubscriberMetadataIdentifier(String subscriberRevision) {
-        SubscriberMetadataIdentifier subscriberMetadataIdentifier = new SubscriberMetadataIdentifier();
-        subscriberMetadataIdentifier.setRevision(subscriberRevision);
-        subscriberMetadataIdentifier.setApplication(ApplicationModel.getApplication());
-        return subscriberMetadataIdentifier;
-    }
-
-    private InMemoryWritableMetadataService getInMemoryWriableMetadataService() {
-        return (InMemoryWritableMetadataService) metadataReportService.defaultWritableMetadataService;
-    }
-
-    private int countNum() {
-        int num = 0;
-        for (SortedSet<URL> tmp : getInMemoryWriableMetadataService().exportedServiceURLs.values()) {
-            num += tmp.size();
-        }
-        if (!getInMemoryWriableMetadataService().subscribedServiceURLs.values().isEmpty()) {
-            num++;
-        }
-        return num;
-    }
-}
diff --git a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceTest.java b/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceTest.java
deleted file mode 100644
index e9ca89f..0000000
--- a/dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/store/RemoteWritableMetadataServiceTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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 org.apache.dubbo.metadata.store;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.utils.NetUtils;
-import org.apache.dubbo.metadata.definition.model.FullServiceDefinition;
-import org.apache.dubbo.metadata.report.MetadataReportInstance;
-import org.apache.dubbo.metadata.report.identifier.KeyTypeEnum;
-import org.apache.dubbo.metadata.report.identifier.ServiceMetadataIdentifier;
-import org.apache.dubbo.metadata.report.identifier.SubscriberMetadataIdentifier;
-import org.apache.dubbo.metadata.test.JTestMetadataReport4Test;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-
-import com.google.gson.Gson;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.Map;
-
-/**
- * 2018/9/14
- */
-public class RemoteWritableMetadataServiceTest {
-    URL url = URL.valueOf("JTest://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vic");
-    RemoteWritableMetadataService metadataReportService1;
-
-    @BeforeEach
-    public void before() {
-        metadataReportService1 = new RemoteWritableMetadataService();
-        MetadataReportInstance.init(url);
-    }
-
-    @Test
-    public void testPublishProviderNoInterfaceName() {
-        URL publishUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vicpubprovder&side=provider");
-        metadataReportService1.publishServiceDefinition(publishUrl);
-
-        Assertions.assertTrue(metadataReportService1.getMetadataReport() instanceof JTestMetadataReport4Test);
-
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.getMetadataReport();
-        Assertions.assertTrue(!jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getProviderKey(publishUrl)));
-
-    }
-
-    @Test
-    public void testPublishProviderWrongInterface() {
-
-        URL publishUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vicpu&interface=ccc&side=provider");
-        metadataReportService1.publishServiceDefinition(publishUrl);
-
-        Assertions.assertTrue(metadataReportService1.getMetadataReport() instanceof JTestMetadataReport4Test);
-
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.getMetadataReport();
-        Assertions.assertTrue(!jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getProviderKey(publishUrl)));
-
-    }
-
-    @Test
-    public void testPublishProviderContainInterface() throws InterruptedException {
-
-        URL publishUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.3&application=vicpubp&interface=org.apache.dubbo.metadata.store.InterfaceNameTestService&side=provider");
-        metadataReportService1.publishServiceDefinition(publishUrl);
-        Thread.sleep(300);
-
-        Assertions.assertTrue(metadataReportService1.getMetadataReport() instanceof JTestMetadataReport4Test);
-
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.getMetadataReport();
-        Assertions.assertTrue(jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getProviderKey(publishUrl)));
-
-        String value = jTestMetadataReport4Test.store.get(JTestMetadataReport4Test.getProviderKey(publishUrl));
-        FullServiceDefinition fullServiceDefinition = toServiceDefinition(value);
-        Map<String, String> map = fullServiceDefinition.getParameters();
-        Assertions.assertEquals(map.get("application"), "vicpubp");
-        Assertions.assertEquals(map.get("version"), "1.0.3");
-        Assertions.assertEquals(map.get("interface"), "org.apache.dubbo.metadata.store.InterfaceNameTestService");
-    }
-
-    @Test
-    public void testPublishConsumer() throws InterruptedException {
-
-        URL publishUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.x&application=vicpubconsumer&side=consumer");
-        metadataReportService1.publishServiceDefinition(publishUrl);
-        Thread.sleep(300);
-
-        Assertions.assertTrue(metadataReportService1.getMetadataReport() instanceof JTestMetadataReport4Test);
-
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.getMetadataReport();
-        Assertions.assertTrue(jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getConsumerKey(publishUrl)));
-
-        String value = jTestMetadataReport4Test.store.get(JTestMetadataReport4Test.getConsumerKey(publishUrl));
-        Gson gson = new Gson();
-        Map<String, String> map = gson.fromJson(value, Map.class);
-        Assertions.assertEquals(map.get("application"), "vicpubconsumer");
-        Assertions.assertEquals(map.get("version"), "1.0.x");
-
-    }
-
-    @Test
-    public void testPublishServiceDefinition() {
-        URL publishUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestService?version=1.0.0&application=vicpubprovder&side=provider");
-        metadataReportService1.publishServiceDefinition(publishUrl);
-
-        Assertions.assertTrue(metadataReportService1.getMetadataReport() instanceof JTestMetadataReport4Test);
-
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.getMetadataReport();
-        Assertions.assertTrue(!jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getProviderKey(publishUrl)));
-
-    }
-
-    @Test
-    public void testUnexportURL() {
-
-    }
-
-    @Test
-    public void testRefreshMetadataService() throws InterruptedException {
-        URL publishUrl = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadataService?version=1.0.8&application=vicpubprovder&side=provider");
-        URL publishUrl2 = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadata2Service?version=1.0.5&application=vicpubprovder&side=provider");
-        metadataReportService1.exportURL(publishUrl);
-        metadataReportService1.exportURL(publishUrl2);
-        String exportedRevision = "9999";
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.getMetadataReport();
-        int origSize = jTestMetadataReport4Test.store.size();
-        Assertions.assertTrue(metadataReportService1.refreshMetadata(exportedRevision, "1109"));
-        Thread.sleep(200);
-        int size = jTestMetadataReport4Test.store.size();
-        Assertions.assertEquals(origSize, size);
-        Assertions.assertNull(jTestMetadataReport4Test.store.get(getServiceMetadataIdentifier(publishUrl, exportedRevision).getUniqueKey(KeyTypeEnum.UNIQUE_KEY)));
-        Assertions.assertNull(jTestMetadataReport4Test.store.get(getServiceMetadataIdentifier(publishUrl2, exportedRevision).getUniqueKey(KeyTypeEnum.UNIQUE_KEY)));
-    }
-
-    @Test
-    public void testRefreshMetadataSubscription() throws InterruptedException {
-        URL subscriberUrl1 = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadata00Service?version=1.0.8&application=vicpubprovder&side=provider");
-        URL subscriberUrl2 = URL.valueOf("subscriber://" + NetUtils.getLocalAddress().getHostName() + ":4444/org.apache.dubbo.TestRefreshMetadata09Service?version=1.0.5&application=vicpubprovder&side=provider");
-        metadataReportService1.subscribeURL(subscriberUrl1);
-        metadataReportService1.subscribeURL(subscriberUrl2);
-        String exportedRevision = "9999";
-        String subscriberRevision = "2099";
-        String applicationName = "wriableMetadataService";
-        JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.getMetadataReport();
-        int origSize = jTestMetadataReport4Test.store.size();
-        ApplicationModel.setApplication(applicationName);
-        Assertions.assertTrue(metadataReportService1.refreshMetadata(exportedRevision, subscriberRevision));
-        Thread.sleep(200);
-        int size = jTestMetadataReport4Test.store.size();
-        Assertions.assertEquals(origSize, size);
-        String r = jTestMetadataReport4Test.store.get(getSubscriberMetadataIdentifier(
-                subscriberRevision).getUniqueKey(KeyTypeEnum.UNIQUE_KEY));
-        Assertions.assertNull(r);
-    }
-
-    private ServiceMetadataIdentifier getServiceMetadataIdentifier(URL publishUrl, String exportedRevision) {
-        ServiceMetadataIdentifier serviceMetadataIdentifier = new ServiceMetadataIdentifier(publishUrl);
-        serviceMetadataIdentifier.setRevision(exportedRevision);
-        serviceMetadataIdentifier.setProtocol(publishUrl.getProtocol());
-        return serviceMetadataIdentifier;
-    }
-
-    private SubscriberMetadataIdentifier getSubscriberMetadataIdentifier(String subscriberRevision) {
-        SubscriberMetadataIdentifier subscriberMetadataIdentifier = new SubscriberMetadataIdentifier();
-        subscriberMetadataIdentifier.setRevision(subscriberRevision);
-        subscriberMetadataIdentifier.setApplication(ApplicationModel.getApplication());
-        return subscriberMetadataIdentifier;
-    }
-
-    private FullServiceDefinition toServiceDefinition(String urlQuery) {
-        Gson gson = new Gson();
-        return gson.fromJson(urlQuery, FullServiceDefinition.class);
-    }
-
-}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
index 2607054..48ceffd 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java
@@ -29,7 +29,6 @@ import org.apache.dubbo.metadata.WritableMetadataService;
 import org.apache.dubbo.registry.NotifyListener;
 import org.apache.dubbo.registry.Registry;
 import org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener;
-import org.apache.dubbo.registry.client.metadata.MetadataUtils;
 import org.apache.dubbo.registry.client.metadata.SubscribedURLsSynthesizer;
 import org.apache.dubbo.registry.support.FailbackRegistry;
 
@@ -132,7 +131,7 @@ public class ServiceDiscoveryRegistry extends FailbackRegistry {
         this.serviceDiscovery = createServiceDiscovery(registryURL);
         this.subscribedServices = parseServices(registryURL.getParameter(SUBSCRIBED_SERVICE_NAMES_KEY));
         this.serviceNameMapping = ServiceNameMapping.getDefaultExtension();
-        this.writableMetadataService = MetadataUtils.getLocalMetadataService();
+        this.writableMetadataService = WritableMetadataService.getDefaultExtension();
     }
 
     public ServiceDiscovery getServiceDiscovery() {
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 5ad373a..be78440 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
@@ -25,10 +25,9 @@ import org.apache.dubbo.registry.client.ServiceInstanceMetadataCustomizer;
 import java.util.SortedSet;
 
 import static org.apache.dubbo.metadata.MetadataService.toURLs;
-import static org.apache.dubbo.metadata.WritableMetadataService.getExtension;
+import static org.apache.dubbo.metadata.WritableMetadataService.getDefaultExtension;
 import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME;
 import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getMetadataServiceParameter;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getMetadataStorageType;
 
 /**
  * An {@link ServiceInstanceMetadataCustomizer} to customize the {@link URL urls} of {@link MetadataService}
@@ -46,10 +45,7 @@ public class MetadataServiceURLParamsMetadataCustomizer extends ServiceInstanceM
 
     @Override
     public String resolveMetadataPropertyValue(ServiceInstance serviceInstance) {
-
-        String metadataStorageType = getMetadataStorageType(serviceInstance);
-
-        WritableMetadataService writableMetadataService = getExtension(metadataStorageType);
+        WritableMetadataService writableMetadataService = getDefaultExtension();
 
         String serviceInterface = MetadataService.class.getName();
 
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java
index 0926f7d..9cbe577 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java
@@ -23,7 +23,6 @@ import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.metadata.MetadataService;
 import org.apache.dubbo.metadata.WritableMetadataService;
 import org.apache.dubbo.registry.client.ServiceInstance;
-import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService;
 import org.apache.dubbo.registry.client.metadata.store.RemoteMetadataServiceImpl;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Protocol;
@@ -55,27 +54,16 @@ public class MetadataUtils {
         if (remoteMetadataService == null) {
             synchronized (REMOTE_LOCK) {
                 if (remoteMetadataService == null) {
-                    remoteMetadataService = new RemoteMetadataServiceImpl(getLocalMetadataService());
+                    remoteMetadataService = new RemoteMetadataServiceImpl(WritableMetadataService.getDefaultExtension());
                 }
             }
         }
         return remoteMetadataService;
     }
 
-    public static WritableMetadataService getLocalMetadataService() {
-        if (localMetadataService == null) {
-            synchronized (LOCK) {
-                if (localMetadataService == null) {
-                    localMetadataService = new InMemoryWritableMetadataService();
-                }
-            }
-        }
-        return localMetadataService;
-    }
-
     public static void publishServiceDefinition(URL url) {
         // store in local
-        getLocalMetadataService().publishServiceDefinition(url);
+        WritableMetadataService.getDefaultExtension().publishServiceDefinition(url);
         // send to remote
         getRemoteMetadataService().publishServiceDefinition(url);
     }
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ProtocolPortsMetadataCustomizer.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ProtocolPortsMetadataCustomizer.java
index 2d83295..c8dffc4 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ProtocolPortsMetadataCustomizer.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/ProtocolPortsMetadataCustomizer.java
@@ -26,8 +26,6 @@ import org.apache.dubbo.rpc.Protocol;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.apache.dubbo.metadata.WritableMetadataService.getExtension;
-import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getMetadataStorageType;
 import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.setEndpoints;
 
 /**
@@ -40,10 +38,7 @@ public class ProtocolPortsMetadataCustomizer implements ServiceInstanceCustomize
 
     @Override
     public void customize(ServiceInstance serviceInstance) {
-
-        String metadataStoredType = getMetadataStorageType(serviceInstance);
-
-        WritableMetadataService writableMetadataService = getExtension(metadataStoredType);
+        WritableMetadataService writableMetadataService = WritableMetadataService.getDefaultExtension();
 
         Map<String, Integer> protocols = new HashMap<>();
         writableMetadataService.getExportedURLs()
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java
index ac0cbc2..799d2aa 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/store/RemoteMetadataServiceImpl.java
@@ -44,6 +44,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
 import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
+import static org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.EXPORTED_SERVICES_REVISION_PROPERTY_NAME;
 
 public class RemoteMetadataServiceImpl {
 
@@ -59,14 +60,17 @@ public class RemoteMetadataServiceImpl {
     }
 
     public void publishMetadata(ServiceInstance instance) {
-        SubscriberMetadataIdentifier identifier = new SubscriberMetadataIdentifier(instance.getServiceName(), ServiceInstanceMetadataUtils.getExportedServicesRevision(instance));
+        MetadataInfo metadataInfo = localMetadataService.getMetadataInfo();
+        SubscriberMetadataIdentifier identifier = new SubscriberMetadataIdentifier(instance.getServiceName(), metadataInfo.getRevision());
         getMetadataReports().forEach(metadataReport -> {
-            metadataReport.publishAppMetadata(identifier, localMetadataService.getMetadataInfo());
+            instance.getMetadata().put(EXPORTED_SERVICES_REVISION_PROPERTY_NAME, metadataInfo.getRevision());
+            metadataReport.publishAppMetadata(identifier, metadataInfo);
         });
     }
 
     public MetadataInfo getMetadata(ServiceInstance instance) {
-        SubscriberMetadataIdentifier identifier = new SubscriberMetadataIdentifier(instance.getServiceName(), ServiceInstanceMetadataUtils.getExportedServicesRevision(instance));
+        SubscriberMetadataIdentifier identifier = new SubscriberMetadataIdentifier(instance.getServiceName(),
+                ServiceInstanceMetadataUtils.getExportedServicesRevision(instance));
         for (MetadataReport reporter : getMetadataReports()) {
             MetadataInfo metadataInfo = reporter.getAppMetadata(identifier, instance.getMetadata());
             if (metadataInfo != null) {
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.WritableMetadataService b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.WritableMetadataService
new file mode 100644
index 0000000..0030270
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.WritableMetadataService
@@ -0,0 +1 @@
+default=org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory
deleted file mode 100644
index a42e022..0000000
--- a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory
+++ /dev/null
@@ -1,3 +0,0 @@
-local=org.apache.dubbo.registry.client.metadata.proxy.DefaultMetadataServiceProxyFactory
-remote=org.apache.dubbo.registry.client.metadata.proxy.RemoteMetadataServiceProxyFactory
-composite = org.apache.dubbo.registry.client.metadata.proxy.CompositeMetadataServiceProxyFactory
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java
index f27a50d..b84bfa9 100644
--- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java
+++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java
@@ -30,7 +30,6 @@ import com.alibaba.nacos.api.naming.listener.NamingEvent;
 import com.alibaba.nacos.api.naming.pojo.Instance;
 import com.alibaba.nacos.api.naming.pojo.ListView;
 
-import java.util.Collection;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
@@ -121,7 +120,7 @@ public class NacosServiceDiscovery implements ServiceDiscovery {
 
     private void handleEvent(NamingEvent event, ServiceInstancesChangedListener listener) {
         String serviceName = event.getServiceName();
-        Collection<ServiceInstance> serviceInstances = event.getInstances()
+        List<ServiceInstance> serviceInstances = event.getInstances()
                 .stream()
                 .map(NacosNamingServiceUtils::toServiceInstance)
                 .collect(Collectors.toList());