Skip to content

Commit

Permalink
Initial commit of new rebalance controller.
Browse files Browse the repository at this point in the history
This is an interim commit. The new RebalanceControllerCLI has been added. Portions of the RebalanceController have been updated to use the RebalancePlan. All the tests that should pass, still pass for the old RebalanceController. About to switch tests to use new RebalanceController that works with a RebalancePlan.
  • Loading branch information
jayjwylie committed Jun 20, 2013
1 parent 0515ae4 commit 464df36
Show file tree
Hide file tree
Showing 12 changed files with 582 additions and 48 deletions.
10 changes: 10 additions & 0 deletions src/java/voldemort/client/rebalance/OrderedClusterTransition.java
Expand Up @@ -36,6 +36,7 @@ public class OrderedClusterTransition {
private String printedContent;
private final int id;

@Deprecated
public OrderedClusterTransition(final Cluster currentCluster,
final Cluster targetCluster,
List<StoreDefinition> storeDefs,
Expand All @@ -48,6 +49,15 @@ public OrderedClusterTransition(final Cluster currentCluster,
this.orderedRebalancePartitionsInfoList = orderedClusterPlan(rebalanceClusterPlan);
}

public OrderedClusterTransition(final RebalanceClusterPlan rebalanceClusterPlan) {
this.id = idGen.incrementAndGet();
this.currentCluster = rebalanceClusterPlan.getCurrentCluster();
this.targetCluster = rebalanceClusterPlan.getFinalCluster();
this.storeDefs = rebalanceClusterPlan.getStoreDefs();
this.rebalanceClusterPlan = rebalanceClusterPlan;
this.orderedRebalancePartitionsInfoList = orderedClusterPlan(rebalanceClusterPlan);
}

public List<StoreDefinition> getStoreDefs() {
return this.storeDefs;
}
Expand Down
52 changes: 16 additions & 36 deletions src/java/voldemort/client/rebalance/RebalanceCLI.java
Expand Up @@ -153,6 +153,7 @@ public static void main(String[] args) throws Exception {
}

if(options.has("url")) {
// Old rebalancing controller

if(!options.has("target-cluster")) {
System.err.println("Missing required arguments: target-cluster");
Expand All @@ -169,8 +170,12 @@ public static void main(String[] args) throws Exception {
rebalanceController.rebalance(targetCluster);

} else {

Set<String> missing = CmdUtils.missing(options, "current-cluster", "current-stores");
// Entropy tool
Set<String> missing = CmdUtils.missing(options,
"entropy",
"output-dir",
"current-cluster",
"current-stores");
if(missing.size() > 0) {
System.err.println("Missing required arguments: "
+ Joiner.on(", ").join(missing));
Expand All @@ -184,45 +189,20 @@ public static void main(String[] args) throws Exception {
Cluster currentCluster = new ClusterMapper().readCluster(new File(currentClusterXML));
List<StoreDefinition> storeDefs = new StoreDefinitionsMapper().readStoreList(new File(currentStoresXML));

// TODO: Remove this option.
if(options.has("entropy")) {

if(!config.hasOutputDirectory()) {
System.err.println("Missing arguments output-dir");
printHelp(System.err, parser);
System.exit(ERROR_EXIT_CODE);
}

boolean entropy = (Boolean) options.valueOf("entropy");
boolean verbose = options.has("verbose-logging");
long numKeys = CmdUtils.valueOf(options, "keys", Entropy.DEFAULT_NUM_KEYS);
Entropy generator = new Entropy(-1, numKeys, verbose);
generator.generateEntropy(currentCluster,
storeDefs,
new File(config.getOutputDirectory()),
entropy);
return;

}

if(!options.has("target-cluster")) {
System.err.println("Missing required arguments: target-cluster");
printHelp(System.err, parser);
System.exit(ERROR_EXIT_CODE);
}

String targetClusterXML = (String) options.valueOf("target-cluster");
Cluster targetCluster = new ClusterMapper().readCluster(new File(targetClusterXML));

rebalanceController = new RebalanceController(currentCluster, config);
rebalanceController.rebalance(currentCluster, targetCluster, storeDefs);

boolean entropy = (Boolean) options.valueOf("entropy");
boolean verbose = options.has("verbose-logging");
long numKeys = CmdUtils.valueOf(options, "keys", Entropy.DEFAULT_NUM_KEYS);
Entropy generator = new Entropy(-1, numKeys, verbose);
generator.generateEntropy(currentCluster,
storeDefs,
new File(config.getOutputDirectory()),
entropy);
}

exitCode = SUCCESS_EXIT_CODE;
if(logger.isInfoEnabled()) {
logger.info("Successfully terminated rebalance all tasks");
}
exitCode = SUCCESS_EXIT_CODE;

} catch(VoldemortException e) {
logger.error("Unsuccessfully terminated rebalance operation - " + e.getMessage(), e);
Expand Down
Expand Up @@ -21,6 +21,10 @@
import voldemort.client.protocol.admin.AdminClientConfig;
import voldemort.utils.Props;

// TODO: This class mixes configuration of RebalancePlan with configuration of
// RebalanceController. It needs to be deprecated so that a clean way of setting
// the parameters/configs for each of these classes is put in place.
@Deprecated
public class RebalanceClientConfig extends AdminClientConfig {

public final static int MAX_PARALLEL_REBALANCING = 1;
Expand Down
Expand Up @@ -171,14 +171,18 @@ public RebalanceClusterPlan(final Cluster targetCluster,
// TODO: (end) Remove ...
}

public Cluster getTargetCluster() {
public Cluster getCurrentCluster() {
return targetCluster;
}

public Cluster getFinalCluster() {
return finalCluster;
}

public List<StoreDefinition> getStoreDefs() {
return storeDefs;
}

@Deprecated
public Queue<RebalanceNodePlan> getRebalancingTaskQueue() {
return rebalanceTaskQueue;
Expand Down

0 comments on commit 464df36

Please sign in to comment.