2016-11-21 43 views

回答

3

你可以使用下面的代碼打印的主題級CONFIGS。更新配置的用法類似。

字串[] args = { 「--zookeeper」, 「本地主機:2181」, 「--entity型」, 「主題」, 「--entity名」, 「測試」,「 - 描述」};

ConfigCommand.main(args);

至於獲得的元數據,請參見https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example尋找一個主題和分區鉛經紀人:

新增:添加配置獲取&更新例如使用AdminUtils:

ZkUtils zkUtils = ZkUtils.apply("localhost:2181/k1", 6000, 10000, JaasUtils.isZkSecurityEnabled()); 

    Properties pp = new Properties(); 
    pp.setProperty("delete.retention.ms", "3000000"); 
    pp.setProperty("file.delete.delay.ms", "40000"); 
    AdminUtils.changeTopicConfig(zkUtils, "test", pp); 
    Properties p = AdminUtils.fetchEntityConfig(zkUtils, ConfigType.Topic(), "test"); 
    System.out.println(p); 
+0

我試圖通過Kafka Admin Utils API實現結果 – user6708151