Search in sources :

Example 1 with DefaultZKClientService

use of org.apache.twill.internal.zookeeper.DefaultZKClientService in project cdap by caskdata.

the class KafkaClientModuleTest method beforeTest.

@Before
public void beforeTest() throws Exception {
    zkServer = InMemoryZKServer.builder().setDataDir(TEMP_FOLDER.newFolder()).build();
    zkServer.startAndWait();
    CConfiguration cConf = CConfiguration.create();
    String kafkaZKNamespace = cConf.get(KafkaConstants.ConfigKeys.ZOOKEEPER_NAMESPACE_CONFIG);
    kafkaZKConnect = zkServer.getConnectionStr();
    if (kafkaZKNamespace != null) {
        ZKClientService zkClient = new DefaultZKClientService(zkServer.getConnectionStr(), 2000, null, ImmutableMultimap.<String, byte[]>of());
        zkClient.startAndWait();
        zkClient.create("/" + kafkaZKNamespace, null, CreateMode.PERSISTENT);
        zkClient.stopAndWait();
        kafkaZKConnect += "/" + kafkaZKNamespace;
    }
    kafkaServer = createKafkaServer(kafkaZKConnect, TEMP_FOLDER.newFolder());
    kafkaServer.startAndWait();
}
Also used : ZKClientService(org.apache.twill.zookeeper.ZKClientService) DefaultZKClientService(org.apache.twill.internal.zookeeper.DefaultZKClientService) DefaultZKClientService(org.apache.twill.internal.zookeeper.DefaultZKClientService) CConfiguration(co.cask.cdap.common.conf.CConfiguration) Before(org.junit.Before)

Aggregations

CConfiguration (co.cask.cdap.common.conf.CConfiguration)1 DefaultZKClientService (org.apache.twill.internal.zookeeper.DefaultZKClientService)1 ZKClientService (org.apache.twill.zookeeper.ZKClientService)1 Before (org.junit.Before)1