test_class.declarator: url
test_class.modifier: private
test_class.original_string: private URL url;
test_class.type: URL
test_class.var_name: url
test_class.declarator: consulServiceDiscovery
test_class.modifier: private
test_class.original_string: private ConsulServiceDiscovery consulServiceDiscovery;
test_class.type: ConsulServiceDiscovery
test_class.var_name: consulServiceDiscovery
test_class.declarator: consul
test_class.modifier: private
test_class.original_string: private ConsulProcess consul;
test_class.type: ConsulProcess
test_class.var_name: consul
test_class.declarator: SERVICE_NAME = "A"
test_class.modifier: private static final
test_class.original_string: private static final String SERVICE_NAME = "A";
test_class.type: String
test_class.var_name: SERVICE_NAME
test_class.declarator: LOCALHOST = "127.0.0.1"
test_class.modifier: private static final
test_class.original_string: private static final String LOCALHOST = "127.0.0.1";
test_class.type: String
test_class.var_name: LOCALHOST
test_class.file: dubbo-registry/dubbo-registry-consul/src/test/java/org/apache/dubbo/registry/consul/ConsulServiceDiscoveryTest.java
test_class.identifier: ConsulServiceDiscoveryTest
test_case.body: @Test
      public void testGetInstances() throws Exception {
          String serviceName = "ConsulTest77Service";
          assertTrue(consulServiceDiscovery.getInstances(serviceName).isEmpty());
          int portA = NetUtils.getAvailablePort();
          int portB = NetUtils.getAvailablePort();
          consulServiceDiscovery.register(new DefaultServiceInstance(valueOf(System.nanoTime()), serviceName, "127.0.0.1", portA));
          consulServiceDiscovery.register(new DefaultServiceInstance(valueOf(System.nanoTime()), serviceName, "127.0.0.1", portB));
          Thread.sleep(5000);
          Assertions.assertFalse(consulServiceDiscovery.getInstances(serviceName).isEmpty());
          List<String> r = convertToIpPort(consulServiceDiscovery.getInstances(serviceName));
          assertTrue(r.contains("127.0.0.1:" + portA));
          assertTrue(r.contains("127.0.0.1:" + portB));
      }
test_case.class_method_signature: ConsulServiceDiscoveryTest.testGetInstances()
test_case.full_signature: @Test public void testGetInstances()
test_case.identifier: testGetInstances
test_case.invocations: assertTrue isEmpty getInstances getAvailablePort getAvailablePort register valueOf nanoTime register valueOf nanoTime sleep assertFalse isEmpty getInstances convertToIpPort getInstances assertTrue contains assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetInstances()
focal_class.declarator: logger = LoggerFactory.getLogger(ConsulServiceDiscovery.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(ConsulServiceDiscovery.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: QUERY_TAG = "consul_query_tag"
focal_class.modifier: private static final
focal_class.original_string: private static final String QUERY_TAG = "consul_query_tag";
focal_class.type: String
focal_class.var_name: QUERY_TAG
focal_class.declarator: REGISTER_TAG = "consul_register_tag"
focal_class.modifier: private static final
focal_class.original_string: private static final String REGISTER_TAG = "consul_register_tag";
focal_class.type: String
focal_class.var_name: REGISTER_TAG
focal_class.declarator: registeringTags = new ArrayList<>()
focal_class.modifier: private
focal_class.original_string: private List<String> registeringTags = new ArrayList<>();
focal_class.type: List<String>
focal_class.var_name: registeringTags
focal_class.declarator: tag
focal_class.modifier: private
focal_class.original_string: private String tag;
focal_class.type: String
focal_class.var_name: tag
focal_class.declarator: client
focal_class.modifier: private
focal_class.original_string: private ConsulClient client;
focal_class.type: ConsulClient
focal_class.var_name: client
focal_class.declarator: notifierExecutor = newCachedThreadPool(
              new NamedThreadFactory("dubbo-service-discovery-consul-notifier", true))
focal_class.modifier: private
focal_class.original_string: private ExecutorService notifierExecutor = newCachedThreadPool(
              new NamedThreadFactory("dubbo-service-discovery-consul-notifier", true));
focal_class.type: ExecutorService
focal_class.var_name: notifierExecutor
focal_class.declarator: notifiers = new ConcurrentHashMap<>()
focal_class.modifier: private
focal_class.original_string: private Map<String, ConsulNotifier> notifiers = new ConcurrentHashMap<>();
focal_class.type: Map<String, ConsulNotifier>
focal_class.var_name: notifiers
focal_class.declarator: ttlSchedulers = new ConcurrentHashMap<>()
focal_class.modifier: private
focal_class.original_string: private Map<String, TtlScheduler> ttlSchedulers = new ConcurrentHashMap<>();
focal_class.type: Map<String, TtlScheduler>
focal_class.var_name: ttlSchedulers
focal_class.declarator: checkPassInterval
focal_class.modifier: private
focal_class.original_string: private long checkPassInterval;
focal_class.type: long
focal_class.var_name: checkPassInterval
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: aclToken
focal_class.modifier: private
focal_class.original_string: private String aclToken;
focal_class.type: String
focal_class.var_name: aclToken
focal_class.declarator: tags
focal_class.modifier: private
focal_class.original_string: private List<String> tags;
focal_class.type: List<String>
focal_class.var_name: tags
focal_class.declarator: consistencyMode
focal_class.modifier: private
focal_class.original_string: private ConsistencyMode consistencyMode;
focal_class.type: ConsistencyMode
focal_class.var_name: consistencyMode
focal_class.declarator: defaultZoneMetadataName
focal_class.modifier: private
focal_class.original_string: private String defaultZoneMetadataName;
focal_class.type: String
focal_class.var_name: defaultZoneMetadataName
focal_class.declarator: instanceZone
focal_class.modifier: private
focal_class.original_string: private String instanceZone;
focal_class.type: String
focal_class.var_name: instanceZone
focal_class.declarator: instanceGroup
focal_class.modifier: private
focal_class.original_string: private String instanceGroup;
focal_class.type: String
focal_class.var_name: instanceGroup
focal_class.file: dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscovery.java
focal_class.identifier: ConsulServiceDiscovery
focal_class.interfaces: implements EventListener<ServiceInstancesChangedEvent>
focal_class.class_method_signature: ConsulServiceDiscovery.onEvent(ServiceInstancesChangedEvent event)
focal_class.full_signature: @Override public void onEvent(ServiceInstancesChangedEvent event)
focal_class.identifier: onEvent
focal_class.modifiers: @Override public
focal_class.parameters: (ServiceInstancesChangedEvent event)
focal_class.return: void
focal_class.signature: void onEvent(ServiceInstancesChangedEvent event)
focal_class.class_method_signature: ConsulServiceDiscovery.initialize(URL registryURL)
focal_class.full_signature: @Override public void initialize(URL registryURL)
focal_class.identifier: initialize
focal_class.modifiers: @Override public
focal_class.parameters: (URL registryURL)
focal_class.return: void
focal_class.signature: void initialize(URL registryURL)
focal_class.class_method_signature: ConsulServiceDiscovery.getConsistencyMode(URL registryURL)
focal_class.full_signature: private ConsistencyMode getConsistencyMode(URL registryURL)
focal_class.identifier: getConsistencyMode
focal_class.modifiers: private
focal_class.parameters: (URL registryURL)
focal_class.return: ConsistencyMode
focal_class.signature: ConsistencyMode getConsistencyMode(URL registryURL)
focal_class.class_method_signature: ConsulServiceDiscovery.getTags(URL registryURL)
focal_class.full_signature: private List<String> getTags(URL registryURL)
focal_class.identifier: getTags
focal_class.modifiers: private
focal_class.parameters: (URL registryURL)
focal_class.return: List<String>
focal_class.signature: List<String> getTags(URL registryURL)
focal_class.class_method_signature: ConsulServiceDiscovery.getUrl()
focal_class.full_signature: @Override public URL getUrl()
focal_class.identifier: getUrl
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: URL
focal_class.signature: URL getUrl()
focal_class.class_method_signature: ConsulServiceDiscovery.getRegisteringTags(URL url)
focal_class.full_signature: private List<String> getRegisteringTags(URL url)
focal_class.identifier: getRegisteringTags
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: List<String>
focal_class.signature: List<String> getRegisteringTags(URL url)
focal_class.class_method_signature: ConsulServiceDiscovery.destroy()
focal_class.full_signature: @Override public void destroy()
focal_class.identifier: destroy
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void destroy()
focal_class.class_method_signature: ConsulServiceDiscovery.register(ServiceInstance serviceInstance)
focal_class.full_signature: @Override public void register(ServiceInstance serviceInstance)
focal_class.identifier: register
focal_class.modifiers: @Override public
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: void
focal_class.signature: void register(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.addServiceInstancesChangedListener(ServiceInstancesChangedListener listener)
focal_class.full_signature: @Override public void addServiceInstancesChangedListener(ServiceInstancesChangedListener listener)
focal_class.identifier: addServiceInstancesChangedListener
focal_class.modifiers: @Override public
focal_class.parameters: (ServiceInstancesChangedListener listener)
focal_class.return: void
focal_class.signature: void addServiceInstancesChangedListener(ServiceInstancesChangedListener listener)
focal_class.class_method_signature: ConsulServiceDiscovery.update(ServiceInstance serviceInstance)
focal_class.full_signature: @Override public void update(ServiceInstance serviceInstance)
focal_class.identifier: update
focal_class.modifiers: @Override public
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: void
focal_class.signature: void update(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.unregister(ServiceInstance serviceInstance)
focal_class.full_signature: @Override public void unregister(ServiceInstance serviceInstance)
focal_class.identifier: unregister
focal_class.modifiers: @Override public
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: void
focal_class.signature: void unregister(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.getServices()
focal_class.full_signature: @Override public Set<String> getServices()
focal_class.identifier: getServices
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Set<String>
focal_class.signature: Set<String> getServices()
focal_class.class_method_signature: ConsulServiceDiscovery.getInstances(String serviceName)
focal_class.full_signature: @Override public List<ServiceInstance> getInstances(String serviceName)
focal_class.identifier: getInstances
focal_class.modifiers: @Override public
focal_class.parameters: (String serviceName)
focal_class.return: List<ServiceInstance>
focal_class.signature: List<ServiceInstance> getInstances(String serviceName)
focal_class.class_method_signature: ConsulServiceDiscovery.convert(List<HealthService> services)
focal_class.full_signature: private List<ServiceInstance> convert(List<HealthService> services)
focal_class.identifier: convert
focal_class.modifiers: private
focal_class.parameters: (List<HealthService> services)
focal_class.return: List<ServiceInstance>
focal_class.signature: List<ServiceInstance> convert(List<HealthService> services)
focal_class.class_method_signature: ConsulServiceDiscovery.getHealthServices(String service, long index, int watchTimeout)
focal_class.full_signature: private Response<List<HealthService>> getHealthServices(String service, long index, int watchTimeout)
focal_class.identifier: getHealthServices
focal_class.modifiers: private
focal_class.parameters: (String service, long index, int watchTimeout)
focal_class.return: Response<List<HealthService>>
focal_class.signature: Response<List<HealthService>> getHealthServices(String service, long index, int watchTimeout)
focal_class.class_method_signature: ConsulServiceDiscovery.getMetadata(HealthService.Service service)
focal_class.full_signature: private Map<String, String> getMetadata(HealthService.Service service)
focal_class.identifier: getMetadata
focal_class.modifiers: private
focal_class.parameters: (HealthService.Service service)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getMetadata(HealthService.Service service)
focal_class.class_method_signature: ConsulServiceDiscovery.getScCompatibleMetadata(List<String> tags)
focal_class.full_signature: private Map<String, String> getScCompatibleMetadata(List<String> tags)
focal_class.identifier: getScCompatibleMetadata
focal_class.modifiers: private
focal_class.parameters: (List<String> tags)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getScCompatibleMetadata(List<String> tags)
focal_class.class_method_signature: ConsulServiceDiscovery.buildService(ServiceInstance serviceInstance)
focal_class.full_signature: private NewService buildService(ServiceInstance serviceInstance)
focal_class.identifier: buildService
focal_class.modifiers: private
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: NewService
focal_class.signature: NewService buildService(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.buildId(ServiceInstance serviceInstance)
focal_class.full_signature: private String buildId(ServiceInstance serviceInstance)
focal_class.identifier: buildId
focal_class.modifiers: private
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: String
focal_class.signature: String buildId(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.buildTags(ServiceInstance serviceInstance)
focal_class.full_signature: private List<String> buildTags(ServiceInstance serviceInstance)
focal_class.identifier: buildTags
focal_class.modifiers: private
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: List<String>
focal_class.signature: List<String> buildTags(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.buildMetadata(ServiceInstance serviceInstance)
focal_class.full_signature: private Map<String, String> buildMetadata(ServiceInstance serviceInstance)
focal_class.identifier: buildMetadata
focal_class.modifiers: private
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> buildMetadata(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.encodeMetadata(Map<String, String> metadata)
focal_class.full_signature: private Map<String, String> encodeMetadata(Map<String, String> metadata)
focal_class.identifier: encodeMetadata
focal_class.modifiers: private
focal_class.parameters: (Map<String, String> metadata)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> encodeMetadata(Map<String, String> metadata)
focal_class.class_method_signature: ConsulServiceDiscovery.decodeMetadata(Map<String, String> metadata)
focal_class.full_signature: private Map<String, String> decodeMetadata(Map<String, String> metadata)
focal_class.identifier: decodeMetadata
focal_class.modifiers: private
focal_class.parameters: (Map<String, String> metadata)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> decodeMetadata(Map<String, String> metadata)
focal_class.class_method_signature: ConsulServiceDiscovery.buildCheck(ServiceInstance serviceInstance)
focal_class.full_signature: private NewService.Check buildCheck(ServiceInstance serviceInstance)
focal_class.identifier: buildCheck
focal_class.modifiers: private
focal_class.parameters: (ServiceInstance serviceInstance)
focal_class.return: NewService.Check
focal_class.signature: NewService.Check buildCheck(ServiceInstance serviceInstance)
focal_class.class_method_signature: ConsulServiceDiscovery.buildWatchTimeout()
focal_class.full_signature: private int buildWatchTimeout()
focal_class.identifier: buildWatchTimeout
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int buildWatchTimeout()
focal_class.superclass: extends AbstractServiceDiscovery
focal_method.body: @Override
      public List<ServiceInstance> getInstances(String serviceName) throws NullPointerException {
          Response<List<HealthService>> response = getHealthServices(serviceName, -1, buildWatchTimeout());
          Long consulIndex = response.getConsulIndex();
  
          ConsulNotifier notifier = notifiers.get(serviceName);
          if (notifier == null) {
              notifier = new ConsulNotifier(serviceName, consulIndex);
              notifiers.put(serviceName, notifier);
          }
          return convert(response.getValue());
      }
focal_method.class_method_signature: ConsulServiceDiscovery.getInstances(String serviceName)
focal_method.full_signature: @Override public List<ServiceInstance> getInstances(String serviceName)
focal_method.identifier: getInstances
focal_method.invocations: getHealthServices buildWatchTimeout getConsulIndex get put convert getValue
focal_method.modifiers: @Override public
focal_method.parameters: (String serviceName)
focal_method.return: List<ServiceInstance>
focal_method.signature: List<ServiceInstance> getInstances(String serviceName)