use of org.apache.dubbo.metadata.MappingListener in project incubator-dubbo-ops by apache.
the class ConfigCenter method getServiceMapping.
@Bean
@DependsOn("metaDataCollector")
ServiceMapping getServiceMapping(ServiceDiscovery serviceDiscovery, InstanceRegistryCache instanceRegistryCache) {
ServiceMapping serviceMapping = new NoOpServiceMapping();
if (metadataUrl == null) {
return serviceMapping;
}
MappingListener mappingListener = new AdminMappingListener(serviceDiscovery, instanceRegistryCache);
serviceMapping = ExtensionLoader.getExtensionLoader(ServiceMapping.class).getExtension(metadataUrl.getProtocol());
serviceMapping.addMappingListener(mappingListener);
serviceMapping.init(metadataUrl);
return serviceMapping;
}
use of org.apache.dubbo.metadata.MappingListener in project incubator-dubbo-ops by apache.
the class ZookeeperServiceMapping method notifyMappingChangedEvent.
private void notifyMappingChangedEvent(String service) {
if (service.equals(Constants.CONFIGURATORS_CATEGORY) || service.equals(Constants.CONSUMERS_CATEGORY) || service.equals(Constants.PROVIDERS_CATEGORY) || service.equals(Constants.ROUTERS_CATEGORY)) {
return;
}
String servicePath = MAPPING_PATH + Constants.PATH_SEPARATOR + service;
String content = zkClient.getContent(servicePath);
if (content != null) {
Set<String> apps = getAppNames(content);
MappingChangedEvent event = new MappingChangedEvent(service, apps);
for (MappingListener listener : listeners) {
listener.onEvent(event);
}
}
}
Aggregations