kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jun...@apache.org
Subject [02/27] git commit: KAFKA-785 Resolve bugs in PreferredReplicaLeaderElection admin tool; reviewed by Swapnil Ghike and Neha Narkhede
Date Thu, 18 Apr 2013 04:53:56 GMT
KAFKA-785 Resolve bugs in PreferredReplicaLeaderElection admin tool; reviewed by Swapnil Ghike
and Neha Narkhede


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

Branch: refs/heads/trunk
Commit: a971a27b59dacb4fbc882a8fead5406c5b4144c6
Parents: 0ee46e0
Author: Neha Narkhede <neha.narkhede@gmail.com>
Authored: Tue Mar 5 09:38:29 2013 -0800
Committer: Neha Narkhede <neha.narkhede@gmail.com>
Committed: Tue Mar 5 09:38:29 2013 -0800

----------------------------------------------------------------------
 .../PreferredReplicaLeaderElectionCommand.scala    |   13 ++-----------
 .../kafka/admin/ReassignPartitionsCommand.scala    |    8 --------
 2 files changed, 2 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/a971a27b/core/src/main/scala/kafka/admin/PreferredReplicaLeaderElectionCommand.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/admin/PreferredReplicaLeaderElectionCommand.scala b/core/src/main/scala/kafka/admin/PreferredReplicaLeaderElectionCommand.scala
index ebcf669..faf0e3e 100644
--- a/core/src/main/scala/kafka/admin/PreferredReplicaLeaderElectionCommand.scala
+++ b/core/src/main/scala/kafka/admin/PreferredReplicaLeaderElectionCommand.scala
@@ -42,11 +42,11 @@ object PreferredReplicaLeaderElectionCommand extends Logging {
 
     val options = parser.parse(args : _*)
 
-    CommandLineUtils.checkRequiredArgs(parser, options, jsonFileOpt, zkConnectOpt)
+    CommandLineUtils.checkRequiredArgs(parser, options, zkConnectOpt)
 
     val jsonFile = options.valueOf(jsonFileOpt)
     val zkConnect = options.valueOf(zkConnectOpt)
-    val jsonString = Utils.readFileAsString(jsonFile)
+    val jsonString = if(jsonFile != "") Utils.readFileAsString(jsonFile) else ""
     var zkClient: ZkClient = null
 
     try {
@@ -55,15 +55,6 @@ object PreferredReplicaLeaderElectionCommand extends Logging {
         if(jsonFile == "") ZkUtils.getAllPartitions(zkClient) else parsePreferredReplicaJsonData(jsonString)
       val preferredReplicaElectionCommand = new PreferredReplicaLeaderElectionCommand(zkClient,
partitionsForPreferredReplicaElection)
 
-      // attach shutdown handler to catch control-c
-      Runtime.getRuntime().addShutdownHook(new Thread() {
-        override def run() = {
-          // delete the admin path so it can be retried
-          ZkUtils.deletePathRecursive(zkClient, ZkUtils.PreferredReplicaLeaderElectionPath)
-          zkClient.close()
-        }
-      })
-
       preferredReplicaElectionCommand.moveLeaderToPreferredReplica()
       println("Successfully started preferred replica election for partitions %s".format(partitionsForPreferredReplicaElection))
     } catch {

http://git-wip-us.apache.org/repos/asf/kafka/blob/a971a27b/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala b/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
index b2204b8..d3845cc 100644
--- a/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
+++ b/core/src/main/scala/kafka/admin/ReassignPartitionsCommand.scala
@@ -71,14 +71,6 @@ object ReassignPartitionsCommand extends Logging {
       zkClient = new ZkClient(zkConnect, 30000, 30000, ZKStringSerializer)
       val reassignPartitionsCommand = new ReassignPartitionsCommand(zkClient, partitionsToBeReassigned)
 
-      // attach shutdown handler to catch control-c
-      Runtime.getRuntime().addShutdownHook(new Thread() {
-        override def run() = {
-          // delete the admin path so it can be retried
-          ZkUtils.deletePathRecursive(zkClient, ZkUtils.ReassignPartitionsPath)
-        }
-      })
-
       if(reassignPartitionsCommand.reassignPartitions())
         println("Successfully started reassignment of partitions %s".format(partitionsToBeReassigned))
       else


Mime
View raw message