Permalink
Browse files

Changed Rebalancer --output-dir option to append numbers to each .xml…

… file it outputs so that we have access to interim cluster configs.
  • Loading branch information...
1 parent 433ce02 commit 1162dbb0d9c74ad95aea4a2e36edf50638cc57bc @jayjwylie jayjwylie committed Feb 22, 2013
@@ -248,6 +248,7 @@ private void rebalancePerClusterTransition(Cluster currentCluster,
logger.info("Total number of tasks : " + numTasks);
int tasksCompleted = 0;
+ int batchCounter = 0;
int primaryPartitionId = 0;
double totalTimeMs = 0.0;
@@ -269,6 +270,7 @@ private void rebalancePerClusterTransition(Cluster currentCluster,
if(primaryPartitionBatchSize == rebalanceConfig.getPrimaryPartitionBatchSize())
break;
}
+ batchCounter++;
// Remove the partitions moved + Prepare message to print
StringBuffer buffer = new StringBuffer();
@@ -303,7 +305,8 @@ private void rebalancePerClusterTransition(Cluster currentCluster,
if(rebalanceConfig.hasOutputDirectory())
RebalanceUtils.dumpCluster(currentCluster,
transitionCluster,
- new File(rebalanceConfig.getOutputDirectory()));
+ new File(rebalanceConfig.getOutputDirectory()),
+ Integer.toString(batchCounter));
long startTimeMs = System.currentTimeMillis();
rebalancePerPartitionTransition(orderedClusterTransition);
@@ -378,9 +381,9 @@ private void rebalancePerPartitionTransition(final OrderedClusterTransition orde
// Split the store definitions
List<StoreDefinition> readOnlyStoreDefs = StoreDefinitionUtils.filterStores(orderedClusterTransition.getStoreDefs(),
- true);
+ true);
List<StoreDefinition> readWriteStoreDefs = StoreDefinitionUtils.filterStores(orderedClusterTransition.getStoreDefs(),
- false);
+ false);
boolean hasReadOnlyStores = readOnlyStoreDefs != null && readOnlyStoreDefs.size() > 0;
boolean hasReadWriteStores = readWriteStoreDefs != null
&& readWriteStoreDefs.size() > 0;
@@ -757,16 +757,19 @@ public static String printMap(final Map<Integer, Set<Pair<Integer, Integer>>> no
* @param outputDir Output directory where to dump this file
* @throws IOException
*/
- public static void dumpCluster(Cluster initialCluster, Cluster finalCluster, File outputDir) {
+ public static void dumpCluster(Cluster initialCluster,
+ Cluster finalCluster,
+ File outputDir,
+ String fileSuffix) {
// 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);
- File finalClusterFile = new File(outputDir, finalClusterFileName);
+ File initialClusterFile = new File(outputDir, initialClusterFileName + fileSuffix);
+ File finalClusterFile = new File(outputDir, finalClusterFileName + fileSuffix);
// Write the output
ClusterMapper mapper = new ClusterMapper();

0 comments on commit 1162dbb

Please sign in to comment.