BdbStorageEngine storeA = null;
bdbStorage = new BdbStorageConfiguration(voldemortConfig);
assertEquals("Reserved cache size not zero", 0, bdbStorage.getReservedCacheSize());
try {
StoreDefinition defA = TestUtils.makeStoreDefinition("storeA", shareA
/ ByteUtils.BYTES_PER_MB);
storeA = (BdbStorageEngine) bdbStorage.getStore(defA,
TestUtils.makeSingleNodeRoutingStrategy());
fail("Should have thrown exception since minSharedCache will be violated");
} catch(StorageInitializationException sie) {
// should come here.
}
// failing operations should not alter reserved cache size
assertEquals("failure somehow altered the reservedCacheSize",
0,
bdbStorage.getReservedCacheSize());
voldemortConfig.setBdbMinimumSharedCache(10 * ByteUtils.BYTES_PER_MB);
bdbStorage = new BdbStorageConfiguration(voldemortConfig);
try {
StoreDefinition defA = TestUtils.makeStoreDefinition("storeA", shareA
/ ByteUtils.BYTES_PER_MB);
storeA = (BdbStorageEngine) bdbStorage.getStore(defA,
TestUtils.makeSingleNodeRoutingStrategy());
} catch(StorageInitializationException sie) {
// should not come here.
fail("minSharedCache should n't have been violated");
}
assertEquals("store A's share does not match up with reserved cache size",
shareA,
bdbStorage.getReservedCacheSize());
long reserveCacheSize = bdbStorage.getReservedCacheSize();
// now, try increasing the reservation dynamically and it should fail
try {
StoreDefinition defA = TestUtils.makeStoreDefinition("storeA", 15);
bdbStorage.update(defA);
fail("Should have thrown exception since minSharedCache will be violated");
} catch(StorageInitializationException sie) {
// should come here.
}