|
|
@ -40,7 +40,6 @@ import org.apache.dubbo.common.URL;
|
|
|
|
import org.apache.dubbo.registry.NotifyListener;
|
|
|
|
import org.apache.dubbo.registry.NotifyListener;
|
|
|
|
import org.apache.dubbo.registry.RegistryFactory;
|
|
|
|
import org.apache.dubbo.registry.RegistryFactory;
|
|
|
|
import org.apache.dubbo.registry.support.FailbackRegistry;
|
|
|
|
import org.apache.dubbo.registry.support.FailbackRegistry;
|
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.cloud.client.ServiceInstance;
|
|
|
|
import org.springframework.cloud.client.ServiceInstance;
|
|
|
@ -215,6 +214,33 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
|
|
|
|
generateId(url), serviceName);
|
|
|
|
generateId(url), serviceName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<URL> allSubscribedURLs = new LinkedList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collection<ServiceInstance> serviceInstances = serviceInstancesFunction
|
|
|
|
|
|
|
|
.apply(serviceName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(serviceInstances)) {
|
|
|
|
|
|
|
|
dubboMetadataConfigServiceProxy.removeProxy(serviceName);
|
|
|
|
|
|
|
|
repository.removeInitializedService(serviceName);
|
|
|
|
|
|
|
|
repository.removeServiceMetadata(serviceName);
|
|
|
|
|
|
|
|
if (logger.isWarnEnabled()) {
|
|
|
|
|
|
|
|
logger.warn(
|
|
|
|
|
|
|
|
"There is no instance from service[name : {}], and then Dubbo Service[key : {}] will not be "
|
|
|
|
|
|
|
|
+ "available , please make sure the further impact",
|
|
|
|
|
|
|
|
serviceName, url.getServiceKey());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* URLs with {@link RegistryConstants#EMPTY_PROTOCOL}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
allSubscribedURLs.addAll(emptyURLs(url));
|
|
|
|
|
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
|
|
|
|
|
logger.debug("The subscribed URL[{}] will notify all URLs : {}", url,
|
|
|
|
|
|
|
|
allSubscribedURLs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
listener.notify(allSubscribedURLs);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DubboMetadataService dubboMetadataService = dubboMetadataConfigServiceProxy
|
|
|
|
DubboMetadataService dubboMetadataService = dubboMetadataConfigServiceProxy
|
|
|
|
.getProxy(serviceName);
|
|
|
|
.getProxy(serviceName);
|
|
|
|
|
|
|
|
|
|
|
@ -239,50 +265,30 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Collection<ServiceInstance> serviceInstances = serviceInstancesFunction
|
|
|
|
List<URL> exportedURLs = getExportedURLs(dubboMetadataService, url);
|
|
|
|
.apply(serviceName);
|
|
|
|
|
|
|
|
|
|
|
|
for (URL exportedURL : exportedURLs) {
|
|
|
|
List<URL> allSubscribedURLs = new LinkedList<>();
|
|
|
|
String protocol = exportedURL.getProtocol();
|
|
|
|
|
|
|
|
List<URL> subscribedURLs = new LinkedList<>();
|
|
|
|
if (CollectionUtils.isEmpty(serviceInstances)) {
|
|
|
|
serviceInstances.forEach(serviceInstance -> {
|
|
|
|
if (logger.isWarnEnabled()) {
|
|
|
|
Integer port = repository.getDubboProtocolPort(serviceInstance, protocol);
|
|
|
|
logger.warn(
|
|
|
|
String host = serviceInstance.getHost();
|
|
|
|
"There is no instance from service[name : {}], and then Dubbo Service[key : {}] will not be "
|
|
|
|
if (port == null) {
|
|
|
|
+ "available , please make sure the further impact",
|
|
|
|
if (logger.isWarnEnabled()) {
|
|
|
|
serviceName, url.getServiceKey());
|
|
|
|
logger.warn(
|
|
|
|
}
|
|
|
|
"The protocol[{}] port of Dubbo service instance[host : {}] "
|
|
|
|
/**
|
|
|
|
+ "can't be resolved",
|
|
|
|
* URLs with {@link RegistryConstants#EMPTY_PROTOCOL}
|
|
|
|
protocol, host);
|
|
|
|
*/
|
|
|
|
|
|
|
|
allSubscribedURLs.addAll(emptyURLs(url));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
List<URL> exportedURLs = getExportedURLs(dubboMetadataService, url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (URL exportedURL : exportedURLs) {
|
|
|
|
|
|
|
|
String protocol = exportedURL.getProtocol();
|
|
|
|
|
|
|
|
List<URL> subscribedURLs = new LinkedList<>();
|
|
|
|
|
|
|
|
serviceInstances.forEach(serviceInstance -> {
|
|
|
|
|
|
|
|
Integer port = repository.getDubboProtocolPort(serviceInstance,
|
|
|
|
|
|
|
|
protocol);
|
|
|
|
|
|
|
|
String host = serviceInstance.getHost();
|
|
|
|
|
|
|
|
if (port == null) {
|
|
|
|
|
|
|
|
if (logger.isWarnEnabled()) {
|
|
|
|
|
|
|
|
logger.warn(
|
|
|
|
|
|
|
|
"The protocol[{}] port of Dubbo service instance[host : {}] "
|
|
|
|
|
|
|
|
+ "can't be resolved",
|
|
|
|
|
|
|
|
protocol, host);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
URL subscribedURL = new URL(protocol, host, port,
|
|
|
|
|
|
|
|
exportedURL.getParameters());
|
|
|
|
|
|
|
|
subscribedURLs.add(subscribedURL);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
allSubscribedURLs.addAll(subscribedURLs);
|
|
|
|
URL subscribedURL = new URL(protocol, host, port,
|
|
|
|
}
|
|
|
|
exportedURL.getParameters());
|
|
|
|
|
|
|
|
subscribedURLs.add(subscribedURL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allSubscribedURLs.addAll(subscribedURLs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
|