Search in sources :

Example 1 with TestingCluster

use of org.apache.curator.test.TestingCluster in project druid by druid-io.

the class RemoteTaskRunnerFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    TestUtils testUtils = new TestUtils();
    jsonMapper = testUtils.getTestObjectMapper();
    testingCluster = new TestingCluster(1);
    testingCluster.start();
    cf = CuratorFrameworkFactory.builder().connectString(testingCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1, 10)).compressionProvider(new PotentiallyGzippedCompressionProvider(false)).build();
    cf.start();
    cf.blockUntilConnected();
}
Also used : TestUtils(io.druid.indexing.common.TestUtils) TestingCluster(org.apache.curator.test.TestingCluster) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) PotentiallyGzippedCompressionProvider(io.druid.curator.PotentiallyGzippedCompressionProvider) Before(org.junit.Before)

Example 2 with TestingCluster

use of org.apache.curator.test.TestingCluster in project druid by druid-io.

the class WorkerTaskMonitorTest method setUp.

@Before
public void setUp() throws Exception {
    testingCluster = new TestingCluster(1);
    testingCluster.start();
    cf = CuratorFrameworkFactory.builder().connectString(testingCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1, 10)).compressionProvider(new PotentiallyGzippedCompressionProvider(false)).build();
    cf.start();
    cf.blockUntilConnected();
    cf.create().creatingParentsIfNeeded().forPath(basePath);
    worker = new Worker("worker", "localhost", 3, "0");
    workerCuratorCoordinator = new WorkerCuratorCoordinator(jsonMapper, new IndexerZkConfig(new ZkPathsConfig() {

        @Override
        public String getBase() {
            return basePath;
        }
    }, null, null, null, null, null), new TestRemoteTaskRunnerConfig(new Period("PT1S")), cf, worker);
    workerCuratorCoordinator.start();
    // Start a task monitor
    workerTaskMonitor = createTaskMonitor();
    TestTasks.registerSubtypes(jsonMapper);
    jsonMapper.registerSubtypes(new NamedType(TestRealtimeTask.class, "test_realtime"));
    workerTaskMonitor.start();
    task = TestTasks.immediateSuccess("test");
}
Also used : IndexerZkConfig(io.druid.server.initialization.IndexerZkConfig) TestRemoteTaskRunnerConfig(io.druid.indexing.overlord.TestRemoteTaskRunnerConfig) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) NamedType(com.fasterxml.jackson.databind.jsontype.NamedType) Period(org.joda.time.Period) PotentiallyGzippedCompressionProvider(io.druid.curator.PotentiallyGzippedCompressionProvider) TestRealtimeTask(io.druid.indexing.common.TestRealtimeTask) TestingCluster(org.apache.curator.test.TestingCluster) ZkPathsConfig(io.druid.server.initialization.ZkPathsConfig) Before(org.junit.Before)

Example 3 with TestingCluster

use of org.apache.curator.test.TestingCluster in project druid by druid-io.

the class WorkerResourceTest method setUp.

@Before
public void setUp() throws Exception {
    testingCluster = new TestingCluster(1);
    testingCluster.start();
    cf = CuratorFrameworkFactory.builder().connectString(testingCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1, 10)).compressionProvider(new PotentiallyGzippedCompressionProvider(false)).build();
    cf.start();
    cf.blockUntilConnected();
    cf.create().creatingParentsIfNeeded().forPath(basePath);
    worker = new Worker("host", "ip", 3, "v1");
    curatorCoordinator = new WorkerCuratorCoordinator(jsonMapper, new IndexerZkConfig(new ZkPathsConfig() {

        @Override
        public String getBase() {
            return basePath;
        }
    }, null, null, null, null, null), new RemoteTaskRunnerConfig(), cf, worker);
    curatorCoordinator.start();
    workerResource = new WorkerResource(worker, curatorCoordinator, null);
}
Also used : IndexerZkConfig(io.druid.server.initialization.IndexerZkConfig) TestingCluster(org.apache.curator.test.TestingCluster) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) WorkerCuratorCoordinator(io.druid.indexing.worker.WorkerCuratorCoordinator) ZkPathsConfig(io.druid.server.initialization.ZkPathsConfig) Worker(io.druid.indexing.worker.Worker) PotentiallyGzippedCompressionProvider(io.druid.curator.PotentiallyGzippedCompressionProvider) RemoteTaskRunnerConfig(io.druid.indexing.overlord.config.RemoteTaskRunnerConfig) Before(org.junit.Before)

Example 4 with TestingCluster

use of org.apache.curator.test.TestingCluster in project hadoop by apache.

the class TestLeaderElectorService method setUp.

@Before
public void setUp() throws Exception {
    Logger rootLogger = LogManager.getRootLogger();
    rootLogger.setLevel(Level.INFO);
    conf = new Configuration();
    conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
    conf.setBoolean(YarnConfiguration.CURATOR_LEADER_ELECTOR, true);
    conf.set(YarnConfiguration.RM_CLUSTER_ID, "cluster1");
    conf.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID);
    for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) {
        conf.set(HAUtil.addSuffix(confKey, RM1_NODE_ID), RM1_ADDRESS);
        conf.set(HAUtil.addSuffix(confKey, RM2_NODE_ID), RM2_ADDRESS);
    }
    zkCluster = new TestingCluster(3);
    conf.set(YarnConfiguration.RM_ZK_ADDRESS, zkCluster.getConnectString());
    zkCluster.start();
}
Also used : TestingCluster(org.apache.curator.test.TestingCluster) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Logger(org.apache.log4j.Logger) Before(org.junit.Before)

Example 5 with TestingCluster

use of org.apache.curator.test.TestingCluster in project druid by druid-io.

the class BatchServerInventoryViewTest method setUp.

@Before
public void setUp() throws Exception {
    testingCluster = new TestingCluster(1);
    testingCluster.start();
    cf = CuratorFrameworkFactory.builder().connectString(testingCluster.getConnectString()).retryPolicy(new ExponentialBackoffRetry(1, 10)).compressionProvider(new PotentiallyGzippedCompressionProvider(true)).build();
    cf.start();
    cf.blockUntilConnected();
    cf.create().creatingParentsIfNeeded().forPath(testBasePath);
    jsonMapper = new DefaultObjectMapper();
    announcer = new Announcer(cf, MoreExecutors.sameThreadExecutor());
    announcer.start();
    segmentAnnouncer = new BatchDataSegmentAnnouncer(new DruidServerMetadata("id", "host", Long.MAX_VALUE, "type", "tier", 0), new BatchDataSegmentAnnouncerConfig() {

        @Override
        public int getSegmentsPerNode() {
            return 50;
        }
    }, new ZkPathsConfig() {

        @Override
        public String getBase() {
            return testBasePath;
        }
    }, announcer, jsonMapper);
    segmentAnnouncer.start();
    testSegments = Sets.newConcurrentHashSet();
    for (int i = 0; i < INITIAL_SEGMENTS; i++) {
        testSegments.add(makeSegment(i));
    }
    batchServerInventoryView = new BatchServerInventoryView(new ZkPathsConfig() {

        @Override
        public String getBase() {
            return testBasePath;
        }
    }, cf, jsonMapper, Predicates.<Pair<DruidServerMetadata, DataSegment>>alwaysTrue());
    batchServerInventoryView.start();
    inventoryUpdateCounter.set(0);
    filteredBatchServerInventoryView = new BatchServerInventoryView(new ZkPathsConfig() {

        @Override
        public String getBase() {
            return testBasePath;
        }
    }, cf, jsonMapper, new Predicate<Pair<DruidServerMetadata, DataSegment>>() {

        @Override
        public boolean apply(@Nullable Pair<DruidServerMetadata, DataSegment> input) {
            return input.rhs.getInterval().getStart().isBefore(SEGMENT_INTERVAL_START.plusDays(INITIAL_SEGMENTS));
        }
    }) {

        @Override
        protected DruidServer addInnerInventory(DruidServer container, String inventoryKey, Set<DataSegment> inventory) {
            DruidServer server = super.addInnerInventory(container, inventoryKey, inventory);
            inventoryUpdateCounter.incrementAndGet();
            return server;
        }
    };
    filteredBatchServerInventoryView.start();
}
Also used : BatchServerInventoryView(io.druid.client.BatchServerInventoryView) ExponentialBackoffRetry(org.apache.curator.retry.ExponentialBackoffRetry) BatchDataSegmentAnnouncerConfig(io.druid.server.initialization.BatchDataSegmentAnnouncerConfig) DruidServer(io.druid.client.DruidServer) DruidServerMetadata(io.druid.server.coordination.DruidServerMetadata) PotentiallyGzippedCompressionProvider(io.druid.curator.PotentiallyGzippedCompressionProvider) DataSegment(io.druid.timeline.DataSegment) Predicate(com.google.common.base.Predicate) TestingCluster(org.apache.curator.test.TestingCluster) BatchDataSegmentAnnouncer(io.druid.server.coordination.BatchDataSegmentAnnouncer) Announcer(io.druid.curator.announcement.Announcer) ZkPathsConfig(io.druid.server.initialization.ZkPathsConfig) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) BatchDataSegmentAnnouncer(io.druid.server.coordination.BatchDataSegmentAnnouncer) Nullable(javax.annotation.Nullable) Pair(io.druid.java.util.common.Pair) Before(org.junit.Before)

Aggregations

TestingCluster (org.apache.curator.test.TestingCluster)49 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)23 CuratorFramework (org.apache.curator.framework.CuratorFramework)19 Before (org.junit.Before)18 InstanceSpec (org.apache.curator.test.InstanceSpec)15 Timing (org.apache.curator.test.Timing)11 Test (org.testng.annotations.Test)10 ConnectionState (org.apache.curator.framework.state.ConnectionState)7 RetryOneTime (org.apache.curator.retry.RetryOneTime)7 PotentiallyGzippedCompressionProvider (io.druid.curator.PotentiallyGzippedCompressionProvider)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 ConnectionStateListener (org.apache.curator.framework.state.ConnectionStateListener)5 PotentiallyGzippedCompressionProvider (org.apache.druid.curator.PotentiallyGzippedCompressionProvider)5 Test (org.junit.Test)5 ZkPathsConfig (io.druid.server.initialization.ZkPathsConfig)4 TestBroker (org.apache.druid.indexing.kafka.test.TestBroker)4 ZkPathsConfig (org.apache.druid.server.initialization.ZkPathsConfig)4 GatewayConfig (org.apache.knox.gateway.config.GatewayConfig)4 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)3 File (java.io.File)3