From 16387be385ceafced807a96297f5ef24248446b8 Mon Sep 17 00:00:00 2001 From: Roshan Sumbaly Date: Mon, 3 Jan 2011 01:54:10 -0800 Subject: [PATCH] Added compulsory param (to MigratePartitions) to indicate whether we want to switch back to normal state at the end of migration --- .../client/rebalance/MigratePartitions.java | 25 +++++-------------- .../rebalance/MigratePartitionsTest.java | 12 ++++++--- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/java/voldemort/client/rebalance/MigratePartitions.java b/src/java/voldemort/client/rebalance/MigratePartitions.java index 8e1e7ea816..8654bc28ff 100644 --- a/src/java/voldemort/client/rebalance/MigratePartitions.java +++ b/src/java/voldemort/client/rebalance/MigratePartitions.java @@ -46,23 +46,6 @@ public class MigratePartitions { private final HashMap> donorStates; private final boolean transitionToNormal; - public MigratePartitions(Cluster currentCluster, - Cluster targetCluster, - List currentStoreDefs, - List targetStoreDefs, - AdminClient adminClient, - VoldemortConfig voldemortConfig, - List stealerNodeIds) { - this(currentCluster, - targetCluster, - currentStoreDefs, - targetStoreDefs, - adminClient, - voldemortConfig, - stealerNodeIds, - false); - } - /** * * @param currentCluster The cluster as it is now @@ -256,10 +239,12 @@ public static void main(String[] args) throws IOException { parser.accepts("cluster-xml", "[REQUIRED] cluster xml file location") .withRequiredArg() .describedAs("path"); - parser.accepts("stealer-node-ids", "Comma separated node ids [ Default - all]") + parser.accepts("stealer-node-ids", "Comma separated node ids [Default - all]") .withRequiredArg() .ofType(Integer.class) .withValuesSeparatedBy(','); + parser.accepts("transition-to-normal", + "At the end of migration do we want to transition back to normal state? [Default-false]"); OptionSet options = parser.parse(args); @@ -282,6 +267,7 @@ public static void main(String[] args) throws IOException { String currentClusterFile = (String) options.valueOf("cluster-xml"); String currentStoresFile = (String) options.valueOf("stores-xml"); String targetStoresFile = currentStoresFile; + boolean transitionToNormal = options.has("transition-to-normal"); if(options.has("target-stores-xml")) { targetStoresFile = (String) options.valueOf("target-stores-xml"); @@ -317,7 +303,8 @@ public static void main(String[] args) throws IOException { targetStoreDefs, adminClient, voldemortConfig, - stealerNodeIds); + stealerNodeIds, + transitionToNormal); migratePartitions.migrate(); } catch(Exception e) { diff --git a/test/unit/voldemort/client/rebalance/MigratePartitionsTest.java b/test/unit/voldemort/client/rebalance/MigratePartitionsTest.java index 69daacb931..d56c010a5e 100644 --- a/test/unit/voldemort/client/rebalance/MigratePartitionsTest.java +++ b/test/unit/voldemort/client/rebalance/MigratePartitionsTest.java @@ -255,7 +255,8 @@ public void testDonorNodePlanGeneration() { Lists.newArrayList(afterStoreDef), adminClient, voldemortConfig, - Lists.newArrayList(0)); + Lists.newArrayList(0), + true); HashMap> donorNodePlans = tool.getDonorNodePlan(); Assert.assertEquals(donorNodePlans.size(), 1); Assert.assertEquals(donorNodePlans.get(1).size(), 1); @@ -267,7 +268,8 @@ public void testDonorNodePlanGeneration() { Lists.newArrayList(afterStoreDef), adminClient, voldemortConfig, - Lists.newArrayList(1)); + Lists.newArrayList(1), + true); donorNodePlans = tool.getDonorNodePlan(); Assert.assertEquals(donorNodePlans.size(), 1); Assert.assertEquals(donorNodePlans.get(0).size(), 1); @@ -279,7 +281,8 @@ public void testDonorNodePlanGeneration() { Lists.newArrayList(afterStoreDef), adminClient, voldemortConfig, - Lists.newArrayList(0, -1)); + Lists.newArrayList(0, -1), + true); donorNodePlans = tool.getDonorNodePlan(); Assert.assertEquals(donorNodePlans.size(), 1); Assert.assertEquals(donorNodePlans.get(1).size(), 1); @@ -291,7 +294,8 @@ public void testDonorNodePlanGeneration() { Lists.newArrayList(afterStoreDef), adminClient, voldemortConfig, - null); + null, + true); donorNodePlans = tool.getDonorNodePlan(); Assert.assertEquals(donorNodePlans.size(), 2); Assert.assertEquals(donorNodePlans.get(0).size(), 1);