Search in sources :

Example 6 with PersistitException

use of com.persistit.exception.PersistitException in project titan by thinkaurelius.

the class PersistitTransaction method getExchange.

public Exchange getExchange(String treeName, Boolean create) throws StorageException {
    synchronized (this) {
        Exchange exchange;
        try {
            assign();
            exchange = db.getExchange(VOLUME_NAME, treeName, create);
            return exchange;
        } catch (PersistitException ex) {
            throw new PermanentStorageException(ex);
        }
    }
}
Also used : Exchange(com.persistit.Exchange) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) PersistitException(com.persistit.exception.PersistitException)

Example 7 with PersistitException

use of com.persistit.exception.PersistitException 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 8 with PersistitException

use of com.persistit.exception.PersistitException 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 9 with PersistitException

use of com.persistit.exception.PersistitException 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

PersistitException (com.persistit.exception.PersistitException)9 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)9 Exchange (com.persistit.Exchange)2 Transaction (com.persistit.Transaction)1 Volume (com.persistit.Volume)1 RollbackException (com.persistit.exception.RollbackException)1 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)1 AbstractStoreTransaction (com.thinkaurelius.titan.diskstorage.common.AbstractStoreTransaction)1 KeyValueEntry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.keyvalue.KeyValueEntry)1 RecordIterator (com.thinkaurelius.titan.diskstorage.util.RecordIterator)1