Skip to content

Commit

Permalink
Dubbo cloud native (#4949)
Browse files Browse the repository at this point in the history
* Polish #4542 : [Enhancement] Adapt the Java standard Event/Listener mechanism

* Polish #4541 : [Feature] Add local File System DynamicConfigurationFactory‘s extension

* Polish #4541 : Bugfix

* Polish #4541 : Optimization

* Polish #4541 : Add the compatibility for PollingWatchService on the some platforms

* Polish #4541 : Add delay publish without ThreadPoolExecutor

* Polish #4541 : Refactor the extension name

* Polish #4541 : Add remove ops

* Polish #4541 : Add testable constructor

* Polish #4541 : Add getConfigGroups method

* Polish #4610 : [Refactor] Refactor the bootstrap module

* Polish #4541 : Fix the nulling URL issue

* Polish #4622 : [Refactor] Refactor ConfigManager

* Polish #4622 : [Refactor] Refactor ConfigManager

* Polish #4622 : Support multiple configcenters

* Polish #4671 : ServiceNameMapping will not map the group, version and protocol

* update referenceCount log (#4683)

Add comments to support multiple shared connections

* Polish /#4687 : Remove the duplicated test code in dubbo-config-spring (#4688)

* #4685  修改代码if判断false问题 if (hasException == false)修改成if (!hasException) (#4695)

* Fixed Service annotation method parameters are not in effect (#4598)

* keep demo simple, and switch to use zookeeper as registry center (#4705)

* keep demo simple, and switch to use zookeeper as registry center

* remove comment

* @reference auto-wires the instance of generic interface #4594 (#4677)

* try to shorten maven output to make travis build pass (#4710)

* use CountDownLatch to check zk registry if establish connection (#4589)

* Minor change

* Rename the extension name of WritableMetadataService

* Polish #4759 : [Refactor] Change the signature of methods of MetadataService #4759

* Merge remote-tracking branch 'upstream/master' into dubbo-cloud-native

# Conflicts:
#	dubbo-all/pom.xml
#	dubbo-bom/pom.xml
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ApplicationConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/RegistryConfig.java
#	dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
#	dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
#	dubbo-configcenter/dubbo-configcenter-api/src/main/java/org/apache/dubbo/configcenter/DynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-api/src/test/java/org/apache/dubbo/configcenter/mock/MockDynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-consul/src/main/java/org/apache/dubbo/configcenter/consul/ConsulDynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-etcd/src/test/java/org/apache/dubbo/configcenter/support/etcd/EtcdDynamicConfigurationTest.java
#	dubbo-configcenter/dubbo-configcenter-nacos/src/main/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfiguration.java
#	dubbo-configcenter/dubbo-configcenter-nacos/src/test/java/org/apache/dubbo/configcenter/support/nacos/NacosDynamicConfigurationTest.java
#	dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java
#	dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/definition/model/MethodDefinition.java
#	dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifier.java
#	dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/report/support/AbstractMetadataReport.java
#	dubbo-metadata/dubbo-metadata-api/src/test/java/org/apache/dubbo/metadata/report/identifier/MetadataIdentifierTest.java
#	dubbo-metadata/dubbo-metadata-definition-protobuf/src/main/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilder.java
#	dubbo-metadata/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/ProtobufTypeBuilderTest.java
#	dubbo-metadata/pom.xml
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/AbstractConfiguratorListener.java
#	dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
#	dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistryFactory.java
#	dubbo-rpc/dubbo-rpc-xml/src/main/java/org/apache/dubbo/xml/rpc/protocol/xmlrpc/XmlRpcProtocol.java

* Polish #3984 : Add the implementation of Page<ServiceInstance> getInstances(String serviceName, int offset, int pageSize, boolean healthyOnly)

* Code merge

* Fix the cases

* Merge remote-tracking branch 'upstream/cloud-native' into dubbo-cloud-native

# Conflicts:
#	dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProviderBootstrap.java
#	dubbo-metadata/dubbo-metadata-definition-protobuf/pom.xml
#	dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/ServiceOrientedRegistryTest.java
#	dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscoveryFactory.java
#	dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java

* Refactor ConfigManager

* Refactor ConfigManager

* Resolve the issues on ConfigManager

* Refactor and add test-cases for ConfigManager

* Polish #4774 : [Feature] Dubbo Cloud Native - To Support in Spring

* Polish #4808 : [Feature] Add the registered/unregistered event mechanism ShutdownHook

* Polish #4807 : [Feature] Add the callback mechanism ShutdownHook #4807

* Polish #4813 : [Feature] add Prioritized implementation for ServiceInstanceCustomizer

* Polish #4815 : [Feature] Add the ServiceLoader for Dubbo's services or components

* Polish #4815 : [Feature] Add the ServiceLoader for Dubbo's services or components

* Polish #4813 : [Feature] add Prioritized implementation for ServiceInstanceCustomizer

* Polish #4807 : Add sort implementation

* Refactor

* Refactor

* Polish #4845 : [Feature] Enhance the Event-Publishing feature to original ServiceDiscovery

* Merge remote-tracking branch 'upstream/cloud-native' into dubbo-cloud-native

# Conflicts:
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultServiceDiscoveryFactory.java
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java

* Merge remote-tracking branch 'upstream/cloud-native' into dubbo-cloud-native

# Conflicts:
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/DefaultServiceDiscoveryFactory.java
#	dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/ServiceDiscoveryRegistry.java

* Polish #4854 : [Feature] MetadataService supports the Dubbo protocol under auto-increased port

* Polish #4857 : [Enhancement] Sync the Metadata storage type into ApplicationConfig

* Polish #4868 : [Enhancement] Refactor ConfigChangeEvent

* Polish #4868 : [Enhancement] Refactor ConfigChangeEvent

* Polish #4873 : [Feature] Add a conditional EventListener into Event Module

* Polish #4875 : [Feature] Refactor ServiceInstancesChangedListener

* Remove the cycle dependencies

* Remove the cycle dependencies

* Polish #4903 : [Feature] Set source into the BeanDefinition of Dubbo Config

* Polish #4902 : [Feature] Dubbo Cloud Native to Spring XML scenario

* Polish #4713 : Initial the new module and dependencies

* Polish #4690 : AnnotatedBeanDefinitionRegistryUtils#registerBeans can't remove the duplicated bean definitions

* Polish #4690 : AnnotatedBeanDefinitionRegistryUtils#registerBeans can't remove the duplicated bean definitions

* Polish #4690 : AnnotatedBeanDefinitionRegistryUtils#registerBeans can't remove the duplicated bean definitions

* Polish #4910 : [Feature] To suppoort DubboLifecycleComponentApplicationListener in Spring XML scenario

* Polish #4713 : Add Service discovery implementation for Eureka #4713

* Polish #4713 : Add Service registration and discovery implementation for Eureka

* Polish #4713 : Add Service registration and discovery implementation for Eureka

* Polish #4920 : [Refactor] Extract the common implementation for URLs' revision

* Refactor

* Polish #4925 : ServiceDiscovery limits only one ServiceInstancesChangedListener each service

* Polish #4925 : ServiceDiscovery limits only one ServiceInstancesChangedListener each service

* Remove useless classes

* Bugfix & Refactor ServiceDiscoveryRegistry

* Polish #4937 : The calculation of Revision should add the parameters of URL

* Polish #4940 : NacosDynamicConfiguration supports getConfigKeys method

* Polish #4942 : Dubbo Cloud Native supports multiple protcols

* Polish #4944 : [Feature] Simplify The metadata of URL for MetadataService

* Polish #4947 : [Feature] Dubbo Cloud-Native supports the REST call to Non-Dubbo
  • Loading branch information
mercyblitz authored Aug 26, 2019
1 parent 27ba1c7 commit edd37e3
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,21 @@ public static void main(String[] args) throws Exception {
// applicationConfig.setMetadataType("remote");
new DubboBootstrap()
.application(applicationConfig)
// Zookeeper
.registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service&subscribed-services=dubbo-nacos-provider-demo"))
.registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service&subscribed-services=service-provider"))
.metadataReport(new MetadataReportConfig("nacos://127.0.0.1:8848"))
// Nacos
// .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
.reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
.reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
.start()
.await();

ConfigManager configManager = ConfigManager.getInstance();

ReferenceConfig<EchoService> referenceConfig = configManager.getReference("echo");
ReferenceConfig<UserService> referenceConfig = configManager.getReference("user");

EchoService echoService = referenceConfig.get();
UserService userService = referenceConfig.get();

for (int i = 0; i < 500; i++) {
Thread.sleep(2000L);
System.out.println(echoService.echo("Hello,World"));
System.out.println(userService.getUser(i * 1L));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent;
import org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener;
import org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils;
import org.apache.dubbo.registry.client.metadata.SubscribedURLsSynthesizer;
import org.apache.dubbo.registry.client.metadata.proxy.MetadataServiceProxyFactory;
import org.apache.dubbo.registry.client.selector.ServiceInstanceSelector;
import org.apache.dubbo.registry.support.FailbackRegistry;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -72,6 +74,7 @@
import static org.apache.dubbo.common.function.ThrowableAction.execute;
import static org.apache.dubbo.common.utils.CollectionUtils.isEmpty;
import static org.apache.dubbo.common.utils.CollectionUtils.isNotEmpty;
import static org.apache.dubbo.common.utils.DubboServiceLoader.loadServices;
import static org.apache.dubbo.common.utils.StringUtils.isBlank;
import static org.apache.dubbo.metadata.WritableMetadataService.DEFAULT_EXTENSION;
import static org.apache.dubbo.registry.client.ServiceDiscoveryFactory.getExtension;
Expand Down Expand Up @@ -110,6 +113,8 @@ public class ServiceDiscoveryRegistry extends FailbackRegistry {

private final Set<String> registeredListeners = new LinkedHashSet<>();

private final List<SubscribedURLsSynthesizer> subscribedURLsSynthesizers;

/**
* A cache for all URLs of services that the subscribed services exported
* The key is the service name
Expand All @@ -124,6 +129,7 @@ public ServiceDiscoveryRegistry(URL registryURL) {
this.serviceNameMapping = ServiceNameMapping.getDefaultExtension();
String metadataStorageType = getMetadataStorageType(registryURL);
this.writableMetadataService = WritableMetadataService.getExtension(metadataStorageType);
this.subscribedURLsSynthesizers = initSubscribedURLsSynthesizers();
}

/**
Expand Down Expand Up @@ -157,6 +163,10 @@ protected ServiceDiscovery createServiceDiscovery(URL registryURL) {
return serviceDiscovery;
}

private List<SubscribedURLsSynthesizer> initSubscribedURLsSynthesizers() {
return loadServices(SubscribedURLsSynthesizer.class, this.getClass().getClassLoader());
}

/**
* Get the instance {@link ServiceDiscovery} from the registry {@link URL} using
* {@link ServiceDiscoveryFactory} SPI
Expand Down Expand Up @@ -331,12 +341,32 @@ protected void subscribeURLs(URL subscribedURL, NotifyListener listener, String
return;
}

List<URL> subscribedURLs = getSubscribedURLs(subscribedURL, serviceInstances);
List<URL> subscribedURLs = new LinkedList<>();

/**
* Add the exported URLs from {@link MetadataService}
*/
subscribedURLs.addAll(getExportedURLs(subscribedURL, serviceInstances));

if (subscribedURLs.isEmpty()) { // If empty, try to synthesize
/**
* Add the subscribed URLs that were synthesized
*/
subscribedURLs.addAll(synthesizeSubscribedURLs(subscribedURL, serviceInstances));
}

listener.notify(subscribedURLs);
}

private List<URL> getSubscribedURLs(URL subscribedURL, Collection<ServiceInstance> instances) {
/**
* Get the exported {@link URL URLs} from the {@link MetadataService} in the specified
* {@link ServiceInstance service instances}
*
* @param subscribedURL the subscribed {@link URL url}
* @param instances {@link ServiceInstance service instances}
* @return the exported {@link URL URLs} if present, or <code>{@link Collections#emptyList() empty list}</code>
*/
private List<URL> getExportedURLs(URL subscribedURL, Collection<ServiceInstance> instances) {

// local service instances could be mutable
List<ServiceInstance> serviceInstances = instances.stream()
Expand All @@ -356,7 +386,7 @@ private List<URL> getSubscribedURLs(URL subscribedURL, Collection<ServiceInstanc
initTemplateURLs(subscribedURL, serviceInstances);

// Clone the subscribed URLs from the template URLs
List<URL> subscribedURLs = cloneSubscribedURLs(subscribedURL, serviceInstances);
List<URL> subscribedURLs = cloneExportedURLs(subscribedURL, serviceInstances);
// clear local service instances
serviceInstances.clear();
return subscribedURLs;
Expand All @@ -368,7 +398,7 @@ private void initTemplateURLs(URL subscribedURL, List<ServiceInstance> serviceIn
// select a instance of {@link ServiceInstance}
ServiceInstance selectedInstance = selectServiceInstance(serviceInstances);
// try to get the template URLs
List<URL> templateURLs = getTemplateURLs(subscribedURL, selectedInstance);
List<URL> templateURLs = getTemplateExportedURLs(subscribedURL, selectedInstance);
if (isNotEmpty(templateURLs)) { // If the result is valid
break; // break the loop
} else {
Expand Down Expand Up @@ -407,19 +437,19 @@ private void expungeStaleRevisionExportedURLs(List<ServiceInstance> serviceInsta
}
}

private List<URL> cloneSubscribedURLs(URL subscribedURL, Collection<ServiceInstance> serviceInstances) {
private List<URL> cloneExportedURLs(URL subscribedURL, Collection<ServiceInstance> serviceInstances) {

if (isEmpty(serviceInstances)) {
return emptyList();
}

List<URL> clonedURLs = new LinkedList<>();
List<URL> clonedExportedURLs = new LinkedList<>();

serviceInstances.forEach(serviceInstance -> {

String host = serviceInstance.getHost();

getTemplateURLs(subscribedURL, serviceInstance)
getTemplateExportedURLs(subscribedURL, serviceInstance)
.stream()
.map(templateURL -> templateURL.removeParameter(TIMESTAMP_KEY))
.map(templateURL -> templateURL.removeParameter(PID_KEY))
Expand All @@ -437,9 +467,9 @@ private List<URL> cloneSubscribedURLs(URL subscribedURL, Collection<ServiceInsta

return clonedURLBuilder.build();
})
.forEach(clonedURLs::add);
.forEach(clonedExportedURLs::add);
});
return clonedURLs;
return clonedExportedURLs;
}


Expand All @@ -461,7 +491,7 @@ private ServiceInstance selectServiceInstance(List<ServiceInstance> serviceInsta
}

/**
* Get the template {@link URL urls} from the specified {@link ServiceInstance}.
* Get the template exported {@link URL urls} from the specified {@link ServiceInstance}.
* <p>
* First, put the revision {@link ServiceInstance service instance}
* associating {@link #getExportedURLs(URL, ServiceInstance) exported URLs} into cache.
Expand All @@ -478,7 +508,7 @@ private ServiceInstance selectServiceInstance(List<ServiceInstance> serviceInsta
* associating with the {@link URL urls}
* @return non-null {@link List} of {@link URL urls}
*/
protected List<URL> getTemplateURLs(URL subscribedURL, ServiceInstance selectedInstance) {
private List<URL> getTemplateExportedURLs(URL subscribedURL, ServiceInstance selectedInstance) {

List<URL> exportedURLs = getRevisionExportedURLs(selectedInstance);

Expand Down Expand Up @@ -655,6 +685,21 @@ protected List<URL> getExportedURLs(URL subscribedURL, ServiceInstance providerS
return exportedURLs;
}

/**
* Synthesize new subscribed {@link URL URLs} from old one
*
* @param subscribedURL
* @param serviceInstances
* @return non-null
*/
private Collection<? extends URL> synthesizeSubscribedURLs(URL subscribedURL, Collection<ServiceInstance> serviceInstances) {
return subscribedURLsSynthesizers.stream()
.filter(synthesizer -> synthesizer.supports(subscribedURL))
.map(synthesizer -> synthesizer.synthesize(subscribedURL, serviceInstances))
.flatMap(Collection::stream)
.collect(Collectors.toList());
}


protected Set<String> getServices(URL subscribedURL) {
Set<String> serviceNames = getSubscribedServices();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* 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.metadata;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.registry.client.ServiceInstance;
import org.apache.dubbo.rpc.Protocol;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static java.lang.Boolean.TRUE;
import static org.apache.dubbo.common.constants.CommonConstants.PID_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER;
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.RegistryConstants.CATEGORY_KEY;
import static org.apache.dubbo.registry.Constants.REGISTER_KEY;
import static org.apache.dubbo.rpc.Constants.LAZY_CONNECT_KEY;
import static org.apache.dubbo.rpc.cluster.Constants.CLUSTER_STICKY_KEY;

/**
* {@link SubscribedURLsSynthesizer} implementation for REST {@link Protocol protocol}
*
* @since 2.7.4
*/
public class RestProtocolSubscribedURLsSynthesizer implements SubscribedURLsSynthesizer {

@Override
public boolean supports(URL subscribedURL) {
return "rest".equals(subscribedURL.getProtocol()) ||
"rest".equals(subscribedURL.getParameter(PROTOCOL_KEY));
}

@Override
public List<URL> synthesize(URL subscribedURL, Collection<ServiceInstance> serviceInstances) {

String protocol = subscribedURL.getParameter(PROTOCOL_KEY);

Map<String, String> parametersToCopy = subscribedURL.removeParameter(CATEGORY_KEY)
.removeParameter(PROTOCOL_KEY)
.removeParameter(SIDE_KEY)
.removeParameter(CLUSTER_STICKY_KEY)
.removeParameter(TIMESTAMP_KEY)
.removeParameter(PID_KEY)
.removeParameter(LAZY_CONNECT_KEY)
.getParameters();

return serviceInstances.stream().map(serviceInstance -> {
URLBuilder urlBuilder = new URLBuilder()
.setProtocol(protocol)
.setHost(serviceInstance.getHost())
.setPort(serviceInstance.getPort())
.setPath(subscribedURL.getServiceInterface())
.addParameter(SIDE_KEY, PROVIDER)
.addParameter(REGISTER_KEY, TRUE.toString());

// Copy the parameters
parametersToCopy.forEach((key, value) -> {
urlBuilder.addParameter(key, value);
});

return urlBuilder.build();
}).collect(Collectors.toList());
}

private void addParameter(URLBuilder urlBuilder, String key, String value) {
if (StringUtils.isNotEmpty(value)) {
urlBuilder.addParameter(key, value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.metadata;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.lang.Prioritized;
import org.apache.dubbo.registry.NotifyListener;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.client.ServiceInstance;

import java.util.Collection;
import java.util.List;

/**
* The inteface to synthesize the subscribed {@link URL URLs}
*
* @since 2.7.4
*/
public interface SubscribedURLsSynthesizer extends Prioritized {

/**
* Supports the synthesis of the subscribed {@link URL URLs} or not
*
* @param subscribedURL the original subscribed {@link URL} from the execution of`
* {@link Registry#subscribe(URL, NotifyListener)} method
* @return if supports, return <code>true</code>, or <code>false</code>
*/
boolean supports(URL subscribedURL);

/**
* synthesize the subscribed {@link URL URLs}
*
* @param subscribedURL the original subscribed {@link URL} from the execution of`
* {@link Registry#subscribe(URL, NotifyListener)} method
* @param serviceInstances
* @return
*/
List<URL> synthesize(URL subscribedURL, Collection<ServiceInstance> serviceInstances);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.dubbo.registry.client.metadata.RestProtocolSubscribedURLsSynthesizer

0 comments on commit edd37e3

Please sign in to comment.