Search in sources :

Example 1 with ServiceDiscovery

use of org.apache.curator.x.discovery.ServiceDiscovery in project druid by druid-io.

the class ServiceAnnouncerTest method testServiceAnnouncement.

@Test
public void testServiceAnnouncement() throws Exception {
    curator.start();
    curator.blockUntilConnected();
    List<String> serviceNames = ImmutableList.of("druid/overlord", "druid/coordinator", "druid/firehose/tranquility_test-50-0000-0000");
    final ServiceDiscovery serviceDiscovery = createAndAnnounceServices(serviceNames);
    Assert.assertTrue(Iterators.all(serviceNames.iterator(), new Predicate<String>() {

        @Override
        public boolean apply(String input) {
            try {
                return serviceDiscovery.queryForInstances(input.replaceAll("/", ":")).size() == 1;
            } catch (Exception e) {
                throw new ISE("Something went wrong while finding instance with name [%s] in Service Discovery", input);
            }
        }
    }));
}
Also used : ISE(io.druid.java.util.common.ISE) ServiceDiscovery(org.apache.curator.x.discovery.ServiceDiscovery) Predicate(com.google.common.base.Predicate) Test(org.junit.Test)

Aggregations

Predicate (com.google.common.base.Predicate)1 ISE (io.druid.java.util.common.ISE)1 ServiceDiscovery (org.apache.curator.x.discovery.ServiceDiscovery)1 Test (org.junit.Test)1