2016-11-21 53 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