Search in sources :

Example 41 with PermanentStorageException

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

the class PersistitKeyValueStore method insert.

@Override
public void insert(final StaticBuffer key, final StaticBuffer value, final StoreTransaction txh) throws StorageException {
    final PersistitTransaction tx = (PersistitTransaction) txh;
    synchronized (tx) {
        tx.assign();
        final Exchange exchange = tx.getExchange(name);
        try {
            toKey(exchange, key);
            setValue(exchange, value);
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        } finally {
            tx.releaseExchange(exchange);
        }
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException)

Example 42 with PermanentStorageException

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

the class PersistitStoreManager method clearStorage.

@Override
public void clearStorage() throws StorageException {
    for (String key : stores.keySet()) {
        PersistitKeyValueStore store = stores.remove(key);
        store.clear();
    }
    Volume volume;
    String[] treeNames;
    try {
        volume = db.getVolume(VOLUME_NAME);
        treeNames = volume.getTreeNames();
    } catch (PersistitException ex) {
        throw new PermanentStorageException(ex);
    }
    for (String treeName : treeNames) {
        try {
            Exchange ex = new Exchange(db, volume, treeName, false);
            ex.removeTree();
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        }
    }
    close();
    IOUtils.deleteFromDirectory(directory);
}
Also used : Exchange(com.persistit.Exchange) Volume(com.persistit.Volume) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException)

Example 43 with PermanentStorageException

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

the class PersistitTransaction method commit.

@Override
public void commit() throws StorageException {
    synchronized (this) {
        if (null == sessionId) {
            // Already closed
            log.warn("Can't commit {}: already closed, trace to redundant commit follows", this, new IllegalStateException("redundant commit"));
            return;
        }
        super.commit();
        assign();
        Transaction tx = db.getTransaction();
        int retries = 3;
        try {
            if (tx.isActive() && !tx.isRollbackPending()) {
                int i = 0;
                while (true) {
                    try {
                        tx.commit(Transaction.CommitPolicy.HARD);
                        tx.end();
                        break;
                    } catch (RollbackException ex) {
                        if (i++ >= retries) {
                            throw ex;
                        }
                    }
                }
                close();
            }
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        }
    }
}
Also used : AbstractStoreTransaction(com.thinkaurelius.titan.diskstorage.common.AbstractStoreTransaction) Transaction(com.persistit.Transaction) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException) RollbackException(com.persistit.exception.RollbackException)

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