Search in sources :

Example 1 with PermanentStorageException

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

the class AstyanaxStoreManager method getCompressionOptions.

@Override
public Map<String, String> getCompressionOptions(String cf) throws StorageException {
    try {
        Keyspace k = keyspaceContext.getClient();
        KeyspaceDefinition kdef = k.describeKeyspace();
        if (null == kdef) {
            throw new PermanentStorageException("Keyspace " + k.getKeyspaceName() + " is undefined");
        }
        ColumnFamilyDefinition cfdef = kdef.getColumnFamily(cf);
        if (null == cfdef) {
            throw new PermanentStorageException("Column family " + cf + " is undefined");
        }
        return cfdef.getCompressionOptions();
    } catch (ConnectionException e) {
        throw new PermanentStorageException(e);
    }
}
Also used : KeyspaceDefinition(com.netflix.astyanax.ddl.KeyspaceDefinition) ColumnFamilyDefinition(com.netflix.astyanax.ddl.ColumnFamilyDefinition) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException)

Example 2 with PermanentStorageException

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

the class AstyanaxStoreManager method getRetryPolicy.

private static RetryPolicy getRetryPolicy(String serializedRetryPolicy) throws StorageException {
    String[] tokens = serializedRetryPolicy.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 {
        RetryPolicy rp = instantiate(policyClassName, args, serializedRetryPolicy);
        log.debug("Instantiated RetryPolicy object {} from config string \"{}\"", rp, serializedRetryPolicy);
        return rp;
    } catch (Exception e) {
        throw new PermanentStorageException("Failed to instantiate Astyanax Retry Policy class", e);
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) RetryPolicy(com.netflix.astyanax.retry.RetryPolicy) 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 3 with PermanentStorageException

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

the class CassandraEmbeddedStoreManager method ensureColumnFamilyExists.

private void ensureColumnFamilyExists(String keyspaceName, String columnfamilyName, AbstractType comparator) throws StorageException {
    if (null != Schema.instance.getCFMetaData(keyspaceName, columnfamilyName))
        return;
    // Column Family not found; create it
    CFMetaData cfm = new CFMetaData(keyspaceName, columnfamilyName, ColumnFamilyType.Standard, comparator, null);
    // Hard-coded caching settings
    if (columnfamilyName.startsWith(Backend.EDGESTORE_NAME)) {
        cfm.caching(Caching.KEYS_ONLY);
    } else if (columnfamilyName.startsWith(Backend.VERTEXINDEX_STORE_NAME)) {
        cfm.caching(Caching.ROWS_ONLY);
    }
    // Configure sstable compression
    final CompressionParameters cp;
    if (compressionEnabled) {
        try {
            cp = new CompressionParameters(compressionClass, compressionChunkSizeKB * 1024, Collections.<String, String>emptyMap());
            // CompressionParameters doesn't override toString(), so be explicit
            log.debug("Creating CF {}: setting {}={} and {}={} on {}", new Object[] { columnfamilyName, CompressionParameters.SSTABLE_COMPRESSION, compressionClass, CompressionParameters.CHUNK_LENGTH_KB, compressionChunkSizeKB, cp });
        } catch (ConfigurationException ce) {
            throw new PermanentStorageException(ce);
        }
    } else {
        cp = new CompressionParameters(null);
        log.debug("Creating CF {}: setting {} to null to disable compression", columnfamilyName, CompressionParameters.SSTABLE_COMPRESSION);
    }
    cfm.compressionParameters(cp);
    try {
        cfm.addDefaultIndexNames();
    } catch (ConfigurationException e) {
        throw new PermanentStorageException("Failed to create column family metadata for " + keyspaceName + ":" + columnfamilyName, e);
    }
    try {
        MigrationManager.announceNewColumnFamily(cfm);
    } catch (ConfigurationException e) {
        throw new PermanentStorageException("Failed to create column family " + keyspaceName + ":" + columnfamilyName, e);
    }
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) CompressionParameters(org.apache.cassandra.io.compress.CompressionParameters) CFMetaData(org.apache.cassandra.config.CFMetaData)

Example 4 with PermanentStorageException

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

the class BerkeleyJETx method commit.

@Override
public synchronized void commit() throws StorageException {
    super.commit();
    if (tx == null)
        return;
    try {
        closeOpenIterators();
        tx.commit();
        tx = null;
    } catch (DatabaseException e) {
        throw new PermanentStorageException(e);
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) DatabaseException(com.sleepycat.je.DatabaseException)

Example 5 with PermanentStorageException

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

the class BerkeleyJETx method rollback.

@Override
public synchronized void rollback() throws StorageException {
    super.rollback();
    if (tx == null)
        return;
    try {
        closeOpenIterators();
        tx.abort();
        tx = null;
    } catch (DatabaseException e) {
        throw new PermanentStorageException(e);
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) DatabaseException(com.sleepycat.je.DatabaseException)

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