Search in sources :

Example 1 with RebalanceController

use of voldemort.client.rebalance.RebalanceController in project voldemort by voldemort.

the class RebalanceControllerCLI method main.

public static void main(String[] args) throws Exception {
    setupParser();
    OptionSet options = getValidOptions(args);
    // Bootstrap & fetch current cluster/stores
    String bootstrapURL = (String) options.valueOf("url");
    int parallelism = RebalanceController.MAX_PARALLEL_REBALANCING;
    if (options.has("parallelism")) {
        parallelism = (Integer) options.valueOf("parallelism");
    }
    long proxyPauseSec = RebalanceController.PROXY_PAUSE_IN_SECONDS;
    if (options.has("proxy-pause")) {
        proxyPauseSec = (Long) options.valueOf("proxy-pause");
    }
    RebalanceController rebalanceController = new RebalanceController(bootstrapURL, parallelism, proxyPauseSec);
    Cluster currentCluster = rebalanceController.getCurrentCluster();
    List<StoreDefinition> currentStoreDefs = rebalanceController.getCurrentStoreDefs();
    // If this test doesn't pass, something is wrong in prod!
    RebalanceUtils.validateClusterStores(currentCluster, currentStoreDefs);
    // Determine final cluster/stores and validate them
    String finalClusterXML = (String) options.valueOf("final-cluster");
    Cluster finalCluster = new ClusterMapper().readCluster(new File(finalClusterXML));
    List<StoreDefinition> finalStoreDefs = currentStoreDefs;
    if (options.has("final-stores")) {
        String storesXML = (String) options.valueOf("final-stores");
        finalStoreDefs = new StoreDefinitionsMapper().readStoreList(new File(storesXML));
    }
    RebalanceUtils.validateClusterStores(finalCluster, finalStoreDefs);
    RebalanceUtils.validateCurrentFinalCluster(currentCluster, finalCluster);
    // Process optional "planning" arguments
    int batchSize = CmdUtils.valueOf(options, "batch-size", RebalancePlan.BATCH_SIZE);
    String outputDir = null;
    if (options.has("output-dir")) {
        outputDir = (String) options.valueOf("output-dir");
    }
    RebalancePlan rebalancePlan = new RebalancePlan(currentCluster, currentStoreDefs, finalCluster, finalStoreDefs, batchSize, outputDir);
    boolean resetQuota = !options.has("no-reset-quota");
    Set<String> storeNames = Sets.newHashSet();
    for (StoreDefinition storeDef : finalStoreDefs) {
        storeNames.add(storeDef.getName());
    }
    QuotaResetter quotaResetter = new QuotaResetter(bootstrapURL, storeNames, rebalancePlan.getFinalCluster().getNodeIds());
    // before rebalance, remember and disable quota enforcement settings
    if (resetQuota) {
        quotaResetter.rememberAndDisableQuota();
    }
    // Plan & execute rebalancing.
    rebalanceController.rebalance(rebalancePlan);
    // after rebalance, reset quota values and recover quota enforcement
    if (resetQuota) {
        quotaResetter.resetQuotaAndRecoverEnforcement();
    }
}
Also used : RebalancePlan(voldemort.client.rebalance.RebalancePlan) StoreDefinitionsMapper(voldemort.xml.StoreDefinitionsMapper) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper) RebalanceController(voldemort.client.rebalance.RebalanceController) StoreDefinition(voldemort.store.StoreDefinition) QuotaResetter(voldemort.client.rebalance.QuotaResetter) OptionSet(joptsimple.OptionSet) File(java.io.File)

Example 2 with RebalanceController

use of voldemort.client.rebalance.RebalanceController in project voldemort by voldemort.

the class ClusterTestUtils method getRebalanceKit.

public static RebalanceKit getRebalanceKit(String bootstrapUrl, Cluster finalCluster, List<StoreDefinition> finalStoreDefs) {
    RebalanceController rebalanceController = new RebalanceController(bootstrapUrl, RebalanceController.MAX_PARALLEL_REBALANCING, REBALANCE_CONTROLLER_TEST_PROXY_PAUSE_IN_SECONDS);
    RebalancePlan rebalancePlan = rebalanceController.getPlan(finalCluster, finalStoreDefs, RebalancePlan.BATCH_SIZE);
    return new RebalanceKit(rebalanceController, rebalancePlan);
}
Also used : RebalancePlan(voldemort.client.rebalance.RebalancePlan) RebalanceController(voldemort.client.rebalance.RebalanceController)

Example 3 with RebalanceController

use of voldemort.client.rebalance.RebalanceController in project voldemort by voldemort.

the class ClusterTestUtils method getRebalanceKit.

public static RebalanceKit getRebalanceKit(String bootstrapUrl, int maxParallel, long proxyPauseS, Cluster finalCluster) {
    RebalanceController rebalanceController = new RebalanceController(bootstrapUrl, maxParallel, proxyPauseS);
    RebalancePlan rebalancePlan = rebalanceController.getPlan(finalCluster, RebalancePlan.BATCH_SIZE);
    return new RebalanceKit(rebalanceController, rebalancePlan);
}
Also used : RebalancePlan(voldemort.client.rebalance.RebalancePlan) RebalanceController(voldemort.client.rebalance.RebalanceController)

Aggregations

RebalanceController (voldemort.client.rebalance.RebalanceController)3 RebalancePlan (voldemort.client.rebalance.RebalancePlan)3 File (java.io.File)1 OptionSet (joptsimple.OptionSet)1 QuotaResetter (voldemort.client.rebalance.QuotaResetter)1 Cluster (voldemort.cluster.Cluster)1 StoreDefinition (voldemort.store.StoreDefinition)1 ClusterMapper (voldemort.xml.ClusterMapper)1 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)1