Search in sources :

Example 31 with ZkClient

use of org.I0Itec.zkclient.ZkClient in project metron by apache.

the class KafkaComponent method start.

@Override
public void start() {
    // setup Zookeeper
    zookeeperConnectString = topologyProperties.getProperty(ZKServerComponent.ZOOKEEPER_PROPERTY);
    zkClient = new ZkClient(zookeeperConnectString, 30000, 30000, ZKStringSerializer$.MODULE$);
    // setup Broker
    Properties props = TestUtilsWrapper.createBrokerConfig(0, zookeeperConnectString, brokerPort);
    props.setProperty("zookeeper.connection.timeout.ms", "1000000");
    KafkaConfig config = new KafkaConfig(props);
    Time mock = new MockTime();
    kafkaServer = TestUtils.createServer(config, mock);
    org.apache.log4j.Level oldLevel = UnitTestHelper.getLog4jLevel(KafkaServer.class);
    UnitTestHelper.setLog4jLevel(KafkaServer.class, org.apache.log4j.Level.OFF);
    // do not proceed until the broker is up
    TestUtilsWrapper.waitUntilBrokerIsRunning(kafkaServer, "Timed out waiting for RunningAsBroker State", 100000);
    for (Topic topic : getTopics()) {
        try {
            createTopic(topic.name, topic.numPartitions, true);
        } catch (InterruptedException e) {
            throw new RuntimeException("Unable to create topic", e);
        }
    }
    UnitTestHelper.setLog4jLevel(KafkaServer.class, oldLevel);
    if (postStartCallback != null) {
        postStartCallback.apply(this);
    }
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) MockTime(kafka.utils.MockTime) Time(kafka.utils.Time) Properties(java.util.Properties) MockTime(kafka.utils.MockTime) KafkaConfig(kafka.server.KafkaConfig)

Aggregations

ZkClient (org.I0Itec.zkclient.ZkClient)31 Properties (java.util.Properties)10 ZkUtils (kafka.utils.ZkUtils)7 KafkaConfig (kafka.server.KafkaConfig)6 ZkConnection (org.I0Itec.zkclient.ZkConnection)6 Before (org.junit.Before)6 IOException (java.io.IOException)5 File (java.io.File)4 InputStream (java.io.InputStream)4 MockTime (kafka.utils.MockTime)4 Time (kafka.utils.Time)4 EmbeddedZookeeper (kafka.zk.EmbeddedZookeeper)3 DateTime (org.joda.time.DateTime)3 PinotHelixResourceManager (com.linkedin.pinot.controller.helix.core.PinotHelixResourceManager)2 URL (com.weibo.api.motan.rpc.URL)2 ISE (io.druid.java.util.common.ISE)2 HashSet (java.util.HashSet)2 TopicExistsException (kafka.common.TopicExistsException)2 TestingServer (org.apache.curator.test.TestingServer)2 KafkaProducer (org.apache.kafka.clients.producer.KafkaProducer)2