Skip to content

Commit

Permalink
Added compulsory param (to MigratePartitions) to indicate whether we …
Browse files Browse the repository at this point in the history
…want to switch back to normal state at the end of migration
  • Loading branch information
rsumbaly authored and afeinberg committed Jan 12, 2011
1 parent d037852 commit 16387be
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
25 changes: 6 additions & 19 deletions src/java/voldemort/client/rebalance/MigratePartitions.java
Expand Up @@ -46,23 +46,6 @@ public class MigratePartitions {
private final HashMap<Integer, Versioned<String>> donorStates;
private final boolean transitionToNormal;

public MigratePartitions(Cluster currentCluster,
Cluster targetCluster,
List<StoreDefinition> currentStoreDefs,
List<StoreDefinition> targetStoreDefs,
AdminClient adminClient,
VoldemortConfig voldemortConfig,
List<Integer> stealerNodeIds) {
this(currentCluster,
targetCluster,
currentStoreDefs,
targetStoreDefs,
adminClient,
voldemortConfig,
stealerNodeIds,
false);
}

/**
*
* @param currentCluster The cluster as it is now
Expand Down Expand Up @@ -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);

Expand All @@ -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");
Expand Down Expand Up @@ -317,7 +303,8 @@ public static void main(String[] args) throws IOException {
targetStoreDefs,
adminClient,
voldemortConfig,
stealerNodeIds);
stealerNodeIds,
transitionToNormal);

migratePartitions.migrate();
} catch(Exception e) {
Expand Down
12 changes: 8 additions & 4 deletions test/unit/voldemort/client/rebalance/MigratePartitionsTest.java
Expand Up @@ -255,7 +255,8 @@ public void testDonorNodePlanGeneration() {
Lists.newArrayList(afterStoreDef),
adminClient,
voldemortConfig,
Lists.newArrayList(0));
Lists.newArrayList(0),
true);
HashMap<Integer, List<RebalancePartitionsInfo>> donorNodePlans = tool.getDonorNodePlan();
Assert.assertEquals(donorNodePlans.size(), 1);
Assert.assertEquals(donorNodePlans.get(1).size(), 1);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 16387be

Please sign in to comment.