Search in sources :

Example 26 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class ConsistentKeyLockerTest method testCheckLocksDiesOnPermanentStorageException.

/**
 * A single PermanentStorageException on getSlice() for a single lock is
 * sufficient to make the method return immediately (regardless of whether
 * other locks are waiting to be checked).
 *
 * @throws InterruptedException shouldn't happen
 * @throws StorageException     shouldn't happen
 */
@Test
public void testCheckLocksDiesOnPermanentStorageException() throws InterruptedException, StorageException {
    // Setup a LockStatus for defaultLockID
    ConsistentKeyLockStatus lockStatus = makeStatusNow();
    currentTimeNS += TimeUnit.NANOSECONDS.convert(1, TimeUnit.NANOSECONDS);
    expect(lockState.getLocksForTx(defaultTx)).andReturn(ImmutableMap.of(defaultLockID, lockStatus));
    expect(times.sleepUntil(lockStatus.getWriteTimestamp(TimeUnit.NANOSECONDS) + defaultWaitNS)).andReturn(currentTimeNS);
    // First and only getSlice call throws a PSE
    recordExceptionalLockGetSlice(new PermanentStorageException("Connection to storage cluster failed: peer is an IPv6 toaster"));
    ctrl.replay();
    PermanentStorageException pse = null;
    try {
        locker.checkLocks(defaultTx);
    } catch (PermanentStorageException e) {
        pse = e;
    }
    assertNotNull(pse);
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) ConsistentKeyLockStatus(com.thinkaurelius.titan.diskstorage.locking.consistentkey.ConsistentKeyLockStatus) Test(org.junit.Test)

Example 27 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class ConsistentKeyLockerTest method testWriteLockDiesOnPermanentStorageException.

/**
 * Test that the first {@link PermanentStorageException} thrown by the
 * locker's store causes it to attempt to delete outstanding lock writes and
 * then emit the exception without retrying.
 *
 * @throws StorageException shouldn't happen
 */
@Test
public void testWriteLockDiesOnPermanentStorageException() throws StorageException {
    PermanentStorageException errOnFire = new PermanentStorageException("Storage cluster is on fire");
    expect(lockState.has(defaultTx, defaultLockID)).andReturn(false);
    recordSuccessfulLocalLock();
    StaticBuffer lockCol = recordExceptionLockWrite(1, TimeUnit.NANOSECONDS, null, errOnFire);
    recordSuccessfulLockDelete(1, TimeUnit.NANOSECONDS, lockCol);
    recordSuccessfulLocalUnlock();
    ctrl.replay();
    StorageException expected = null;
    try {
        // SUT
        locker.writeLock(defaultLockID, defaultTx);
    } catch (PermanentLockingException e) {
        expected = e;
    }
    assertNotNull(expected);
    assertEquals(errOnFire, expected.getCause());
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) StorageException(com.thinkaurelius.titan.diskstorage.StorageException) Test(org.junit.Test)

Example 28 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class AstyanaxStoreManager method clearStorage.

@Override
public void clearStorage() throws StorageException {
    try {
        Cluster cluster = clusterContext.getClient();
        Keyspace ks = cluster.getKeyspace(keySpaceName);
        // everything up, so first invocation would always fail as Keyspace doesn't yet exist.
        if (ks == null)
            return;
        for (ColumnFamilyDefinition cf : cluster.describeKeyspace(keySpaceName).getColumnFamilyList()) {
            ks.truncateColumnFamily(new ColumnFamily<Object, Object>(cf.getName(), null, null));
        }
    } catch (ConnectionException e) {
        throw new PermanentStorageException(e);
    }
}
Also used : ColumnFamilyDefinition(com.netflix.astyanax.ddl.ColumnFamilyDefinition) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Example 29 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class AstyanaxStoreManager method getRetryBackoffStrategy.

private static RetryBackoffStrategy getRetryBackoffStrategy(String desc) throws PermanentStorageException {
    if (null == desc)
        return null;
    String[] tokens = desc.split(",");
    String policyClassName = tokens[0];
    int argCount = tokens.length - 1;
    Integer[] args = new Integer[argCount];
    for (int i = 1; i < tokens.length; i++) {
        args[i - 1] = Integer.valueOf(tokens[i]);
    }
    try {
        RetryBackoffStrategy rbs = instantiate(policyClassName, args, desc);
        log.debug("Instantiated RetryBackoffStrategy object {} from config string \"{}\"", rbs, desc);
        return rbs;
    } catch (Exception e) {
        throw new PermanentStorageException("Failed to instantiate Astyanax RetryBackoffStrategy implementation", e);
    }
}
Also used : RetryBackoffStrategy(com.netflix.astyanax.connectionpool.RetryBackoffStrategy) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) StorageException(com.thinkaurelius.titan.diskstorage.StorageException)

Example 30 with PermanentStorageException

use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.

the class CassandraEmbeddedStoreManager method ensureKeyspaceExists.

private void ensureKeyspaceExists(String keyspaceName) throws StorageException {
    if (null != Schema.instance.getTableInstance(keyspaceName))
        return;
    // Keyspace not found; create it
    String strategyName = "org.apache.cassandra.locator.SimpleStrategy";
    Map<String, String> options = new HashMap<String, String>() {

        {
            put("replication_factor", String.valueOf(replicationFactor));
        }
    };
    KSMetaData ksm;
    try {
        ksm = KSMetaData.newKeyspace(keyspaceName, strategyName, options, true);
    } catch (ConfigurationException e) {
        throw new PermanentStorageException("Failed to instantiate keyspace metadata for " + keyspaceName, e);
    }
    try {
        MigrationManager.announceNewKeyspace(ksm);
        log.debug("Created keyspace {}", keyspaceName);
    } catch (ConfigurationException e) {
        throw new PermanentStorageException("Failed to create keyspace " + keyspaceName, e);
    }
}
Also used : HashMap(java.util.HashMap) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) KSMetaData(org.apache.cassandra.config.KSMetaData)

Aggregations

PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)43 TemporaryStorageException (com.thinkaurelius.titan.diskstorage.TemporaryStorageException)14 StorageException (com.thinkaurelius.titan.diskstorage.StorageException)12 PersistitException (com.persistit.exception.PersistitException)9 IOException (java.io.IOException)8 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)6 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)5 ByteBuffer (java.nio.ByteBuffer)5 StaticByteBuffer (com.thinkaurelius.titan.diskstorage.util.StaticByteBuffer)4 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)4 StoreTransaction (com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction)3 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)3 ColumnFamilyDefinition (com.netflix.astyanax.ddl.ColumnFamilyDefinition)2 Exchange (com.persistit.Exchange)2 DatabaseException (com.sleepycat.je.DatabaseException)2 TitanException (com.thinkaurelius.titan.core.TitanException)2 CTConnection (com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection)2 Entry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.Entry)2 KeyValueEntry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.keyvalue.KeyValueEntry)2 ConsistentKeyLockStatus (com.thinkaurelius.titan.diskstorage.locking.consistentkey.ConsistentKeyLockStatus)2