Search in sources :

Example 16 with PersistenceFailureException

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;
}
Also used : File(java.io.File) PersistenceFailureException(voldemort.store.PersistenceFailureException)

Example 17 with PersistenceFailureException

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);
}
Also used : ByteArray(voldemort.utils.ByteArray) InMemoryPutAssertionStorageEngine(voldemort.store.memory.InMemoryPutAssertionStorageEngine) SleepyStore(voldemort.store.SleepyStore) ForceFailStore(voldemort.store.ForceFailStore) PersistenceFailureException(voldemort.store.PersistenceFailureException)

Example 18 with PersistenceFailureException

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()));
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) PersistenceFailureException(voldemort.store.PersistenceFailureException) LockTimeoutException(com.sleepycat.je.LockTimeoutException) AbstractStorageEngineTest(voldemort.store.AbstractStorageEngineTest) Test(org.junit.Test)

Example 19 with PersistenceFailureException

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!");
        }
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) ArrayList(java.util.ArrayList) List(java.util.List) PersistenceFailureException(voldemort.store.PersistenceFailureException) Test(org.junit.Test)

Example 20 with PersistenceFailureException

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");
    }
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) PersistenceFailureException(voldemort.store.PersistenceFailureException) Test(org.junit.Test)

Aggregations

PersistenceFailureException (voldemort.store.PersistenceFailureException)26 Versioned (voldemort.versioning.Versioned)13 ByteArray (voldemort.utils.ByteArray)9 Connection (java.sql.Connection)6 PreparedStatement (java.sql.PreparedStatement)6 SQLException (java.sql.SQLException)6 DatabaseEntry (com.sleepycat.je.DatabaseEntry)5 DatabaseException (com.sleepycat.je.DatabaseException)5 OperationStatus (com.sleepycat.je.OperationStatus)5 ResultSet (java.sql.ResultSet)5 Test (org.junit.Test)5 AsyncOperationStatus (voldemort.server.protocol.admin.AsyncOperationStatus)5 Transaction (com.sleepycat.je.Transaction)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 RocksDBException (org.rocksdb.RocksDBException)4 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)4 VectorClock (voldemort.versioning.VectorClock)4 Occurred (voldemort.versioning.Occurred)3 LockTimeoutException (com.sleepycat.je.LockTimeoutException)2