Search in sources :

Example 1 with QuotaResetter

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

the class QuotaResetterTest method testQuotaResetter.

@Test
public void testQuotaResetter() {
    // set unbalanced quota values for nodes
    adminClient.quotaMgmtOps.setQuotaForNode(STORE_NAME, QuotaType.GET_THROUGHPUT, 0, 1000L);
    // verify whether quota values initialized
    assertEquals(Long.parseLong(adminClient.quotaMgmtOps.getQuotaForNode(STORE_NAME, QuotaType.GET_THROUGHPUT, 0).getValue()), 1000L);
    assertEquals(adminClient.quotaMgmtOps.getQuotaForNode(STORE_NAME, QuotaType.GET_THROUGHPUT, 1), null);
    // set initial quota enforcement settings
    adminClient.metadataMgmtOps.updateRemoteMetadata(0, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY, Boolean.toString(true));
    adminClient.metadataMgmtOps.updateRemoteMetadata(1, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY, Boolean.toString(false));
    // verify whether quota enforcement settings initialized
    assertEquals(adminClient.metadataMgmtOps.getRemoteMetadata(0, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY).getValue(), Boolean.toString(true));
    assertEquals(adminClient.metadataMgmtOps.getRemoteMetadata(1, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY).getValue(), Boolean.toString(false));
    // initialize quota resetter
    QuotaResetter quotaResetter = new QuotaResetter(adminClient, storeNames, cluster.getNodeIds());
    // test rememberAndDisableQuota
    quotaResetter.rememberAndDisableQuota();
    // verify whether quota values changed
    assertEquals(Long.parseLong(adminClient.quotaMgmtOps.getQuotaForNode(STORE_NAME, QuotaType.GET_THROUGHPUT, 0).getValue()), 1000L);
    assertEquals(adminClient.quotaMgmtOps.getQuotaForNode(STORE_NAME, QuotaType.GET_THROUGHPUT, 1), null);
    // verify whether quota enforcement disabled
    assertEquals(adminClient.metadataMgmtOps.getRemoteMetadata(0, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY).getValue(), Boolean.toString(false));
    assertEquals(adminClient.metadataMgmtOps.getRemoteMetadata(1, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY).getValue(), Boolean.toString(false));
    // test resetQuotaAndRecoverEnforcement
    quotaResetter.resetQuotaAndRecoverEnforcement();
    // verify whether quota values changed
    assertEquals(Long.parseLong(adminClient.quotaMgmtOps.getQuotaForNode(STORE_NAME, QuotaType.GET_THROUGHPUT, 0).getValue()), 500L);
    assertEquals(Long.parseLong(adminClient.quotaMgmtOps.getQuotaForNode(STORE_NAME, QuotaType.GET_THROUGHPUT, 1).getValue()), 500L);
    // verify whether quota enforcement settings recovered
    assertEquals(adminClient.metadataMgmtOps.getRemoteMetadata(0, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY).getValue(), Boolean.toString(true));
    assertEquals(adminClient.metadataMgmtOps.getRemoteMetadata(1, MetadataStore.QUOTA_ENFORCEMENT_ENABLED_KEY).getValue(), Boolean.toString(false));
}
Also used : QuotaResetter(voldemort.client.rebalance.QuotaResetter) Test(org.junit.Test)

Example 2 with QuotaResetter

use of voldemort.client.rebalance.QuotaResetter 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)

Aggregations

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