use of voldemort.store.PersistenceFailureException in project voldemort by voldemort.
the class StoreVersionManager method getDisabledMarkerFile.
/**
* Gets the '.disabled' file for a given version of this store. That file may or may not
* exist.
*
* @param version of the store for which to get the '.disabled' file.
* @return an instance of {@link File} pointing to the '.disabled' file.
* @throws PersistenceFailureException if the requested version cannot be found.
*/
private File getDisabledMarkerFile(long version) throws PersistenceFailureException {
File[] versionDirArray = ReadOnlyUtils.getVersionDirs(rootDir, version, version);
if (versionDirArray.length == 0) {
throw new PersistenceFailureException("getDisabledMarkerFile did not find the requested version directory" + " on disk. Version: " + version + ", rootDir: " + rootDir);
}
File disabledMarkerFile = new File(versionDirArray[0], DISABLED_MARKER_NAME);
return disabledMarkerFile;
}
use of voldemort.store.PersistenceFailureException in project voldemort by voldemort.
the class HintedHandoffTestEnvironment method createInnerStore.
/**
* Create inner store and storage engines before server starts
*
* @param nodeId
*/
public void createInnerStore(int nodeId) {
Store<ByteArray, byte[], byte[]> realStore = new InMemoryPutAssertionStorageEngine<ByteArray, byte[], byte[]>(STORE_NAME);
ForceFailStore<ByteArray, byte[], byte[]> forceFailStore = new ForceFailStore<ByteArray, byte[], byte[]>(realStore, new PersistenceFailureException("Force failed"));
SleepyStore<ByteArray, byte[], byte[]> sleepyStore = new SleepyStore<ByteArray, byte[], byte[]>(0, forceFailStore);
realStores.put(nodeId, realStore);
forceFailStores.put(nodeId, forceFailStore);
sleepyStores.put(nodeId, sleepyStore);
}
use of voldemort.store.PersistenceFailureException in project voldemort by voldemort.
the class BdbStorageEngineTest method testGetAndLock.
@Test(timeout = 30000)
public void testGetAndLock() throws Exception {
final ByteArray key = new ByteArray("getAndLock".getBytes());
final byte[] valueBytes = "bar".getBytes();
store.put(key, new Versioned<byte[]>(valueBytes), null);
KeyLockHandle<byte[]> handle = store.getAndLock(key);
// get will block and timeout
try {
store.get(key, null);
fail("get(..) should have blocked and timedout");
} catch (PersistenceFailureException pfe) {
// expected
assertTrue("Should have had a LockTimeoutException", pfe.getCause() instanceof LockTimeoutException);
}
// let go of the key lock
store.releaseLock(handle);
// get should not block, since the lock has been released
List<Versioned<byte[]>> vals = store.get(key, null);
assertEquals("Should read back the version previously written", 1, vals.size());
assertEquals("Should read back the version previously written", new ByteArray(valueBytes), new ByteArray(vals.get(0).getValue()));
}
use of voldemort.store.PersistenceFailureException in project voldemort by voldemort.
the class RocksdbStorageEngineAPITest method testGetAll.
@Test
public void testGetAll() {
logger.info("*********** testing get all ***********");
Map<ByteArray, Versioned<byte[]>> expected = new java.util.HashMap<ByteArray, Versioned<byte[]>>();
ByteArray key1, key2;
Versioned<byte[]> value1, value2;
key1 = generateRandomKeys(50);
value1 = generateVersionedValue(100);
try {
// do first put
this.rocksDbStore.put(key1, value1, null);
} catch (PersistenceFailureException pfe) {
Assert.fail("Could not do a put. Unexpectedlt getting exception - " + pfe.getMessage());
}
expected.put(key1, value1);
key2 = generateRandomKeys(50);
value2 = generateVersionedValue(100);
try {
// do second put
this.rocksDbStore.put(key2, value2, null);
} catch (PersistenceFailureException pfe) {
Assert.fail("Could not do a put. Unexpectedlt getting exception - " + pfe.getMessage());
}
expected.put(key2, value2);
Map<ByteArray, List<Versioned<byte[]>>> found = null;
try {
// do getall
found = this.rocksDbStore.getAll(expected.keySet(), null);
} catch (PersistenceFailureException pfe) {
Assert.fail("Get all operation did not succeed for some reason - " + pfe.getMessage());
}
if (found.size() == 0) {
Assert.fail("GetAll returned an empty value unexpectedly");
}
// Checking if the values are same. May need to check the version later
for (ByteArray key : found.keySet()) {
Versioned<byte[]> value = found.get(key).get(0);
if (ByteUtils.compare(value.getValue(), expected.get(key).getValue()) != 0) {
Assert.fail("The found value and expected value don't match!");
}
}
}
use of voldemort.store.PersistenceFailureException in project voldemort by voldemort.
the class RocksdbStorageEngineAPITest method testGetAfterPut.
@Test
public void testGetAfterPut() {
logger.info("*********** testing get after put ***********");
// generate random bytes for key
ByteArray key = generateRandomKeys(100);
// generate random bytes for values
Versioned<byte[]> versionedValue = generateVersionedValue(100);
try {
// Do put
this.rocksDbStore.put(key, versionedValue, null);
} catch (PersistenceFailureException pfe) {
Assert.fail("initial put failed unexpectedly. Exception: " + pfe.getMessage());
}
List<Versioned<byte[]>> found = null;
// Do a get now to see if key exists
try {
found = this.rocksDbStore.get(key, null);
} catch (PersistenceFailureException pfe) {
Assert.fail("read after write unexpectedly throws Exception - " + pfe.getMessage());
}
if (found != null && found.size() > 0) {
if (ByteUtils.compare(versionedValue.getValue(), found.get(0).getValue()) != 0) {
Assert.fail("The returned value and the expected value is not same");
}
} else {
Assert.fail("Either returned value is null or empty");
}
}
Aggregations