本文整理匯總了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);
}