Skip to content

Commit

Permalink
Write plan to a file inside the output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
voldemort authored and jayjwylie committed Jun 20, 2013
1 parent 9ee4ebe commit aa96bbf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/java/voldemort/client/rebalance/RebalancePlan.java
Expand Up @@ -126,6 +126,8 @@ public RebalancePlan(final Cluster currentCluster,
zoneMoveMap = new MoveMap(interimCluster.getZoneIds());

plan();
// write plan to file
RebalanceUtils.dumpPlanToFile(this.outputDir, this);
}

public RebalancePlan(final Cluster currentCluster,
Expand Down
21 changes: 21 additions & 0 deletions src/java/voldemort/utils/RebalanceUtils.java
Expand Up @@ -43,6 +43,7 @@
import voldemort.client.protocol.admin.AdminClient;
import voldemort.client.protocol.admin.AdminClientConfig;
import voldemort.client.rebalance.RebalancePartitionsInfo;
import voldemort.client.rebalance.RebalancePlan;
import voldemort.cluster.Cluster;
import voldemort.cluster.Node;
import voldemort.cluster.Zone;
Expand Down Expand Up @@ -963,6 +964,26 @@ public static void dumpAnalysisToFile(String outputDirName,
}
}

/**
* Prints the plan to a file.
*
* @param outputDirName
* @param plan
*/
public static void dumpPlanToFile(String outputDirName, RebalancePlan plan) {
if(outputDirName != null) {
File outputDir = new File(outputDirName);
if(!outputDir.exists()) {
Utils.mkdirs(outputDir);
}
try {
FileUtils.writeStringToFile(new File(outputDirName, "plan.out"), plan.toString());
} catch(IOException e) {
logger.error("IOException during dumpPlanToFile: " + e);
}
}
}

/**
* Given a list of tuples of [replica_type, partition], flattens it and
* generates a map of replica_type to partition mapping
Expand Down

0 comments on commit aa96bbf

Please sign in to comment.