when add a task from controller or manager, it will invoke com.uber.stream.kafka.mirrormaker.controller.core.HelixMirrorMakerManager.addTopicToMirrorMaker(String topicName, int numTopicPartitions)
addTopicToMirrorMaker will go into IdealStateBuilder.buildCustomIdealStateFor()
take a look at : liveInstance.addTopicPartition(new TopicPartition(topicName, i));
public static IdealState buildCustomIdealStateFor(String topicName,
int numTopicPartitions,
PriorityQueue<InstanceTopicPartitionHolder> instanceToNumServingTopicPartitionMap) {
final CustomModeISBuilder customModeIdealStateBuilder = new CustomModeISBuilder(topicName);
customModeIdealStateBuilder
.setStateModel(OnlineOfflineStateModel.name)
.setNumPartitions(numTopicPartitions).setNumReplica(1)
.setMaxPartitionsPerNode(numTopicPartitions);
for (int i = 0; i < numTopicPartitions; ++i) {
InstanceTopicPartitionHolder liveInstance = instanceToNumServingTopicPartitionMap.poll();
if (liveInstance != null) {
customModeIdealStateBuilder.assignInstanceAndState(Integer.toString(i),
liveInstance.getInstanceName(), "ONLINE");
//here will count bigger than actual partition
liveInstance.addTopicPartition(new TopicPartition(topicName, i));
instanceToNumServingTopicPartitionMap.add(liveInstance);
}
}
so I add another new method for InstanceTopicPartitionHolder
addTopicToMirrorMaker will go into IdealStateBuilder.buildCustomIdealStateFor() take a look at : liveInstance.addTopicPartition(new TopicPartition(topicName, i));