-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support changing replication factor #4
Comments
I've experimented with this. For example, a candidate configuration for the command line {
"version":1,
"partitions":[
{"topic":"map.raw-sq.it","partition":0,"replicas":[1,2,3]},
{"topic":"map.raw-sq.it","partition":1,"replicas":[2,3,4]},
{"topic":"map.raw-sq.it","partition":2,"replicas":[3,4,5]},
{"topic":"map.raw-sq.it","partition":3,"replicas":[4,5,1]},
{"topic":"map.raw-sq.it","partition":4,"replicas":[5,1,2]},
{"topic":"map.raw-sq.it","partition":5,"replicas":[1,3,4]},
{"topic":"map.raw-sq.it","partition":6,"replicas":[2,4,5]},
{"topic":"map.raw-sq.it","partition":7,"replicas":[3,5,1]},
{"topic":"map.raw-sq.it","partition":8,"replicas":[4,1,1]},
{"topic":"map.raw-sq.it","partition":9,"replicas":[5,2,3]}
]
} This mechanism works fine if the number of partitions is unchanged. (So obviously any change in the number of partitions must be made first.) In terms of doing this work, I suggest:
I think this would generate a fairly "clean" setup. |
In manual testing of something knocked together along these lines: def updateReplicationFactor(topicName: String, numPartitions: Int, replicationFactor: Int): Try[Unit] =
for {
brokerMetadatas <- getBrokerMetadatas
replicaAssignment <- assignReplicasToBrokers(brokerMetadatas, numPartitions, replicationFactor)
} yield Try { AdminUtils.createOrUpdateTopicPartitionAssignmentPathInZK(zkUtils, topicName, replicaAssignment, update = true) }
private def getBrokerMetadatas: Try[Seq[BrokerMetadata]] = Try {
AdminUtils.getBrokerMetadatas(zkUtils)
}
private def assignReplicasToBrokers(brokerMetadatas: Seq[BrokerMetadata], numPartitions: Int, replicationFactor: Int) = Try {
AdminUtils.assignReplicasToBrokers(brokerMetadatas, numPartitions, replicationFactor)
} we went from:
and ended up in a weird state:
This didn't resolve itself until I forced a fix using For context, the logic for |
I added this commit to the |
Currently we don't support changing the replication factor for an existing topic as it isn't as trivial as the other configurations.
See the second answer here to see how it can be done.
The text was updated successfully, but these errors were encountered: