optimize dubbo registry

pull/2101/head
theonefx 4 years ago
parent 479540c835
commit df2bced6f2

@ -245,6 +245,7 @@ public class DubboServiceMetadataRepository
@Override
public void afterSingletonsInstantiated() {
// inited by DubboCloudRegistry.preInit() @theonefx
// initializeMetadata();
}

@ -42,7 +42,6 @@ import org.apache.dubbo.registry.support.FailbackRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.context.ApplicationListener;
@ -154,6 +153,8 @@ public class DubboCloudRegistry extends FailbackRegistry
metadataSubscribeHandlerMap.forEach((url, handler) -> handler.init());
urlSubscribeHandlerMap.forEach((url, handler) -> handler.init());
repository.initializeMetadata();
// meke sure everything prepared, then can listening ServiceInstanceChangeEvent
applicationContext.addApplicationListener(this);
logger.info("DubboCloudRegistry preInit Done.");
@ -235,8 +236,9 @@ public class DubboCloudRegistry extends FailbackRegistry
String appName = event.getServiceName();
List<ServiceInstance> instances = filter(event.getServiceInstances() != null
? event.getServiceInstances() : Collections.emptyList());
List<ServiceInstance> instances = filter(
event.getServiceInstances() != null ? event.getServiceInstances()
: Collections.emptyList());
Set<String> subscribedServiceNames = getServices(null);

Loading…
Cancel
Save