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);
}
}
}
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);
}
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);
}
}
}
Aggregations