From 62682518257a376c331eaa67343a80d302549e9f Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Wed, 1 Mar 2017 16:31:52 +0100 Subject: [PATCH 1/2] Supports 0.10.2 API by adding RackAwareMode, guessing we want "Safe"... because according to source this is what you get with auto topic creation. --- pom.xml | 6 +++--- src/main/java/Client.java | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index c03d44f..07ad940 100644 --- a/pom.xml +++ b/pom.xml @@ -12,13 +12,13 @@ org.apache.kafka - kafka_2.11 - 0.9.0.0 + kafka_2.12 + 0.10.2.0 com.101tec zkclient - 0.7 + 0.10 diff --git a/src/main/java/Client.java b/src/main/java/Client.java index 91a9e30..010107b 100644 --- a/src/main/java/Client.java +++ b/src/main/java/Client.java @@ -6,6 +6,8 @@ import java.util.concurrent.TimeUnit; import kafka.admin.AdminUtils; +import kafka.admin.RackAwareMode; +import kafka.admin.RackAwareMode.Safe$; import kafka.utils.ZKStringSerializer$; import kafka.utils.ZkUtils; @@ -15,6 +17,7 @@ public class Client { final static boolean resetTopic = Boolean.parseBoolean(System.getenv("RESET_TOPIC")); final static int partitions = Integer.parseInt(System.getenv("NUM_PARTITIONS")); final static int replication = Integer.parseInt(System.getenv("NUM_REPLICAS")); + final static RackAwareMode rackAwareMode = Safe$.MODULE$; final static int nRetries = Integer.parseInt(System.getenv("NUM_CREATE_RETRIES")); @@ -64,7 +67,7 @@ private static void tryCreate(ZkUtils zkUtils, String topicName, int nRetriesLef System.out.println("Creating topic " + topicName); Properties topicConfig = new Properties(); // add per-topic configurations settings here try { - AdminUtils.createTopic(zkUtils, topicName, partitions, replication, topicConfig); + AdminUtils.createTopic(zkUtils, topicName, partitions, replication, topicConfig, rackAwareMode); } catch (Exception e) { if (nRetriesLeft <= 0) { throw new RuntimeException("Failed to create topic \"" + topicName + "\". Is Kafka and Zookeeper running?"); From b62a7df5c5000b1f3c5ef5d47361c25a191c5059 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Mon, 27 Nov 2017 18:40:25 +0100 Subject: [PATCH 2/2] Upgrades kafka lib to 1.0.0 --- pom.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 07ad940..d7302f3 100644 --- a/pom.xml +++ b/pom.xml @@ -8,12 +8,17 @@ kafka-topic-client 1.0-SNAPSHOT + + 1.8 + 1.8 + + org.apache.kafka kafka_2.12 - 0.10.2.0 + 1.0.0 com.101tec @@ -49,4 +54,4 @@ - \ No newline at end of file +