chia7712 commented on code in PR #18983:
URL: https://github.com/apache/kafka/pull/18983#discussion_r1969041052
##########
core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala:
##########
@@ -3452,11 +3452,26 @@ class PlaintextAdminIntegrationTest extends
BaseAdminIntegrationTest {
val tp3 = new TopicPartition(topic, 2)
createTopic(topic, numPartitions = 4)
-
val validAssignment = Optional.of(new NewPartitionReassignment(
(0 until brokerCount).map(_.asInstanceOf[Integer]).asJava
))
+ val alterOptions = new AlterPartitionReassignmentsOptions
+ alterOptions.allowReplicationFactorChange(false)
+ val alterReplicaNumberTo1 = Optional.of(new
NewPartitionReassignment(List(1.asInstanceOf[Integer]).asJava))
+ val alterReplicaNumberTo2 = Optional.of(new NewPartitionReassignment((0
until brokerCount - 1).map(_.asInstanceOf[Integer]).asJava))
+ val alterReplicaNumberTo3 = Optional.of(new NewPartitionReassignment((0
until brokerCount).map(_.asInstanceOf[Integer]).asJava))
+ val alterReplicaResults = client.alterPartitionReassignments(Map(
+ tp1 -> alterReplicaNumberTo1,
+ tp2 -> alterReplicaNumberTo2,
+ tp3 -> alterReplicaNumberTo3,
+ ).asJava, alterOptions).values()
+ assertDoesNotThrow(() => alterReplicaResults.get(tp1).get())
+ assertEquals("The replication factor is changed from 1 to 2",
+ assertFutureThrows(classOf[InvalidReplicationFactorException],
alterReplicaResults.get(tp2)).getMessage)
+ assertEquals("The replication factor is changed from 1 to 3",
Review Comment:
Could you please add a test of decreasing the RF?
##########
clients/src/main/java/org/apache/kafka/clients/admin/AlterPartitionReassignmentsOptions.java:
##########
@@ -28,4 +28,25 @@
*/
@InterfaceStability.Evolving
public class AlterPartitionReassignmentsOptions extends
AbstractOptions<AlterPartitionReassignmentsOptions> {
+
+ private Boolean allowReplicationFactorChange = true;
Review Comment:
`boolean`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]