use of org.apache.dubbo.metadata.MappingChangedEvent in project dubbo by alibaba.
the class ZookeeperMetadataReport method addServiceMappingListener.
private List<String> addServiceMappingListener(String path, String serviceKey, MappingListener listener) {
ChildListener zkListener = new ChildListener() {
@Override
public void childChanged(String path, List<String> children) {
MappingChangedEvent event = new MappingChangedEvent();
event.setServiceKey(serviceKey);
event.setApps(null != children ? new HashSet<>(children) : null);
listener.onEvent(event);
}
};
List<String> childNodes = zkClient.addChildListener(path, zkListener);
listenerMap.put(path, zkListener);
return childNodes;
}
use of org.apache.dubbo.metadata.MappingChangedEvent 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