test_class.file: dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListenerTest.java
test_class.identifier: ServiceInstancesChangedListenerTest
test_case.body: @Test
      public void testOnEvent() {
  
      }
test_case.class_method_signature: ServiceInstancesChangedListenerTest.testOnEvent()
test_case.full_signature: @Test public void testOnEvent()
test_case.identifier: testOnEvent
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testOnEvent()
focal_class.declarator: logger = LoggerFactory.getLogger(ServiceInstancesChangedListener.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ServiceInstancesChangedListener.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: serviceNames
focal_class.modifier: private final
focal_class.original_string: private final Set<String> serviceNames;
focal_class.type: Set<String>
focal_class.var_name: serviceNames
focal_class.declarator: serviceDiscovery
focal_class.modifier: private final
focal_class.original_string: private final ServiceDiscovery serviceDiscovery;
focal_class.type: ServiceDiscovery
focal_class.var_name: serviceDiscovery
focal_class.declarator: url
focal_class.modifier: private
focal_class.original_string: private URL url;
focal_class.type: URL
focal_class.var_name: url
focal_class.declarator: listeners
focal_class.modifier: private
focal_class.original_string: private Map<String, NotifyListener> listeners;
focal_class.type: Map<String, NotifyListener>
focal_class.var_name: listeners
focal_class.declarator: allInstances
focal_class.modifier: private
focal_class.original_string: private Map<String, List<ServiceInstance>> allInstances;
focal_class.type: Map<String, List<ServiceInstance>>
focal_class.var_name: allInstances
focal_class.declarator: serviceUrls
focal_class.modifier: private
focal_class.original_string: private Map<String, List<URL>> serviceUrls;
focal_class.type: Map<String, List<URL>>
focal_class.var_name: serviceUrls
focal_class.declarator: revisionToMetadata
focal_class.modifier: private
focal_class.original_string: private Map<String, MetadataInfo> revisionToMetadata;
focal_class.type: Map<String, MetadataInfo>
focal_class.var_name: revisionToMetadata
focal_class.file: dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
focal_class.identifier: ServiceInstancesChangedListener
focal_class.interfaces: implements ConditionalEventListener<ServiceInstancesChangedEvent>
focal_class.class_method_signature: ServiceInstancesChangedListener.ServiceInstancesChangedListener(Set<String> serviceNames, ServiceDiscovery serviceDiscovery)
focal_class.full_signature: public  ServiceInstancesChangedListener(Set<String> serviceNames, ServiceDiscovery serviceDiscovery)
focal_class.identifier: ServiceInstancesChangedListener
focal_class.modifiers: public
focal_class.parameters: (Set<String> serviceNames, ServiceDiscovery serviceDiscovery)
focal_class.signature:  ServiceInstancesChangedListener(Set<String> serviceNames, ServiceDiscovery serviceDiscovery)
focal_class.class_method_signature: ServiceInstancesChangedListener.onEvent(ServiceInstancesChangedEvent event)
focal_class.full_signature: public synchronized void onEvent(ServiceInstancesChangedEvent event)
focal_class.identifier: onEvent
focal_class.modifiers: public synchronized
focal_class.parameters: (ServiceInstancesChangedEvent event)
focal_class.return: void
focal_class.signature: void onEvent(ServiceInstancesChangedEvent event)
focal_class.class_method_signature: ServiceInstancesChangedListener.parseMetadata(String revision, MetadataInfo metadata, Map<String, Set<String>> localServiceToRevisions)
focal_class.full_signature: private Map<String, Set<String>> parseMetadata(String revision, MetadataInfo metadata, Map<String, Set<String>> localServiceToRevisions)
focal_class.identifier: parseMetadata
focal_class.modifiers: private
focal_class.parameters: (String revision, MetadataInfo metadata, Map<String, Set<String>> localServiceToRevisions)
focal_class.return: Map<String, Set<String>>
focal_class.signature: Map<String, Set<String>> parseMetadata(String revision, MetadataInfo metadata, Map<String, Set<String>> localServiceToRevisions)
focal_class.class_method_signature: ServiceInstancesChangedListener.getMetadataInfo(ServiceInstance instance)
focal_class.full_signature: private MetadataInfo getMetadataInfo(ServiceInstance instance)
focal_class.identifier: getMetadataInfo
focal_class.modifiers: private
focal_class.parameters: (ServiceInstance instance)
focal_class.return: MetadataInfo
focal_class.signature: MetadataInfo getMetadataInfo(ServiceInstance instance)
focal_class.class_method_signature: ServiceInstancesChangedListener.notifyAddressChanged()
focal_class.full_signature: private void notifyAddressChanged()
focal_class.identifier: notifyAddressChanged
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void notifyAddressChanged()
focal_class.class_method_signature: ServiceInstancesChangedListener.toUrlsWithEmpty(List<URL> urls)
focal_class.full_signature: private List<URL> toUrlsWithEmpty(List<URL> urls)
focal_class.identifier: toUrlsWithEmpty
focal_class.modifiers: private
focal_class.parameters: (List<URL> urls)
focal_class.return: List<URL>
focal_class.signature: List<URL> toUrlsWithEmpty(List<URL> urls)
focal_class.class_method_signature: ServiceInstancesChangedListener.addListener(String serviceKey, NotifyListener listener)
focal_class.full_signature: public void addListener(String serviceKey, NotifyListener listener)
focal_class.identifier: addListener
focal_class.modifiers: public
focal_class.parameters: (String serviceKey, NotifyListener listener)
focal_class.return: void
focal_class.signature: void addListener(String serviceKey, NotifyListener listener)
focal_class.class_method_signature: ServiceInstancesChangedListener.getUrls(String serviceKey)
focal_class.full_signature: public List<URL> getUrls(String serviceKey)
focal_class.identifier: getUrls
focal_class.modifiers: public
focal_class.parameters: (String serviceKey)
focal_class.return: List<URL>
focal_class.signature: List<URL> getUrls(String serviceKey)
focal_class.class_method_signature: ServiceInstancesChangedListener.getServiceNames()
focal_class.full_signature: public final Set<String> getServiceNames()
focal_class.identifier: getServiceNames
focal_class.modifiers: public final
focal_class.parameters: ()
focal_class.return: Set<String>
focal_class.signature: Set<String> getServiceNames()
focal_class.class_method_signature: ServiceInstancesChangedListener.setUrl(URL url)
focal_class.full_signature: public void setUrl(URL url)
focal_class.identifier: setUrl
focal_class.modifiers: public
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void setUrl(URL url)
focal_class.class_method_signature: ServiceInstancesChangedListener.getUrl()
focal_class.full_signature: public URL getUrl()
focal_class.identifier: getUrl
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: URL
focal_class.signature: URL getUrl()
focal_class.class_method_signature: ServiceInstancesChangedListener.accept(ServiceInstancesChangedEvent event)
focal_class.full_signature: public final boolean accept(ServiceInstancesChangedEvent event)
focal_class.identifier: accept
focal_class.modifiers: public final
focal_class.parameters: (ServiceInstancesChangedEvent event)
focal_class.return: boolean
focal_class.signature: boolean accept(ServiceInstancesChangedEvent event)
focal_class.class_method_signature: ServiceInstancesChangedListener.equals(Object o)
focal_class.full_signature: @Override public boolean equals(Object o)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: boolean
focal_class.signature: boolean equals(Object o)
focal_class.class_method_signature: ServiceInstancesChangedListener.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_method.body: public synchronized void onEvent(ServiceInstancesChangedEvent event) {
          logger.info("Received instance notification, serviceName: " + event.getServiceName() + ", instances: " + event.getServiceInstances().size());
          String appName = event.getServiceName();
          allInstances.put(appName, event.getServiceInstances());
  
          Map<String, List<ServiceInstance>> revisionToInstances = new HashMap<>();
          Map<String, Set<String>> localServiceToRevisions = new HashMap<>();
          Map<Set<String>, List<URL>> revisionsToUrls = new HashMap();
          for (Map.Entry<String, List<ServiceInstance>> entry : allInstances.entrySet()) {
              List<ServiceInstance> instances = entry.getValue();
              for (ServiceInstance instance : instances) {
                  String revision = getExportedServicesRevision(instance);
                  if (DEFAULT_REVISION.equals(revision)) {
                      logger.info("Find instance without valid service metadata: " + instance.getAddress());
                      continue;
                  }
                  List<ServiceInstance> subInstances = revisionToInstances.computeIfAbsent(revision, r -> new LinkedList<>());
                  subInstances.add(instance);
  
                  MetadataInfo metadata = revisionToMetadata.get(revision);
                  if (metadata == null) {
                      metadata = getMetadataInfo(instance);
                      logger.info("MetadataInfo for instance " + instance.getAddress() + "?revision=" + revision + " is " + metadata);
                      if (metadata != null) {
                          revisionToMetadata.put(revision, getMetadataInfo(instance));
                      } else {
  
                      }
                  }
  
                  if (metadata != null) {
                      parseMetadata(revision, metadata, localServiceToRevisions);
                      ((DefaultServiceInstance) instance).setServiceMetadata(metadata);
                  }
  //                else {
  //                    logger.error("Failed to load service metadata for instance " + instance);
  //                    Set<String> set = localServiceToRevisions.computeIfAbsent(url.getServiceKey(), k -> new TreeSet<>());
  //                    set.add(revision);
  //                }
  
                  localServiceToRevisions.forEach((serviceKey, revisions) -> {
                      List<URL> urls = revisionsToUrls.get(revisions);
                      if (urls != null) {
                          serviceUrls.put(serviceKey, urls);
                      } else {
                          urls = new ArrayList<>();
                          for (String r : revisions) {
                              for (ServiceInstance i : revisionToInstances.get(r)) {
                                  urls.add(i.toURL());
                              }
                          }
                          revisionsToUrls.put(revisions, urls);
                          serviceUrls.put(serviceKey, urls);
                      }
                  });
              }
          }
  
          this.notifyAddressChanged();
      }
focal_method.class_method_signature: ServiceInstancesChangedListener.onEvent(ServiceInstancesChangedEvent event)
focal_method.full_signature: public synchronized void onEvent(ServiceInstancesChangedEvent event)
focal_method.identifier: onEvent
focal_method.invocations: info getServiceName size getServiceInstances getServiceName put getServiceInstances entrySet getValue getExportedServicesRevision equals info getAddress computeIfAbsent add get getMetadataInfo info getAddress put getMetadataInfo parseMetadata setServiceMetadata forEach get put get add toURL put put notifyAddressChanged
focal_method.modifiers: public synchronized
focal_method.parameters: (ServiceInstancesChangedEvent event)
focal_method.return: void
focal_method.signature: void onEvent(ServiceInstancesChangedEvent event)