kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jun...@apache.org
Subject [18/37] git commit: Improve second replica assignment; patched by Jun Rao; reviewed by Guozhang Wang; kafka-762
Date Mon, 04 Mar 2013 04:22:01 GMT
Improve second replica assignment; patched by Jun Rao; reviewed by Guozhang Wang; kafka-762


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/859959f9
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/859959f9
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/859959f9

Branch: refs/heads/trunk
Commit: 859959f974225dd066ae94fc8254809203ffd980
Parents: 30f992c
Author: Jun Rao <junrao@gmail.com>
Authored: Thu Feb 21 21:42:18 2013 -0800
Committer: Jun Rao <junrao@gmail.com>
Committed: Thu Feb 21 21:42:18 2013 -0800

----------------------------------------------------------------------
 core/src/main/scala/kafka/admin/AdminUtils.scala |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/859959f9/core/src/main/scala/kafka/admin/AdminUtils.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/admin/AdminUtils.scala b/core/src/main/scala/kafka/admin/AdminUtils.scala
index 437a685..8e44cb0 100644
--- a/core/src/main/scala/kafka/admin/AdminUtils.scala
+++ b/core/src/main/scala/kafka/admin/AdminUtils.scala
@@ -63,9 +63,9 @@ object AdminUtils extends Logging {
     val ret = new mutable.HashMap[Int, List[String]]()
     val startIndex = if (fixedStartIndex >= 0) fixedStartIndex else rand.nextInt(brokerList.size)
 
-    var secondReplicaShift = -1
+    var secondReplicaShift = if (fixedStartIndex >= 0) fixedStartIndex else rand.nextInt(brokerList.size)
     for (i <- 0 until nPartitions) {
-      if (i % brokerList.size == 0)
+      if (i > 0 && (i % brokerList.size == 0))
         secondReplicaShift += 1
       val firstReplicaIndex = (i + startIndex) % brokerList.size
       var replicaList = List(brokerList(firstReplicaIndex))


Mime
View raw message