Skip to content

Commit

Permalink
Tweaked Rebalancer --output-dir again to better name interim metadata…
Browse files Browse the repository at this point in the history
… files for each batch.
  • Loading branch information
jayjwylie committed Mar 20, 2013
1 parent 1162dbb commit b05967b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/java/voldemort/client/rebalance/RebalanceController.java
Expand Up @@ -186,6 +186,12 @@ private void rebalancePerClusterTransition(Cluster currentCluster,
// Used for creating clones
ClusterMapper mapper = new ClusterMapper();

// Output initial and final cluster
if(rebalanceConfig.hasOutputDirectory())
RebalanceUtils.dumpCluster(currentCluster,
targetCluster,
new File(rebalanceConfig.getOutputDirectory()));

// Start first dry run to compute the stolen partitions
for(Node stealerNode: targetCluster.getNodes()) {
List<Integer> stolenPrimaryPartitions = RebalanceUtils.getStolenPrimaryPartitions(currentCluster,
Expand Down Expand Up @@ -306,7 +312,7 @@ private void rebalancePerClusterTransition(Cluster currentCluster,
RebalanceUtils.dumpCluster(currentCluster,
transitionCluster,
new File(rebalanceConfig.getOutputDirectory()),
Integer.toString(batchCounter));
"batch-" + Integer.toString(batchCounter) + ".");

long startTimeMs = System.currentTimeMillis();
rebalancePerPartitionTransition(orderedClusterTransition);
Expand Down
20 changes: 17 additions & 3 deletions src/java/voldemort/utils/RebalanceUtils.java
Expand Up @@ -755,21 +755,23 @@ public static String printMap(final Map<Integer, Set<Pair<Integer, Integer>>> no
* @param initialCluster Initial cluster metadata
* @param finalCluster Final cluster metadata
* @param outputDir Output directory where to dump this file
* @param filePrefix String to prepend to the initial & final cluster
* metadata files
* @throws IOException
*/
public static void dumpCluster(Cluster initialCluster,
Cluster finalCluster,
File outputDir,
String fileSuffix) {
String filePrefix) {

// Create the output directory if it doesn't exist
if(!outputDir.exists()) {
Utils.mkdirs(outputDir);
}

// Get the file paths
File initialClusterFile = new File(outputDir, initialClusterFileName + fileSuffix);
File finalClusterFile = new File(outputDir, finalClusterFileName + fileSuffix);
File initialClusterFile = new File(outputDir, filePrefix + initialClusterFileName);
File finalClusterFile = new File(outputDir, filePrefix + finalClusterFileName);

// Write the output
ClusterMapper mapper = new ClusterMapper();
Expand All @@ -781,6 +783,18 @@ public static void dumpCluster(Cluster initialCluster,
}
}

/**
* Given the initial and final cluster dumps it into the output directory
*
* @param initialCluster Initial cluster metadata
* @param finalCluster Final cluster metadata
* @param outputDir Output directory where to dump this file
* @throws IOException
*/
public static void dumpCluster(Cluster initialCluster, Cluster finalCluster, File outputDir) {
dumpCluster(initialCluster, finalCluster, outputDir, "");
}

/**
* 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 b05967b

Please sign in to comment.