2017-10-19 29 views
0

Java APIを使用してKafkaトピックを作成しようとしていますが、LEADERを入手できません。Java APIからのトピック作成

コード:

int partition = 0; 
     ZkClient zkClient = null; 
     try { 
      String zookeeperHosts = "localhost:2181"; // If multiple zookeeper then -> String zookeeperHosts = "192.168.20.1:2181,192.168.20.2:2181"; 
      int sessionTimeOutInMs = 15 * 1000; // 15 secs 
      int connectionTimeOutInMs = 10 * 1000; // 10 secs 

      zkClient = new ZkClient(zookeeperHosts, sessionTimeOutInMs, connectionTimeOutInMs, ZKStringSerializer$.MODULE$); 

      String topicName = "mdmTopic5"; 
      int noOfPartitions = 2; 
      int noOfReplication = 1; 
      Properties topicConfiguration = new Properties(); 
      AdminUtils.createTopic(zkClient, topicName, noOfPartitions, noOfReplication, topicConfiguration); 

     } catch (Exception ex) { 
      ex.printStackTrace(); 
     } finally { 
      if (zkClient != null) { 
       zkClient.close(); 
      } 
     } 

がエラー:カフカ0.11.0.1はAdminUtilsを

[2017-10-19 12:14:42,263] WARN Error while fetching metadata with correlation id 1 : {mdmTopic5=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) 
[2017-10-19 12:14:42,370] WARN Error while fetching metadata with correlation id 3 : {mdmTopic5=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) 
[2017-10-19 12:14:42,479] WARN Error while fetching metadata with correlation id 4 : {mdmTopic5=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) 

をサポートしていない???。このバージョンでトピックを作成する方法を教えてください。

ありがとうございました。

答えて

関連する問題