use of com.netflix.astyanax.retry.RetryPolicy in project janusgraph by JanusGraph.
the class AstyanaxStoreManager method getRetryPolicy.
private static RetryPolicy getRetryPolicy(String serializedRetryPolicy) throws BackendException {
String[] tokens = serializedRetryPolicy.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 {
RetryPolicy rp = instantiate(policyClassName, args, serializedRetryPolicy);
log.debug("Instantiated RetryPolicy object {} from config string \"{}\"", rp, serializedRetryPolicy);
return rp;
} catch (Exception e) {
throw new PermanentBackendException("Failed to instantiate Astyanax Retry Policy class", e);
}
}
use of com.netflix.astyanax.retry.RetryPolicy in project titan by thinkaurelius.
the class AstyanaxStoreManager method getRetryPolicy.
private static RetryPolicy getRetryPolicy(String serializedRetryPolicy) throws StorageException {
String[] tokens = serializedRetryPolicy.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 {
RetryPolicy rp = instantiate(policyClassName, args, serializedRetryPolicy);
log.debug("Instantiated RetryPolicy object {} from config string \"{}\"", rp, serializedRetryPolicy);
return rp;
} catch (Exception e) {
throw new PermanentStorageException("Failed to instantiate Astyanax Retry Policy class", e);
}
}
use of com.netflix.astyanax.retry.RetryPolicy in project coprhd-controller by CoprHD.
the class CustomizedDistributedRowLock method acquire.
/**
* Try to take the lock. The caller must call .release() to properly clean up
* the lock columns from cassandra
*
* @throws Exception
*/
@Override
public void acquire() throws Exception {
Preconditions.checkArgument(ttl == null || TimeUnit.SECONDS.convert(timeout, timeoutUnits) < ttl, "Timeout " + timeout + " must be less than TTL " + ttl);
RetryPolicy retry = backoffPolicy.duplicate();
retryCount = 0;
while (true) {
try {
long curTimeMicros = getCurrentTimeMicros();
MutationBatch m = keyspace.prepareMutationBatch().setConsistencyLevel(consistencyLevel);
fillLockMutation(m, curTimeMicros, ttl);
m.execute();
verifyLock(curTimeMicros);
acquireTime = System.currentTimeMillis();
return;
} catch (BusyLockException e) {
release();
if (!retry.allowRetry()) {
throw e;
}
retryCount++;
}
}
}
Aggregations