use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class AdminServiceBasicTest method testRebalanceQuota.
@Test
public void testRebalanceQuota() throws InterruptedException {
AdminClient client = getAdminClient();
String storeName = storeDefs.get(0).getName();
QuotaType quotaType = QuotaType.GET_THROUGHPUT;
Long quota = 1000L, targetQuota = quota / 2;
client.quotaMgmtOps.setQuotaForNode(storeName, quotaType, 0, quota);
client.quotaMgmtOps.rebalanceQuota(storeName, quotaType);
// rebalanceQuota use put. Put completes as soon as the required nodes
// are completed and rest of them are done in async. There is a race
// condition here if you poll too soon you will see inconsistent result,
// as some of the puts are still in async. Sleep here to avoid those
// conditions.
Thread.sleep(100);
Long getQuota0 = Long.parseLong(client.quotaMgmtOps.getQuotaForNode(storeName, quotaType, 0).getValue());
Long getQuota1 = Long.parseLong(client.quotaMgmtOps.getQuotaForNode(storeName, quotaType, 1).getValue());
assertEquals(targetQuota, getQuota0);
assertEquals(targetQuota, getQuota1);
}
use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class VerifyOrAddStoreTest method verifyNewStoreAddition.
@Test
public void verifyNewStoreAddition() {
adminClient.storeMgmtOps.verifyOrAddStore(newStoreDef, PROCESS_NAME, service);
verifyStoreAddedOnAllNodes();
// Verify set quota on the stores as well.
for (QuotaType quotaType : new QuotaType[] { QuotaType.STORAGE_SPACE, QuotaType.GET_THROUGHPUT }) {
long newQuota = 100000 + new Random().nextInt(10000);
adminClient.quotaMgmtOps.setQuota(newStoreName, quotaType, newQuota, service);
for (Integer nodeId : cluster.getNodeIds()) {
Long retrievedQuota = getQuotaForNode(newStoreName, quotaType, nodeId);
assertEquals("Set and retrieved different quota", newQuota, retrievedQuota.longValue());
}
}
}
use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class ExceededQuotaSlopTest method setGetPutQuotasForEachServer.
public void setGetPutQuotasForEachServer() throws Exception {
Properties adminProperties = new Properties();
adminProperties.setProperty("max_connections", "2");
adminClient = new AdminClient(cluster, new AdminClientConfig().setMaxConnectionsPerNode(2));
Map<Pair<Integer, QuotaType>, Integer> throughPutMap = new HashMap<Pair<Integer, QuotaType>, Integer>();
// Set Node0 Quota
throughPutMap.put(new Pair<Integer, QuotaType>(0, QuotaType.PUT_THROUGHPUT), 5);
throughPutMap.put(new Pair<Integer, QuotaType>(0, QuotaType.GET_THROUGHPUT), 20);
// Set Node1 Quota
throughPutMap.put(new Pair<Integer, QuotaType>(1, QuotaType.PUT_THROUGHPUT), 2);
throughPutMap.put(new Pair<Integer, QuotaType>(1, QuotaType.GET_THROUGHPUT), 20);
for (Entry<Pair<Integer, QuotaType>, Integer> throughPut : throughPutMap.entrySet()) {
int nodeId = throughPut.getKey().getFirst();
QuotaType type = throughPut.getKey().getSecond();
int value = throughPut.getValue();
VectorClock clock = VectorClockUtils.makeClockWithCurrentTime(cluster.getNodeIds());
NodeValue<ByteArray, byte[]> operationValue = new NodeValue<ByteArray, byte[]>(nodeId, new ByteArray(getKeyBytes(type)), new Versioned<byte[]>(ByteUtils.getBytes(Integer.toString(value), encodingType), clock));
try {
adminClient.storeOps.putNodeKeyValue(quotaStoreName, operationValue);
} catch (Exception e) {
throw new Exception("Exception when setting put quota for node " + nodeId + " Operation " + type + "." + e.getMessage());
}
}
}
use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class QuotaOperationsTest method testQuotaSetAndUnset.
@Test
public void testQuotaSetAndUnset() throws Exception {
for (QuotaType quotaType : QuotaType.values()) {
String quotaValueToSet = "1000";
// set quota value
AdminCommand.executeCommand(new String[] { "quota", "set", quotaType + "=" + quotaValueToSet, "-s", storeName, "-u", bsURL, "--confirm" });
// get quota value
String quotaValueToVerify = adminClient.quotaMgmtOps.getQuota(storeName, quotaType).getValue();
assertTrue(quotaValueToVerify.equals(quotaValueToSet));
// unset quota value
AdminCommand.executeCommand(new String[] { "quota", "unset", quotaType.toString(), "-s", storeName, "-u", bsURL, "--confirm" });
// get quota value
Versioned<String> versionedQuotaValueToVerify = adminClient.quotaMgmtOps.getQuota(storeName, quotaType);
assertNull("Value retrieved should be null" + versionedQuotaValueToVerify, versionedQuotaValueToVerify);
}
}
use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class AdminToolUtils method getQuotaTypes.
/**
* Utility function that fetches quota types.
*/
public static List<QuotaType> getQuotaTypes(List<String> strQuotaTypes) {
if (strQuotaTypes.size() < 1) {
throw new VoldemortException("Quota type not specified.");
}
List<QuotaType> quotaTypes;
if (strQuotaTypes.size() == 1 && strQuotaTypes.get(0).equals(AdminToolUtils.QUOTATYPE_ALL)) {
quotaTypes = Arrays.asList(QuotaType.values());
} else {
quotaTypes = new ArrayList<QuotaType>();
for (String strQuotaType : strQuotaTypes) {
QuotaType type = QuotaType.valueOf(strQuotaType);
quotaTypes.add(type);
}
}
return quotaTypes;
}
Aggregations