use of com.thinkaurelius.titan.diskstorage.StorageException in project titan by thinkaurelius.
the class ConsistentKeyLockerTest method testWriteLockThrowsExceptionAfterMaxStoreTimeouts.
/**
* Test locker when all three attempts to write a lock succeed but take
* longer than the wait limit. We expect the locker to delete all three
* columns that it wrote and locally unlock the KeyColumn, then emit an
* exception.
*
* @throws StorageException shouldn't happen
*/
@Test
public void testWriteLockThrowsExceptionAfterMaxStoreTimeouts() throws StorageException {
expect(lockState.has(defaultTx, defaultLockID)).andReturn(false);
recordSuccessfulLocalLock();
StaticBuffer firstCol = recordSuccessfulLockWrite(5, TimeUnit.SECONDS, null).col;
StaticBuffer secondCol = recordSuccessfulLockWrite(5, TimeUnit.SECONDS, firstCol).col;
StaticBuffer thirdCol = recordSuccessfulLockWrite(5, TimeUnit.SECONDS, secondCol).col;
recordSuccessfulLockDelete(1, TimeUnit.NANOSECONDS, thirdCol);
recordSuccessfulLocalUnlock();
ctrl.replay();
StorageException expected = null;
try {
// SUT
locker.writeLock(defaultLockID, defaultTx);
} catch (TemporaryStorageException e) {
expected = e;
}
assertNotNull(expected);
}
use of com.thinkaurelius.titan.diskstorage.StorageException in project titan by thinkaurelius.
the class KCVSConfiguration method getConfigurationProperty.
/**
* Reads the configuration property for this StoreManager
*
* @param key Key identifying the configuration property
* @return Value stored for the key or null if the configuration property has not (yet) been defined.
* @throws StorageException
*/
public String getConfigurationProperty(final String key) throws StorageException {
StaticBuffer column = string2StaticBuffer(key);
final KeySliceQuery query = new KeySliceQuery(rowKey, column, ByteBufferUtil.nextBiggerBuffer(column), false);
StaticBuffer result = BackendOperation.execute(new Callable<StaticBuffer>() {
@Override
public StaticBuffer call() throws Exception {
StoreTransaction txh = null;
try {
txh = manager.beginTransaction(new StoreTxConfig(ConsistencyLevel.KEY_CONSISTENT));
List<Entry> entries = store.getSlice(query, txh);
if (entries.isEmpty())
return null;
return entries.get(0).getValue();
} finally {
if (txh != null)
txh.commit();
}
}
@Override
public String toString() {
return "getConfiguration";
}
}, maxOperationWaitTime);
if (result == null)
return null;
return staticBuffer2String(result);
}
use of com.thinkaurelius.titan.diskstorage.StorageException in project titan by thinkaurelius.
the class StandardTitanGraph method newTransaction.
public StandardTitanTx newTransaction(TransactionConfiguration configuration) {
if (!isOpen)
ExceptionFactory.graphShutdown();
try {
IndexSerializer.IndexInfoRetriever retriever = indexSerializer.getIndexInforRetriever();
StandardTitanTx tx = new StandardTitanTx(this, configuration, backend.beginTransaction(configuration, retriever));
retriever.setTransaction(tx);
return tx;
} catch (StorageException e) {
throw new TitanException("Could not start new transaction", e);
}
}
use of com.thinkaurelius.titan.diskstorage.StorageException in project titan by thinkaurelius.
the class StandardIDPool method renewBuffer.
private void renewBuffer() {
Preconditions.checkArgument(bufferNextID == BUFFER_EMPTY, bufferNextID);
Preconditions.checkArgument(bufferMaxID == BUFFER_EMPTY, bufferMaxID);
try {
long[] idblock = idAuthority.getIDBlock(partitionID);
bufferNextID = idblock[0];
bufferMaxID = idblock[1];
Preconditions.checkArgument(bufferNextID > 0, bufferNextID);
Preconditions.checkArgument(bufferMaxID > bufferNextID, bufferMaxID);
} catch (StorageException e) {
throw new TitanException("Could not acquire new ID block from storage", e);
} catch (IDPoolExhaustedException e) {
bufferNextID = BUFFER_POOL_EXHAUSTION;
bufferMaxID = BUFFER_POOL_EXHAUSTION;
}
}
use of com.thinkaurelius.titan.diskstorage.StorageException in project titan by thinkaurelius.
the class BackendOperation method execute.
public static final <V> V execute(Callable<V> exe, int maxRetryAttempts, long retryWaittime) throws TitanException {
Preconditions.checkArgument(maxRetryAttempts > 0, "Retry attempts must be positive");
Preconditions.checkArgument(retryWaittime >= 0, "Retry wait time must be non-negative");
int retryAttempts = 0;
StorageException lastException = null;
do {
try {
return exe.call();
} catch (StorageException e) {
if (e instanceof TemporaryStorageException)
lastException = e;
else
// Its permanent
throw new TitanException("Permanent exception during backend operation", e);
} catch (Throwable e) {
throw new TitanException("Unexpected exception during backend operation", e);
}
// Wait and retry
retryAttempts++;
Preconditions.checkNotNull(lastException);
if (retryAttempts < maxRetryAttempts) {
long waitTime = Math.round(retryWaittime + ((Math.random() * WAITTIME_PERTURBATION_PERCENTAGE - WAITTIME_PERTURBATION_PERCENTAGE_HALF) * retryWaittime));
Preconditions.checkArgument(waitTime >= 0, "Invalid wait time: %s", waitTime);
log.info("Temporary storage exception during backend operation [{}]. Attempting incremental retry", exe.toString(), lastException);
try {
Thread.sleep(waitTime);
} catch (InterruptedException r) {
throw new TitanException("Interrupted while waiting to retry failed backend operation", r);
}
}
} while (retryAttempts < maxRetryAttempts);
throw new TitanException("Could not successfully complete backend operation due to repeated temporary exceptions after " + maxRetryAttempts + " attempts", lastException);
}
Aggregations