Search in sources :

Example 6 with Announcer

use of io.druid.curator.announcement.Announcer in project druid by druid-io.

the class ListenerResourceAnnouncerTest method testAnnouncerBehaves.

@Test
public void testAnnouncerBehaves() throws Exception {
    setupServerAndCurator();
    closerRule.closeLater(server);
    curator.start();
    closerRule.closeLater(curator);
    Assert.assertNotNull(curator.create().forPath("/druid"));
    Assert.assertTrue(curator.blockUntilConnected(10, TimeUnit.SECONDS));
    final Announcer announcer = new Announcer(curator, executorService);
    final HostAndPort node = HostAndPort.fromString("localhost");
    final ListenerResourceAnnouncer listenerResourceAnnouncer = new ListenerResourceAnnouncer(announcer, listeningAnnouncerConfig, listenerKey, node) {
    };
    listenerResourceAnnouncer.start();
    announcer.start();
    closerRule.closeLater(new Closeable() {

        @Override
        public void close() throws IOException {
            announcer.stop();
        }
    });
    Assert.assertNotNull(curator.checkExists().forPath(announcePath));
    final String nodePath = ZKPaths.makePath(announcePath, node.getHostText());
    Assert.assertNotNull(curator.checkExists().forPath(nodePath));
    Assert.assertEquals(Longs.BYTES, curator.getData().decompressed().forPath(nodePath).length);
    Assert.assertNull(curator.checkExists().forPath(listeningAnnouncerConfig.getAnnouncementPath(listenerKey + "FOO")));
    listenerResourceAnnouncer.stop();
    listenerResourceAnnouncer.start();
    listenerResourceAnnouncer.start();
    listenerResourceAnnouncer.stop();
    listenerResourceAnnouncer.stop();
    listenerResourceAnnouncer.start();
    listenerResourceAnnouncer.stop();
    listenerResourceAnnouncer.start();
    listenerResourceAnnouncer.stop();
    Assert.assertNull(curator.checkExists().forPath(nodePath));
}
Also used : HostAndPort(com.google.common.net.HostAndPort) Announcer(io.druid.curator.announcement.Announcer) Closeable(java.io.Closeable) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

Announcer (io.druid.curator.announcement.Announcer)6 ZkPathsConfig (io.druid.server.initialization.ZkPathsConfig)4 HostAndPort (com.google.common.net.HostAndPort)3 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)3 BatchDataSegmentAnnouncerConfig (io.druid.server.initialization.BatchDataSegmentAnnouncerConfig)3 IOException (java.io.IOException)3 Before (org.junit.Before)3 Test (org.junit.Test)3 PotentiallyGzippedCompressionProvider (io.druid.curator.PotentiallyGzippedCompressionProvider)2 BatchDataSegmentAnnouncer (io.druid.server.coordination.BatchDataSegmentAnnouncer)2 DruidServerMetadata (io.druid.server.coordination.DruidServerMetadata)2 DataSegment (io.druid.timeline.DataSegment)2 Closeable (java.io.Closeable)2 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)2 TestingCluster (org.apache.curator.test.TestingCluster)2 Predicate (com.google.common.base.Predicate)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 BatchServerInventoryView (io.druid.client.BatchServerInventoryView)1 DruidServer (io.druid.client.DruidServer)1 CacheConfig (io.druid.client.cache.CacheConfig)1