use of kafka.utils.ZkUtils in project incubator-rya by apache.
the class KafkaTestInstanceRule method deleteTopic.
/**
* Marks a topic for deletion. You may have to wait some time for the delete to actually complete.
*
* @param topicName - The topic that will be deleted. (not null)
*/
public void deleteTopic(final String topicName) {
ZkUtils zkUtils = null;
try {
logger.info("Deleting Kafka Topic: '{}'", topicName);
zkUtils = ZkUtils.apply(new ZkClient(kafkaInstance.getZookeeperConnect(), 30000, 30000, ZKStringSerializer$.MODULE$), false);
AdminUtils.deleteTopic(zkUtils, topicName);
} finally {
if (zkUtils != null) {
zkUtils.close();
}
}
}
use of kafka.utils.ZkUtils in project nakadi by zalando.
the class KafkaTopicRepository method doWithZkUtils.
private void doWithZkUtils(final ZkUtilsAction action) throws Exception {
ZkUtils zkUtils = null;
try {
final String connectionString = zkFactory.get().getZookeeperClient().getCurrentConnectionString();
zkUtils = ZkUtils.apply(connectionString, zookeeperSettings.getZkSessionTimeoutMs(), zookeeperSettings.getZkConnectionTimeoutMs(), false);
action.execute(zkUtils);
} finally {
if (zkUtils != null) {
zkUtils.close();
}
}
}
use of kafka.utils.ZkUtils in project nakadi by zalando.
the class KafkaTestHelper method createTopic.
public void createTopic(final String topic, final String zkUrl) {
ZkUtils zkUtils = null;
try {
zkUtils = ZkUtils.apply(zkUrl, 30000, 10000, false);
AdminUtils.createTopic(zkUtils, topic, 1, 1, new Properties(), RackAwareMode.Safe$.MODULE$);
} finally {
if (zkUtils != null) {
zkUtils.close();
}
}
}
use of kafka.utils.ZkUtils in project drill by axbaretto.
the class TestKafkaSuit method initKafka.
@BeforeClass
public static void initKafka() throws Exception {
synchronized (TestKafkaSuit.class) {
if (initCount.get() == 0) {
ZookeeperTestUtil.setZookeeperSaslTestConfigProps();
System.setProperty(JaasUtils.JAVA_LOGIN_CONFIG_PARAM, ClassLoader.getSystemResource(LOGIN_CONF_RESOURCE_PATHNAME).getFile());
embeddedKafkaCluster = new EmbeddedKafkaCluster();
Properties topicProps = new Properties();
zkClient = new ZkClient(embeddedKafkaCluster.getZkServer().getConnectionString(), SESSION_TIMEOUT, CONN_TIMEOUT, ZKStringSerializer$.MODULE$);
ZkUtils zkUtils = new ZkUtils(zkClient, new ZkConnection(embeddedKafkaCluster.getZkServer().getConnectionString()), false);
AdminUtils.createTopic(zkUtils, TestQueryConstants.JSON_TOPIC, 1, 1, topicProps, RackAwareMode.Disabled$.MODULE$);
org.apache.kafka.common.requests.MetadataResponse.TopicMetadata fetchTopicMetadataFromZk = AdminUtils.fetchTopicMetadataFromZk(TestQueryConstants.JSON_TOPIC, zkUtils);
logger.info("Topic Metadata: " + fetchTopicMetadataFromZk);
KafkaMessageGenerator generator = new KafkaMessageGenerator(embeddedKafkaCluster.getKafkaBrokerList(), StringSerializer.class);
generator.populateJsonMsgIntoKafka(TestQueryConstants.JSON_TOPIC, NUM_JSON_MSG);
}
initCount.incrementAndGet();
runningSuite = true;
}
logger.info("Initialized Embedded Zookeeper and Kafka");
}
use of kafka.utils.ZkUtils in project atlas by apache.
the class AtlasTopicCreatorTest method shouldCloseResources.
@Test
public void shouldCloseResources() {
Configuration configuration = mock(Configuration.class);
when(configuration.getBoolean(AtlasTopicCreator.ATLAS_NOTIFICATION_CREATE_TOPICS_KEY, true)).thenReturn(true);
when(configuration.getString("atlas.authentication.method.kerberos")).thenReturn("false");
final ZkUtils zookeeperUtils = mock(ZkUtils.class);
AtlasTopicCreator atlasTopicCreator = new AtlasTopicCreator() {
@Override
protected boolean ifTopicExists(String topicName, ZkUtils zkUtils) {
return false;
}
@Override
protected ZkUtils createZkUtils(Configuration atlasProperties) {
return zookeeperUtils;
}
@Override
protected void createTopic(Configuration atlasProperties, String topicName, ZkUtils zkUtils) {
}
};
atlasTopicCreator.createAtlasTopic(configuration, "ATLAS_HOOK", "ATLAS_ENTITIES");
verify(zookeeperUtils, times(1)).close();
}
Aggregations