use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class ConsistentKeyLockerTest method testCheckLocksDiesOnPermanentStorageException.
/**
* A single PermanentStorageException on getSlice() for a single lock is
* sufficient to make the method return immediately (regardless of whether
* other locks are waiting to be checked).
*
* @throws InterruptedException shouldn't happen
* @throws StorageException shouldn't happen
*/
@Test
public void testCheckLocksDiesOnPermanentStorageException() throws InterruptedException, StorageException {
// Setup a LockStatus for defaultLockID
ConsistentKeyLockStatus lockStatus = makeStatusNow();
currentTimeNS += TimeUnit.NANOSECONDS.convert(1, TimeUnit.NANOSECONDS);
expect(lockState.getLocksForTx(defaultTx)).andReturn(ImmutableMap.of(defaultLockID, lockStatus));
expect(times.sleepUntil(lockStatus.getWriteTimestamp(TimeUnit.NANOSECONDS) + defaultWaitNS)).andReturn(currentTimeNS);
// First and only getSlice call throws a PSE
recordExceptionalLockGetSlice(new PermanentStorageException("Connection to storage cluster failed: peer is an IPv6 toaster"));
ctrl.replay();
PermanentStorageException pse = null;
try {
locker.checkLocks(defaultTx);
} catch (PermanentStorageException e) {
pse = e;
}
assertNotNull(pse);
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class ConsistentKeyLockerTest method testWriteLockDiesOnPermanentStorageException.
/**
* Test that the first {@link PermanentStorageException} thrown by the
* locker's store causes it to attempt to delete outstanding lock writes and
* then emit the exception without retrying.
*
* @throws StorageException shouldn't happen
*/
@Test
public void testWriteLockDiesOnPermanentStorageException() throws StorageException {
PermanentStorageException errOnFire = new PermanentStorageException("Storage cluster is on fire");
expect(lockState.has(defaultTx, defaultLockID)).andReturn(false);
recordSuccessfulLocalLock();
StaticBuffer lockCol = recordExceptionLockWrite(1, TimeUnit.NANOSECONDS, null, errOnFire);
recordSuccessfulLockDelete(1, TimeUnit.NANOSECONDS, lockCol);
recordSuccessfulLocalUnlock();
ctrl.replay();
StorageException expected = null;
try {
// SUT
locker.writeLock(defaultLockID, defaultTx);
} catch (PermanentLockingException e) {
expected = e;
}
assertNotNull(expected);
assertEquals(errOnFire, expected.getCause());
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class AstyanaxStoreManager method clearStorage.
@Override
public void clearStorage() throws StorageException {
try {
Cluster cluster = clusterContext.getClient();
Keyspace ks = cluster.getKeyspace(keySpaceName);
// everything up, so first invocation would always fail as Keyspace doesn't yet exist.
if (ks == null)
return;
for (ColumnFamilyDefinition cf : cluster.describeKeyspace(keySpaceName).getColumnFamilyList()) {
ks.truncateColumnFamily(new ColumnFamily<Object, Object>(cf.getName(), null, null));
}
} catch (ConnectionException e) {
throw new PermanentStorageException(e);
}
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class AstyanaxStoreManager method getRetryBackoffStrategy.
private static RetryBackoffStrategy getRetryBackoffStrategy(String desc) throws PermanentStorageException {
if (null == desc)
return null;
String[] tokens = desc.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 {
RetryBackoffStrategy rbs = instantiate(policyClassName, args, desc);
log.debug("Instantiated RetryBackoffStrategy object {} from config string \"{}\"", rbs, desc);
return rbs;
} catch (Exception e) {
throw new PermanentStorageException("Failed to instantiate Astyanax RetryBackoffStrategy implementation", e);
}
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class CassandraEmbeddedStoreManager method ensureKeyspaceExists.
private void ensureKeyspaceExists(String keyspaceName) throws StorageException {
if (null != Schema.instance.getTableInstance(keyspaceName))
return;
// Keyspace not found; create it
String strategyName = "org.apache.cassandra.locator.SimpleStrategy";
Map<String, String> options = new HashMap<String, String>() {
{
put("replication_factor", String.valueOf(replicationFactor));
}
};
KSMetaData ksm;
try {
ksm = KSMetaData.newKeyspace(keyspaceName, strategyName, options, true);
} catch (ConfigurationException e) {
throw new PermanentStorageException("Failed to instantiate keyspace metadata for " + keyspaceName, e);
}
try {
MigrationManager.announceNewKeyspace(ksm);
log.debug("Created keyspace {}", keyspaceName);
} catch (ConfigurationException e) {
throw new PermanentStorageException("Failed to create keyspace " + keyspaceName, e);
}
}
Aggregations