public ServiceSelector createServiceSelector(String type, ServiceSelectorConfig selectorConfig) { requireNonNull(type, "type is null"); requireNonNull(selectorConfig, "selectorConfig is null"); CachingServiceSelector serviceSelector = new CachingServiceSelector(type, selectorConfig, lookupClient, executor); serviceSelector.start(); return serviceSelector; } }
public ServiceSelector createServiceSelector(String type, ServiceSelectorConfig selectorConfig) { Preconditions.checkNotNull(type, "type is null"); Preconditions.checkNotNull(selectorConfig, "selectorConfig is null"); CachingServiceSelector serviceSelector = new CachingServiceSelector(type, selectorConfig, lookupClient, executor); serviceSelector.start(); return serviceSelector; } }
public ServiceSelector createServiceSelector(String type, ServiceSelectorConfig selectorConfig) { Preconditions.checkNotNull(type, "type is null"); Preconditions.checkNotNull(selectorConfig, "selectorConfig is null"); CachingServiceSelector serviceSelector = new CachingServiceSelector(type, selectorConfig, lookupClient, executor); serviceSelector.start(); return serviceSelector; } }
@Test public void testNotStartedEmpty() { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); Assert.assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testNotStartedEmpty() { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testNotStartedEmpty() { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testBasics() { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); assertEquals(serviceSelector.getType(), "type"); assertEquals(serviceSelector.getPool(), "pool"); }
@Test public void testStartedEmpty() throws Exception { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); serviceSelector.start(); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testBasics() { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); Assert.assertEquals(serviceSelector.getType(), "type"); Assert.assertEquals(serviceSelector.getPool(), "pool"); }
@Test public void testStartedEmpty() throws Exception { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); serviceSelector.start(); Assert.assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testStartedEmpty() throws Exception { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); serviceSelector.start(); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testBasics() { CachingServiceSelector serviceSelector = new CachingServiceSelector("type", new ServiceSelectorConfig().setPool("pool"), new InMemoryDiscoveryClient(nodeInfo), executor); assertEquals(serviceSelector.getType(), "type"); assertEquals(serviceSelector.getPool(), "pool"); }
@Test public void testNotStartedWithServices() { InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo); discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testNotStartedWithServices() { InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo); discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor); assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testNotStartedWithServices() { InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo); discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor); Assert.assertEquals(serviceSelector.selectAllServices(), ImmutableList.of()); }
@Test public void testStartedWithServices() throws Exception { InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo); discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor); serviceSelector.start(); Thread.sleep(100); Assertions.assertEqualsIgnoreOrder(serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE)); } }
@Test public void testStartedWithServices() throws Exception { InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo); discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor); serviceSelector.start(); Thread.sleep(100); assertEqualsIgnoreOrder(serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE)); } }
@Test public void testStartedWithServices() throws Exception { InMemoryDiscoveryClient discoveryClient = new InMemoryDiscoveryClient(nodeInfo); discoveryClient.addDiscoveredService(APPLE_1_SERVICE); discoveryClient.addDiscoveredService(APPLE_2_SERVICE); discoveryClient.addDiscoveredService(DIFFERENT_TYPE); discoveryClient.addDiscoveredService(DIFFERENT_POOL); CachingServiceSelector serviceSelector = new CachingServiceSelector("apple", new ServiceSelectorConfig().setPool("pool"), discoveryClient, executor); serviceSelector.start(); Thread.sleep(100); assertEqualsIgnoreOrder(serviceSelector.selectAllServices(), ImmutableList.of(APPLE_1_SERVICE, APPLE_2_SERVICE)); } }