use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class VerifyOrAddStoreTest method verifyCreateWithNodeFailure.
@Test
public void verifyCreateWithNodeFailure() throws Exception {
ServerTestUtils.stopVoldemortServer(servers[FAILED_NODE_ID]);
// Set CreateStore to false, node down should have thrown an error
try {
adminClient.storeMgmtOps.verifyOrAddStore(newStoreDef, PROCESS_NAME, false, service);
Assert.fail("Node failure should have raised an error");
} catch (VoldemortException ex) {
// Pass
}
// Verify that.
for (Integer nodeId : cluster.getNodeIds()) {
if (nodeId == FAILED_NODE_ID) {
// this is a dead server, continue;
} else {
StoreDefinition retrieved = retrieveStoreOnNode(newStoreName, nodeId);
assertNull("store should not exist", retrieved);
}
}
// nodes that are up and thrown an exception at the end.
try {
adminClient.storeMgmtOps.verifyOrAddStore(newStoreDef, PROCESS_NAME, service);
Assert.fail("Node failure should have raised an error");
} catch (VoldemortException ex) {
// Pass
}
// Verify that.
for (Integer nodeId : cluster.getNodeIds()) {
if (nodeId == FAILED_NODE_ID) {
// this is a dead server, continue;
} else {
StoreDefinition retrieved = retrieveStoreOnNode(newStoreName, nodeId);
assertEquals("store successfully created on online nodes", newStoreDef, retrieved);
}
}
// 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);
try {
adminClient.quotaMgmtOps.setQuota(newStoreName, quotaType, newQuota, service);
Assert.fail("Node failure should have raised an error");
} catch (VoldemortException ex) {
// expected.
}
for (Integer nodeId : cluster.getNodeIds()) {
if (nodeId == FAILED_NODE_ID) {
// this is dead server, continue.
} else {
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 VerifyOrAddStoreTest method verifyAdminClientAcrossNodeRestart.
@Test
public void verifyAdminClientAcrossNodeRestart() throws Exception {
long newQuota = 500000 + new Random().nextInt(10000);
// Do a query create the connections.
adminClient.storeMgmtOps.verifyOrAddStore(newStoreDef, PROCESS_NAME, service);
// Create client pool as well.
for (QuotaType quotaType : new QuotaType[] { QuotaType.STORAGE_SPACE, QuotaType.GET_THROUGHPUT }) {
adminClient.quotaMgmtOps.setQuota(newStoreName, quotaType, newQuota, service);
}
ServerTestUtils.stopVoldemortServer(servers[FAILED_NODE_ID]);
try {
retrieveStoreOnNode(newStoreName, FAILED_NODE_ID);
Assert.fail("Downed node retrieval should have thrown an error");
} catch (VoldemortException ex) {
// Expected
}
try {
adminClient.storeMgmtOps.verifyOrAddStore(newStoreDef, PROCESS_NAME, service);
Assert.fail("Downed node should have thrown an error");
} catch (VoldemortException ex) {
// Expected
}
// setQuota should throw as well.
for (QuotaType quotaType : new QuotaType[] { QuotaType.STORAGE_SPACE, QuotaType.GET_THROUGHPUT }) {
try {
adminClient.quotaMgmtOps.setQuota(newStoreName, quotaType, newQuota, service);
Assert.fail("Node failure should have raised an error");
} catch (VoldemortException ex) {
// expected.
}
}
servers[FAILED_NODE_ID] = ServerTestUtils.restartServer(servers[FAILED_NODE_ID], FAILED_NODE_ID, cluster, serverProps);
StoreDefinition retrieved = retrieveStoreOnNode(newStoreName, FAILED_NODE_ID);
assertEquals("After restart, should retrieve the store", newStoreDef, retrieved);
adminClient.storeMgmtOps.verifyOrAddStore(newStoreDef, PROCESS_NAME, service);
long updatedQuota = newQuota + 100;
for (QuotaType quotaType : new QuotaType[] { QuotaType.STORAGE_SPACE, QuotaType.GET_THROUGHPUT }) {
adminClient.quotaMgmtOps.setQuota(newStoreName, quotaType, updatedQuota, service);
for (Integer nodeId : cluster.getNodeIds()) {
Long retrievedQuota = getQuotaForNode(newStoreName, quotaType, nodeId);
assertEquals("Set and retrieved different quota", updatedQuota, retrievedQuota.longValue());
}
}
}
use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class QuotaTest method testBasicOperation.
@Test
public void testBasicOperation() {
String storeName = stores.get(0).getName();
for (QuotaType quotaType : QuotaType.values()) {
verifyNoQuota(storeName, quotaType);
// Create
int newQuota = new Random().nextInt(Integer.MAX_VALUE);
adminClient.quotaMgmtOps.setQuota(storeName, quotaType, newQuota);
verifyValidQuota(storeName, quotaType, newQuota);
// Update
newQuota = new Random().nextInt(Integer.MAX_VALUE);
adminClient.quotaMgmtOps.setQuota(storeName, quotaType, newQuota);
verifyValidQuota(storeName, quotaType, newQuota);
// Delete
adminClient.quotaMgmtOps.unsetQuota(storeName, quotaType);
verifyNoQuota(storeName, quotaType);
}
}
use of voldemort.store.quota.QuotaType in project voldemort by voldemort.
the class QuotaTest method testGetAllQuota.
@Test
public void testGetAllQuota() {
for (QuotaType quotaType : QuotaType.values()) {
List<String> existingStoreNames = new ArrayList<String>();
Map<String, Integer> storeQuotas = new HashMap<String, Integer>();
for (StoreDefinition store : stores) {
String storeName = store.getName();
existingStoreNames.add(storeName);
int quota = new Random().nextInt();
storeQuotas.put(storeName, quota);
adminClient.quotaMgmtOps.setQuota(storeName, quotaType, quota);
}
// All stores in some order
Collections.shuffle(existingStoreNames);
verifyGetAll(existingStoreNames, storeQuotas, quotaType);
// Pick subset of stores.
final int REQUIRED_ELEMENTS = 3;
int numElements = REQUIRED_ELEMENTS + new Random().nextInt(existingStoreNames.size() - REQUIRED_ELEMENTS);
List<String> fewStores = existingStoreNames.subList(0, numElements);
verifyGetAll(fewStores, storeQuotas, quotaType);
// Pick few existing stores and few non-existent stores
List<String> mixedStores = new ArrayList<String>();
mixedStores.addAll(fewStores);
for (int i = 0; i < 10; i++) {
mixedStores.add("NON_EXISTENT_STORE" + i);
}
verifyGetAll(mixedStores, storeQuotas, quotaType);
}
}
Aggregations