本文整理汇总了Java中kafka.admin.AdminUtils.changeTopicConfig方法的典型用法代码示例。如果您正苦于以下问题:Java AdminUtils.changeTopicConfig方法的具体用法?Java AdminUtils.changeTopicConfig怎么用?Java AdminUtils.changeTopicConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kafka.admin.AdminUtils
的用法示例。
在下文中一共展示了AdminUtils.changeTopicConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureTopicCreated
import kafka.admin.AdminUtils; //导入方法依赖的package包/类
private void ensureTopicCreated(Map<String, ?> config) {
ZkUtils zkUtils = createZkUtils(config);
Map<String, List<PartitionInfo>> topics = _consumers.get(0).listTopics();
long snapshotWindowMs = Long.parseLong((String) config.get(KafkaCruiseControlConfig.LOAD_SNAPSHOT_WINDOW_MS_CONFIG));
int numSnapshotWindows = Integer.parseInt((String) config.get(KafkaCruiseControlConfig.NUM_LOAD_SNAPSHOTS_CONFIG));
long retentionMs = (numSnapshotWindows * ADDITIONAL_SNAPSHOT_WINDOW_TO_RETAIN_FACTOR) * snapshotWindowMs;
Properties props = new Properties();
props.setProperty(LogConfig.RetentionMsProp(), Long.toString(retentionMs));
props.setProperty(LogConfig.CleanupPolicyProp(), DEFAULT_CLEANUP_POLICY);
int replicationFactor = Math.min(2, zkUtils.getAllBrokersInCluster().size());
if (!topics.containsKey(_partitionMetricSampleStoreTopic)) {
AdminUtils.createTopic(zkUtils, _partitionMetricSampleStoreTopic, 32, replicationFactor, props, RackAwareMode.Safe$.MODULE$);
} else {
AdminUtils.changeTopicConfig(zkUtils, _partitionMetricSampleStoreTopic, props);
}
if (!topics.containsKey(_brokerMetricSampleStoreTopic)) {
AdminUtils.createTopic(zkUtils, _brokerMetricSampleStoreTopic, 32, replicationFactor, props, RackAwareMode.Safe$.MODULE$);
} else {
AdminUtils.changeTopicConfig(zkUtils, _brokerMetricSampleStoreTopic, props);
}
KafkaCruiseControlUtils.closeZkUtilsWithTimeout(zkUtils, 10000);
}
示例2: overrideTopicProperties
import kafka.admin.AdminUtils; //导入方法依赖的package包/类
/**
* Override topic configuration
*
* @param connection zookeeper util API
* @param topicName topic name
* @param configs topic properties
*/
public void overrideTopicProperties(final ZkUtils connection, final String topicName, final Properties configs) {
try {
AdminUtils.changeTopicConfig(connection, topicName, configs);
} catch (AdminOperationException | KafkaException e) {
throw new TopicOperationException(topicName, e.getMessage(), e, this.getClass());
}
}
示例3: changeTopicConfig
import kafka.admin.AdminUtils; //导入方法依赖的package包/类
/**
* 修改主题配置
*
* @param topic 主题
* @param prop 属性
*/
private static void changeTopicConfig(String topic, Properties prop) {
Properties currProp = AdminUtils.fetchEntityConfig(zkUtils, ConfigType.Topic(), topic);
for (Object key : currProp.keySet()) {
System.out.println(key + ":" + currProp.get(key));
}
currProp.putAll(prop);
AdminUtils.changeTopicConfig(zkUtils, KAFKA_TOPIC, currProp);
}