bozhao12 commented on a change in pull request #11942:
URL: https://github.com/apache/kafka/pull/11942#discussion_r836181354



##########
File path: core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala
##########
@@ -1300,6 +1300,62 @@ class ReplicaManagerTest {
     TestUtils.assertNoNonDaemonThreads(this.getClass.getName)
   }
 
+  @Test
+  def testHasPreferredReplica(): Unit = {
+    val replicaManager = setupReplicaManagerWithMockedPurgatories(new 
MockTimer(time),
+      propsModifier = props => props.put(KafkaConfig.ReplicaSelectorClassProp, 
"org.apache.kafka.common.replica.RackAwareReplicaSelector"))
+
+    try {
+      val leaderBrokerId = 0
+      val followerBrokerId = 1
+      val brokerList = Seq[Integer](leaderBrokerId, followerBrokerId).asJava
+      val topicId = Uuid.randomUuid()
+      val tp0 = new TopicPartition(topic, 0)
+      val tidp0 = new TopicIdPartition(topicId, tp0)
+
+      initializeLogAndTopicId(replicaManager, tp0, topicId)
+      when(replicaManager.metadataCache.getPartitionReplicaEndpoints(
+        any[TopicPartition], any[ListenerName])).
+        thenReturn(Map(leaderBrokerId -> new Node(leaderBrokerId, "host1", 
9092, "rack-a"),
+          followerBrokerId -> new Node(followerBrokerId, "host2", 9092, 
"rack-b")).toMap)

Review comment:
       @dajac  It looks better,all codes mentioned in the comments have been 
updated. Thanks.




-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to