|
|
@ -351,10 +351,17 @@ class KafkaApis(val requestChannel: RequestChannel, |
|
|
|
if (topic == OffsetManager.OffsetsTopicName || config.autoCreateTopicsEnable) { |
|
|
|
if (topic == OffsetManager.OffsetsTopicName || config.autoCreateTopicsEnable) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (topic == OffsetManager.OffsetsTopicName) { |
|
|
|
if (topic == OffsetManager.OffsetsTopicName) { |
|
|
|
AdminUtils.createTopic(zkClient, topic, config.offsetsTopicPartitions, config.offsetsTopicReplicationFactor, |
|
|
|
val aliveBrokers = metadataCache.getAliveBrokers |
|
|
|
|
|
|
|
val offsetsTopicReplicationFactor = |
|
|
|
|
|
|
|
if (aliveBrokers.length > 0) |
|
|
|
|
|
|
|
Math.min(config.offsetsTopicReplicationFactor, aliveBrokers.length) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
config.offsetsTopicReplicationFactor |
|
|
|
|
|
|
|
AdminUtils.createTopic(zkClient, topic, config.offsetsTopicPartitions, |
|
|
|
|
|
|
|
offsetsTopicReplicationFactor, |
|
|
|
offsetManager.offsetsTopicConfig) |
|
|
|
offsetManager.offsetsTopicConfig) |
|
|
|
info("Auto creation of topic %s with %d partitions and replication factor %d is successful!" |
|
|
|
info("Auto creation of topic %s with %d partitions and replication factor %d is successful!" |
|
|
|
.format(topic, config.offsetsTopicPartitions, config.offsetsTopicReplicationFactor)) |
|
|
|
.format(topic, config.offsetsTopicPartitions, offsetsTopicReplicationFactor)) |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
AdminUtils.createTopic(zkClient, topic, config.numPartitions, config.defaultReplicationFactor) |
|
|
|
AdminUtils.createTopic(zkClient, topic, config.numPartitions, config.defaultReplicationFactor) |
|
|
|