Search in sources :

Example 6 with TestingCluster

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

the class KafkaSupervisorTest method setUp.

@Before
public void setUp() throws Exception {
    taskStorage = createMock(TaskStorage.class);
    taskMaster = createMock(TaskMaster.class);
    taskRunner = createMock(TaskRunner.class);
    indexerMetadataStorageCoordinator = createMock(IndexerMetadataStorageCoordinator.class);
    taskClient = createMock(KafkaIndexTaskClient.class);
    taskQueue = createMock(TaskQueue.class);
    zkServer = new TestingCluster(1);
    zkServer.start();
    kafkaServer = new TestBroker(zkServer.getConnectString(), tempFolder.newFolder(), 1, ImmutableMap.of("num.partitions", String.valueOf(NUM_PARTITIONS)));
    kafkaServer.start();
    kafkaHost = String.format("localhost:%d", kafkaServer.getPort());
    dataSchema = getDataSchema(DATASOURCE);
    tuningConfig = new KafkaSupervisorTuningConfig(1000, 50000, new Period("P1Y"), new File("/test"), null, null, true, false, null, null, numThreads, TEST_CHAT_THREADS, TEST_CHAT_RETRIES, TEST_HTTP_TIMEOUT, TEST_SHUTDOWN_TIMEOUT);
}
Also used : IndexerMetadataStorageCoordinator(io.druid.indexing.overlord.IndexerMetadataStorageCoordinator) TestingCluster(org.apache.curator.test.TestingCluster) TaskStorage(io.druid.indexing.overlord.TaskStorage) TestBroker(io.druid.indexing.kafka.test.TestBroker) KafkaIndexTaskClient(io.druid.indexing.kafka.KafkaIndexTaskClient) TaskQueue(io.druid.indexing.overlord.TaskQueue) Period(org.joda.time.Period) TaskMaster(io.druid.indexing.overlord.TaskMaster) File(java.io.File) TaskRunner(io.druid.indexing.overlord.TaskRunner) Before(org.junit.Before)

Example 7 with TestingCluster

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

the class KafkaIndexTaskTest method setUp.

@Before
public void setUp() throws Exception {
    emitter = new ServiceEmitter("service", "host", new LoggingEmitter(log, LoggingEmitter.Level.ERROR, new DefaultObjectMapper()));
    emitter.start();
    EmittingLogger.registerEmitter(emitter);
    makeToolboxFactory();
    zkServer = new TestingCluster(1);
    zkServer.start();
    kafkaServer = new TestBroker(zkServer.getConnectString(), tempFolder.newFolder(), 1, ImmutableMap.of("num.partitions", "2"));
    kafkaServer.start();
    taskExec = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(Execs.makeThreadFactory("kafka-task-test-%d")));
    handoffConditionTimeout = 0;
    reportParseExceptions = false;
    doHandoff = true;
}
Also used : ServiceEmitter(com.metamx.emitter.service.ServiceEmitter) TestingCluster(org.apache.curator.test.TestingCluster) TestBroker(io.druid.indexing.kafka.test.TestBroker) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) LoggingEmitter(com.metamx.emitter.core.LoggingEmitter) Before(org.junit.Before)

Example 8 with TestingCluster

use of org.apache.curator.test.TestingCluster in project helios by spotify.

the class ZooKeeperTestingClusterManager method start0.

private void start0() {
    zkPeers = createPeers(3);
    zkAddresses = allocateAddresses(zkPeers);
    peerCurators = createCurators(zkAddresses);
    System.setProperty("zookeeper.jmx.log4j.disable", "true");
    cluster = new TestingCluster(zkPeers);
    zkServers = cluster.getServers();
    try {
        cluster.start();
    } catch (Exception e) {
        stop();
        throw Throwables.propagate(e);
    }
}
Also used : TestingCluster(org.apache.curator.test.TestingCluster) TimeoutException(java.util.concurrent.TimeoutException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 9 with TestingCluster

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

the class ZookeeperIpFinderTest method testFourNodesKillRestartZookeeper.

/**
 * @throws Exception If failed.
 */
public void testFourNodesKillRestartZookeeper() throws Exception {
    allowDuplicateRegistrations = false;
    // start 4 nodes
    System.setProperty(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING, zkCluster.getConnectString());
    startGrids(4);
    // wait until all grids are started
    waitForRemoteNodes(grid(0), 3);
    // each node will only register itself
    assertEquals(4, zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size());
    // remember ZK server configuration and stop the cluster
    Collection<InstanceSpec> instances = zkCluster.getInstances();
    zkCluster.stop();
    Thread.sleep(1000);
    // start the cluster with the previous configuration
    zkCluster = new TestingCluster(instances);
    zkCluster.start();
    // block the client until connected
    zkCurator.blockUntilConnected();
    // check that the nodes have registered again
    assertEquals(4, zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size());
    // stop all grids
    stopAllGrids();
    assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            try {
                return 0 == zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size();
            } catch (Exception e) {
                U.error(log, "Failed to wait for zk condition", e);
                return false;
            }
        }
    }, 20000));
}
Also used : InstanceSpec(org.apache.curator.test.InstanceSpec) TestingCluster(org.apache.curator.test.TestingCluster) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate)

Example 10 with TestingCluster

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

the class ZookeeperIpFinderTest method beforeTest.

/**
 * Before test.
 *
 * @throws Exception
 */
@Override
public void beforeTest() throws Exception {
    super.beforeTest();
    // remove stale system properties
    System.getProperties().remove(TcpDiscoveryZookeeperIpFinder.PROP_ZK_CONNECTION_STRING);
    // disable JMX for tests
    System.setProperty("zookeeper.jmx.log4j.disable", "true");
    // start the ZK cluster
    zkCluster = new TestingCluster(ZK_CLUSTER_SIZE);
    zkCluster.start();
    // start the Curator client so we can perform assertions on the ZK state later
    zkCurator = CuratorFrameworkFactory.newClient(zkCluster.getConnectString(), new RetryNTimes(10, 1000));
    zkCurator.start();
}
Also used : RetryNTimes(org.apache.curator.retry.RetryNTimes) TestingCluster(org.apache.curator.test.TestingCluster)

Aggregations

TestingCluster (org.apache.curator.test.TestingCluster)15 Before (org.junit.Before)8 PotentiallyGzippedCompressionProvider (io.druid.curator.PotentiallyGzippedCompressionProvider)6 ExponentialBackoffRetry (org.apache.curator.retry.ExponentialBackoffRetry)6 ZkPathsConfig (io.druid.server.initialization.ZkPathsConfig)4 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)3 Announcer (io.druid.curator.announcement.Announcer)2 TestBroker (io.druid.indexing.kafka.test.TestBroker)2 BatchDataSegmentAnnouncer (io.druid.server.coordination.BatchDataSegmentAnnouncer)2 DruidServerMetadata (io.druid.server.coordination.DruidServerMetadata)2 BatchDataSegmentAnnouncerConfig (io.druid.server.initialization.BatchDataSegmentAnnouncerConfig)2 IndexerZkConfig (io.druid.server.initialization.IndexerZkConfig)2 RetryOneTime (org.apache.curator.retry.RetryOneTime)2 InstanceSpec (org.apache.curator.test.InstanceSpec)2 Period (org.joda.time.Period)2 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)1 Predicate (com.google.common.base.Predicate)1 LoggingEmitter (com.metamx.emitter.core.LoggingEmitter)1 ServiceEmitter (com.metamx.emitter.service.ServiceEmitter)1 BatchServerInventoryView (io.druid.client.BatchServerInventoryView)1