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 a17d60183d..5fc84805bd 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 5a55a023cc..9ed886f103 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% 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/MigrationAddressComparator.java index b288720128..2be527b34b 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/client/migration/MigrationClusterInvoker.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationClusterInvoker.java new file mode 100644 index 0000000000..3bd6fd7f74 --- /dev/null +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/migration/MigrationClusterInvoker.java @@ -0,0 +1,38 @@ +/* + * 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.registry.client.migration.model.MigrationStep; +import org.apache.dubbo.rpc.cluster.ClusterInvoker; + +/** + * FIXME, some methods need to be further optimized. + * + * @param + */ +public interface MigrationClusterInvoker extends ClusterInvoker { + + 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 7ba91542de..768f496c5e 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 implements ClusterInvoker { +public class MigrationInvoker implements MigrationClusterInvoker { private URL url; private Cluster cluster; @@ -85,18 +87,8 @@ public class MigrationInvoker implements ClusterInvoker { 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 implements ClusterInvoker { } } - private synchronized void checkAddresses() { - Set 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 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 implements ClusterInvoker { 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 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 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 0e895f8045..556c701d9b 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 { - private static final Logger logger = LoggerFactory.getLogger(MigrationRuleListener.class); +public class MigrationRuleHandler { + private static final Logger logger = LoggerFactory.getLogger(MigrationRuleHandler.class); private static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "dubbo.application.service-discovery.migration"; private MigrationInvoker migrationInvoker; - public MigrationRuleListener(MigrationInvoker invoker) { + public MigrationRuleHandler(MigrationInvoker 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 f7b422bd06..918d9aa196 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 listeners = new ConcurrentHashSet<>(); + private Set 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 void onRefer(RegistryProtocol registryProtocol, Invoker invoker) { MigrationInvoker migrationInvoker = (MigrationInvoker) invoker; - MigrationRuleListener migrationListener = new MigrationRuleListener<>(migrationInvoker); + MigrationRuleHandler 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 0000000000..b37afbac2b --- /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 extends MigrationInvoker { + + public ServiceDiscoveryMigrationInvoker(RegistryProtocol registryProtocol, Cluster cluster, Registry registry, Class 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 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 31e9395787..b0f84b14c7 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 f0b5ae3dde..1fe8ec8a6c 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 22334edeba..41e3584b2c 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 b73f6743c4..d073aff06f 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 945e65dccc..855b726408 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 extends MigrationInvoker { - - public ServiceDiscoveryMigrationInvoker(RegistryProtocol registryProtocol, Cluster cluster, Registry registry, Class 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 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 ab9bc297d5..50bdca121b 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 0000000000..b7fa71c229 --- /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 1c5c52ddec..0000000000 --- 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 d60633c919..24943f74d8 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 5dda00eb41..4c3b1483ce 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 26a6a63311..e2c22aa076 100644 --- a/pom.xml +++ b/pom.xml @@ -586,6 +586,43 @@ + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + true + false + release + deploy + ${arguments} + + + + org.codehaus.mojo + flatten-maven-plugin + ${maven_flatten_version} + + true + resolveCiFriendliesOnly + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + +