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/27 06:44:19 UTC
[dubbo] branch 3.0 updated: Refactor migration
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
The following commit(s) were added to refs/heads/3.0 by this push:
new 346166e Refactor migration
346166e is described below
commit 346166e674fea88d10dc43be82e387f547156709
Author: ken.lj <ke...@gmail.com>
AuthorDate: Thu Aug 27 14:43:10 2020 +0800
Refactor migration
---
.../DefaultMigrationAddressComparator.java | 2 +-
.../migration}/InvokersChangedListener.java | 2 +-
.../migration}/MigrationAddressComparator.java | 2 +-
.../migration/MigrationClusterInvoker.java} | 23 +++-
.../migration}/MigrationInvoker.java | 142 +++++++++++----------
.../migration/MigrationRuleHandler.java} | 13 +-
.../MigrationRuleListener.java} | 15 +--
.../ServiceDiscoveryMigrationInvoker.java | 52 ++++++++
.../migration/model}/MigrationRule.java | 9 +-
.../migration/model}/MigrationStep.java | 2 +-
.../registry/integration/DynamicDirectory.java | 1 +
.../InterfaceCompatibleRegistryProtocol.java | 2 +-
.../{client => integration}/RegistryProtocol.java | 38 +-----
.../integration/RegistryProtocolListener.java | 1 -
...try.client.migration.MigrationAddressComparator | 1 +
...registry.integration.MigrationAddressComparator | 1 -
...o.registry.integration.RegistryProtocolListener | 2 +-
.../dubbo/internal/org.apache.dubbo.rpc.Protocol | 2 +-
pom.xml | 37 ++++++
19 files changed, 217 insertions(+), 130 deletions(-)
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DefaultMigrationAddressComparator.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/DefaultMigrationAddressComparator.java
similarity index 95%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DefaultMigrationAddressComparator.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/DefaultMigrationAddressComparator.java
index a17d601..5fc8480 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DefaultMigrationAddressComparator.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/DefaultMigrationAddressComparator.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/InvokersChangedListener.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/InvokersChangedListener.java
similarity index 94%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/InvokersChangedListener.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/InvokersChangedListener.java
index 5a55a02..9ed886f 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/InvokersChangedListener.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/InvokersChangedListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration;
public interface InvokersChangedListener {
void onChange();
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationAddressComparator.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationAddressComparator.java
similarity index 95%
copy from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationAddressComparator.java
copy to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationAddressComparator.java
index b288720..2be527b 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationAddressComparator.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationAddressComparator.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration;
import org.apache.dubbo.common.extension.SPI;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationAddressComparator.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationClusterInvoker.java
similarity index 63%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationAddressComparator.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationClusterInvoker.java
index b288720..3bd6fd7 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationAddressComparator.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationClusterInvoker.java
@@ -14,12 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration;
-import org.apache.dubbo.common.extension.SPI;
+import org.apache.dubbo.registry.client.migration.model.MigrationStep;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
-@SPI
-public interface MigrationAddressComparator {
- <T> boolean shouldMigrate(ClusterInvoker<T> serviceDiscoveryInvoker, ClusterInvoker<T> invoker);
+/**
+ * FIXME, some methods need to be further optimized.
+ *
+ * @param <T>
+ */
+public interface MigrationClusterInvoker<T> extends ClusterInvoker<T> {
+
+ boolean isServiceDiscovery();
+
+ MigrationStep getCurrentStep();
+
+ boolean invokersChanged();
+
+ void fallbackToInterfaceInvoker();
+
+ void migrateToServiceDiscoveryInvoker(boolean forceMigrate);
}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationInvoker.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationInvoker.java
similarity index 92%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationInvoker.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationInvoker.java
index 7ba9154..768f496 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationInvoker.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationInvoker.java
@@ -14,12 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.registry.Registry;
-import org.apache.dubbo.registry.client.RegistryProtocol;
+import org.apache.dubbo.registry.client.migration.model.MigrationStep;
+import org.apache.dubbo.registry.integration.DynamicDirectory;
+import org.apache.dubbo.registry.integration.RegistryProtocol;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcException;
@@ -29,7 +31,7 @@ import org.apache.dubbo.rpc.cluster.Directory;
import java.util.Set;
-public class MigrationInvoker<T> implements ClusterInvoker<T> {
+public class MigrationInvoker<T> implements MigrationClusterInvoker<T> {
private URL url;
private Cluster cluster;
@@ -85,18 +87,8 @@ public class MigrationInvoker<T> implements ClusterInvoker<T> {
return type;
}
- private boolean forceMigrate;
-
- public boolean isForceMigrate() {
- return forceMigrate;
- }
-
- public void setForceMigrate(boolean forceMigrate) {
- this.forceMigrate = forceMigrate;
- }
-
+ @Override
public synchronized void migrateToServiceDiscoveryInvoker(boolean forceMigrate) {
- setForceMigrate(forceMigrate);
if (!forceMigrate) {
refreshServiceDiscoveryInvoker();
refreshInterfaceInvoker();
@@ -110,63 +102,12 @@ public class MigrationInvoker<T> implements ClusterInvoker<T> {
}
}
- private synchronized void checkAddresses() {
- Set<MigrationAddressComparator> detectors = ExtensionLoader.getExtensionLoader(MigrationAddressComparator.class).getSupportedExtensionInstances();
- if (detectors != null && detectors.stream().allMatch(migrationDetector -> migrationDetector.shouldMigrate(serviceDiscoveryInvoker, invoker))) {
- discardInterfaceInvokerAddress();
- } else {
- discardServiceDiscoveryInvokerAddress();
- }
- }
-
+ @Override
public synchronized void fallbackToInterfaceInvoker() {
refreshInterfaceInvoker();
destroyServiceDiscoveryInvoker();
}
- protected synchronized void destroyServiceDiscoveryInvoker() {
- if (serviceDiscoveryInvoker != null) {
- serviceDiscoveryInvoker.destroy();
- serviceDiscoveryInvoker = null;
- }
- }
-
- protected synchronized void discardServiceDiscoveryInvokerAddress() {
- if (serviceDiscoveryInvoker != null) {
- serviceDiscoveryInvoker.getDirectory().discordAddresses();
- }
- }
-
- protected synchronized void refreshServiceDiscoveryInvoker() {
- if (needRefresh(serviceDiscoveryInvoker)) {
- serviceDiscoveryInvoker = registryProtocol.getServiceDiscoveryInvoker(cluster, registry, type, url);
- }
- }
-
- protected synchronized void refreshInterfaceInvoker() {
- if (needRefresh(invoker)) {
- // FIXME invoker.destroy();
- invoker = registryProtocol.getInvoker(cluster, registry, type, url);
- }
- }
-
- protected synchronized void destroyInterfaceInvoker() {
- if (invoker != null) {
- invoker.destroy();
- invoker = null;
- }
- }
-
- protected synchronized void discardInterfaceInvokerAddress() {
- if (invoker != null) {
- invoker.getDirectory().discordAddresses();
- }
- }
-
- private boolean needRefresh(ClusterInvoker<T> invoker) {
- return invoker == null || invoker.isDestroyed() || !invoker.isAvailable();
- }
-
@Override
public Result invoke(Invocation invocation) throws RpcException {
if (needRefresh(serviceDiscoveryInvoker)) {
@@ -225,4 +166,73 @@ public class MigrationInvoker<T> implements ClusterInvoker<T> {
return (invoker == null || invoker.isDestroyed())
&& (serviceDiscoveryInvoker == null || serviceDiscoveryInvoker.isDestroyed());
}
+
+ @Override
+ public boolean isServiceDiscovery() {
+ return false;
+ }
+
+ @Override
+ public MigrationStep getCurrentStep() {
+ return null;
+ }
+
+ @Override
+ public boolean invokersChanged() {
+ return false;
+ }
+
+
+ private synchronized void checkAddresses() {
+ Set<MigrationAddressComparator> detectors = ExtensionLoader.getExtensionLoader(MigrationAddressComparator.class).getSupportedExtensionInstances();
+ if (detectors != null && detectors.stream().allMatch(migrationDetector -> migrationDetector.shouldMigrate(serviceDiscoveryInvoker, invoker))) {
+ discardInterfaceInvokerAddress();
+ } else {
+ discardServiceDiscoveryInvokerAddress();
+ }
+ }
+
+ protected synchronized void destroyServiceDiscoveryInvoker() {
+ if (serviceDiscoveryInvoker != null) {
+ serviceDiscoveryInvoker.destroy();
+ serviceDiscoveryInvoker = null;
+ }
+ }
+
+ protected synchronized void discardServiceDiscoveryInvokerAddress() {
+ if (serviceDiscoveryInvoker != null) {
+ serviceDiscoveryInvoker.getDirectory().discordAddresses();
+ }
+ }
+
+ protected synchronized void refreshServiceDiscoveryInvoker() {
+ if (needRefresh(serviceDiscoveryInvoker)) {
+ serviceDiscoveryInvoker = registryProtocol.getServiceDiscoveryInvoker(cluster, registry, type, url);
+ }
+ }
+
+ protected synchronized void refreshInterfaceInvoker() {
+ if (needRefresh(invoker)) {
+ // FIXME invoker.destroy();
+ invoker = registryProtocol.getInvoker(cluster, registry, type, url);
+ }
+ }
+
+ protected synchronized void destroyInterfaceInvoker() {
+ if (invoker != null) {
+ invoker.destroy();
+ invoker = null;
+ }
+ }
+
+ protected synchronized void discardInterfaceInvokerAddress() {
+ if (invoker != null) {
+ invoker.getDirectory().discordAddresses();
+ }
+ }
+
+ private boolean needRefresh(ClusterInvoker<T> invoker) {
+ return invoker == null || invoker.isDestroyed() || !invoker.isAvailable();
+ }
+
}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationRuleListener.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleHandler.java
similarity index 85%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationRuleListener.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleHandler.java
index 0e895f8..556c701 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationRuleListener.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleHandler.java
@@ -14,30 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration;
import org.apache.dubbo.common.config.ConfigurationUtils;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
-import org.apache.dubbo.registry.client.RegistryProtocol;
+import org.apache.dubbo.registry.client.migration.model.MigrationRule;
+import org.apache.dubbo.registry.client.migration.model.MigrationStep;
import static org.apache.dubbo.common.constants.RegistryConstants.INIT;
@Activate
-public class MigrationRuleListener<T> {
- private static final Logger logger = LoggerFactory.getLogger(MigrationRuleListener.class);
+public class MigrationRuleHandler<T> {
+ private static final Logger logger = LoggerFactory.getLogger(MigrationRuleHandler.class);
private static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "dubbo.application.service-discovery.migration";
private MigrationInvoker<T> migrationInvoker;
- public MigrationRuleListener(MigrationInvoker<T> invoker) {
+ public MigrationRuleHandler(MigrationInvoker<T> invoker) {
this.migrationInvoker = invoker;
}
public void doMigrate(String rawRule) {
- MigrationStep step = (migrationInvoker instanceof RegistryProtocol.ServiceDiscoveryMigrationInvoker)
+ MigrationStep step = (migrationInvoker instanceof ServiceDiscoveryMigrationInvoker)
? MigrationStep.FORCE_APPLICATION
: MigrationStep.INTERFACE_FIRST;
if (StringUtils.isEmpty(rawRule)) {
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryProtocolListener.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleListener.java
similarity index 85%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryProtocolListener.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleListener.java
index f7b422b..918d9aa 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistryProtocolListener.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationRuleListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.client;
+package org.apache.dubbo.registry.client.migration;
import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
@@ -25,8 +25,7 @@ import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.ConcurrentHashSet;
import org.apache.dubbo.common.utils.StringUtils;
-import org.apache.dubbo.registry.integration.MigrationInvoker;
-import org.apache.dubbo.registry.integration.MigrationRuleListener;
+import org.apache.dubbo.registry.integration.RegistryProtocol;
import org.apache.dubbo.registry.integration.RegistryProtocolListener;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.Invoker;
@@ -37,17 +36,17 @@ import java.util.Set;
import static org.apache.dubbo.common.constants.RegistryConstants.INIT;
@Activate
-public class ServiceDiscoveryRegistryProtocolListener implements RegistryProtocolListener, ConfigurationListener {
- private static final Logger logger = LoggerFactory.getLogger(ServiceDiscoveryRegistryProtocolListener.class);
+public class MigrationRuleListener implements RegistryProtocolListener, ConfigurationListener {
+ private static final Logger logger = LoggerFactory.getLogger(MigrationRuleListener.class);
private static final String RULE_KEY = ApplicationModel.getName() + ".migration";
private static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "DUBBO_SERVICEDISCOVERY_MIGRATION";
- private Set<MigrationRuleListener> listeners = new ConcurrentHashSet<>();
+ private Set<MigrationRuleHandler> listeners = new ConcurrentHashSet<>();
private DynamicConfiguration configuration;
private volatile String rawRule;
- public ServiceDiscoveryRegistryProtocolListener() {
+ public MigrationRuleListener() {
this.configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().orElseGet(null);
configuration.addListener(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, this);
@@ -81,7 +80,7 @@ public class ServiceDiscoveryRegistryProtocolListener implements RegistryProtoco
public synchronized <T> void onRefer(RegistryProtocol registryProtocol, Invoker<T> invoker) {
MigrationInvoker<T> migrationInvoker = (MigrationInvoker<T>) invoker;
- MigrationRuleListener<T> migrationListener = new MigrationRuleListener<>(migrationInvoker);
+ MigrationRuleHandler<T> migrationListener = new MigrationRuleHandler<>(migrationInvoker);
listeners.add(migrationListener);
migrationListener.doMigrate(rawRule);
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/ServiceDiscoveryMigrationInvoker.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/ServiceDiscoveryMigrationInvoker.java
new file mode 100644
index 0000000..b37afba
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/ServiceDiscoveryMigrationInvoker.java
@@ -0,0 +1,52 @@
+/*
+ * 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.registry.client.migration;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.registry.Registry;
+import org.apache.dubbo.registry.integration.RegistryProtocol;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.Result;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.cluster.Cluster;
+import org.apache.dubbo.rpc.cluster.ClusterInvoker;
+
+public class ServiceDiscoveryMigrationInvoker<T> extends MigrationInvoker<T> {
+
+ public ServiceDiscoveryMigrationInvoker(RegistryProtocol registryProtocol, Cluster cluster, Registry registry, Class<T> type, URL url) {
+ super(registryProtocol, cluster, registry, type, url);
+ }
+
+ @Override
+ public synchronized void fallbackToInterfaceInvoker() {
+ destroyServiceDiscoveryInvoker();
+ }
+
+ @Override
+ public synchronized void migrateToServiceDiscoveryInvoker(boolean forceMigrate) {
+ refreshServiceDiscoveryInvoker();
+ }
+
+ @Override
+ public Result invoke(Invocation invocation) throws RpcException {
+ ClusterInvoker<T> invoker = getServiceDiscoveryInvoker();
+ if (invoker == null) {
+ throw new IllegalStateException("There's no service discovery invoker available for service " + invocation.getServiceName());
+ }
+ return invoker.invoke(invocation);
+ }
+}
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationRule.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/model/MigrationRule.java
similarity index 87%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationRule.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/model/MigrationRule.java
index 31e9395..b0f84b1 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationRule.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/model/MigrationRule.java
@@ -14,11 +14,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration.model;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
+/**
+ * # key = demo-consumer.migration
+ * # group = DUBBO_SERVICEDISCOVERY_MIGRATION
+ * # content
+ * key: demo-consumer
+ * step: APPLICATION_FIRST
+ */
public class MigrationRule {
private String key;
private MigrationStep step;
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationStep.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/model/MigrationStep.java
similarity index 93%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationStep.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/model/MigrationStep.java
index f0b5ae3..1fe8ec8 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/MigrationStep.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/model/MigrationStep.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.integration;
+package org.apache.dubbo.registry.client.migration.model;
public enum MigrationStep {
INTERFACE_FIRST,
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DynamicDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DynamicDirectory.java
index 22334ed..41e3584 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DynamicDirectory.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/DynamicDirectory.java
@@ -26,6 +26,7 @@ import org.apache.dubbo.common.utils.NetUtils;
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.migration.InvokersChangedListener;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/InterfaceCompatibleRegistryProtocol.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/InterfaceCompatibleRegistryProtocol.java
index b73f674..d073aff 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/InterfaceCompatibleRegistryProtocol.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/InterfaceCompatibleRegistryProtocol.java
@@ -19,8 +19,8 @@ package org.apache.dubbo.registry.integration;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.registry.Registry;
-import org.apache.dubbo.registry.client.RegistryProtocol;
import org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory;
+import org.apache.dubbo.registry.client.migration.MigrationInvoker;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.cluster.Cluster;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/RegistryProtocol.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
similarity index 95%
rename from dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/RegistryProtocol.java
rename to dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
index 945e65d..855b726 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/RegistryProtocol.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.client;
+package org.apache.dubbo.registry.integration;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.ConfigurationUtils;
@@ -31,21 +31,15 @@ import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.RegistryFactory;
import org.apache.dubbo.registry.RegistryService;
-import org.apache.dubbo.registry.integration.AbstractConfiguratorListener;
-import org.apache.dubbo.registry.integration.DynamicDirectory;
-import org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol;
-import org.apache.dubbo.registry.integration.MigrationInvoker;
-import org.apache.dubbo.registry.integration.RegistryDirectory;
-import org.apache.dubbo.registry.integration.RegistryProtocolListener;
+import org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory;
+import org.apache.dubbo.registry.client.migration.ServiceDiscoveryMigrationInvoker;
import org.apache.dubbo.registry.retry.ReExportTask;
import org.apache.dubbo.registry.support.SkipFailbackWrapperException;
import org.apache.dubbo.rpc.Exporter;
-import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Protocol;
import org.apache.dubbo.rpc.ProtocolServer;
import org.apache.dubbo.rpc.ProxyFactory;
-import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.Cluster;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
@@ -837,30 +831,4 @@ public class RegistryProtocol implements Protocol {
}
return INSTANCE;
}
-
- public static class ServiceDiscoveryMigrationInvoker<T> extends MigrationInvoker<T> {
-
- public ServiceDiscoveryMigrationInvoker(RegistryProtocol registryProtocol, Cluster cluster, Registry registry, Class<T> type, URL url) {
- super(registryProtocol, cluster, registry, type, url);
- }
-
- @Override
- public synchronized void fallbackToInterfaceInvoker() {
- destroyServiceDiscoveryInvoker();
- }
-
- @Override
- public synchronized void migrateToServiceDiscoveryInvoker(boolean forceMigrate) {
- refreshServiceDiscoveryInvoker();
- }
-
- @Override
- public Result invoke(Invocation invocation) throws RpcException {
- ClusterInvoker<T> invoker = getServiceDiscoveryInvoker();
- if (invoker == null) {
- throw new IllegalStateException("There's no service discovery invoker available for service " + invocation.getServiceName());
- }
- return invoker.invoke(invocation);
- }
- }
}
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocolListener.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocolListener.java
index ab9bc29..50bdca1 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocolListener.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocolListener.java
@@ -18,7 +18,6 @@ package org.apache.dubbo.registry.integration;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.SPI;
-import org.apache.dubbo.registry.client.RegistryProtocol;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.Invoker;
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.migration.MigrationAddressComparator b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.migration.MigrationAddressComparator
new file mode 100644
index 0000000..b7fa71c
--- /dev/null
+++ b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.migration.MigrationAddressComparator
@@ -0,0 +1 @@
+default=org.apache.dubbo.registry.client.migration.DefaultMigrationAddressComparator
\ 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.integration.MigrationAddressComparator b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.integration.MigrationAddressComparator
deleted file mode 100644
index 1c5c52d..0000000
--- a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.integration.MigrationAddressComparator
+++ /dev/null
@@ -1 +0,0 @@
-default=org.apache.dubbo.registry.integration.DefaultMigrationAddressComparator
\ 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.integration.RegistryProtocolListener b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.integration.RegistryProtocolListener
index d60633c..24943f7 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.integration.RegistryProtocolListener
+++ b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.integration.RegistryProtocolListener
@@ -1 +1 @@
-service-discovery=org.apache.dubbo.registry.client.ServiceDiscoveryRegistryProtocolListener
\ No newline at end of file
+migration=org.apache.dubbo.registry.client.migration.MigrationRuleListener
\ No newline at end of file
diff --git a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
index 5dda00e..4c3b148 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
+++ b/dubbo-registry/dubbo-registry-api/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Protocol
@@ -1,2 +1,2 @@
registry=org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol
-service-discovery-registry=org.apache.dubbo.registry.client.RegistryProtocol
\ No newline at end of file
+service-discovery-registry=org.apache.dubbo.registry.integration.RegistryProtocol
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 26a6a63..e2c22aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -586,6 +586,43 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.5.3</version>
+ <configuration>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ <useReleaseProfile>false</useReleaseProfile>
+ <releaseProfiles>release</releaseProfiles>
+ <goals>deploy</goals>
+ <arguments>${arguments}</arguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>flatten-maven-plugin</artifactId>
+ <version>${maven_flatten_version}</version>
+ <configuration>
+ <updatePomFile>true</updatePomFile>
+ <flattenMode>resolveCiFriendliesOnly</flattenMode>
+ </configuration>
+ <executions>
+ <execution>
+ <id>flatten</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>flatten</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>flatten.clean</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>