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));
}
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();
}
}
Aggregations