Search in sources :

Example 1 with RetryPolicy

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);
    }
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) RetryPolicy(com.netflix.astyanax.retry.RetryPolicy) TemporaryBackendException(org.janusgraph.diskstorage.TemporaryBackendException) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) BackendException(org.janusgraph.diskstorage.BackendException) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException)

Example 2 with RetryPolicy

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);
    }
}
Also used : PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) RetryPolicy(com.netflix.astyanax.retry.RetryPolicy) PermanentStorageException(com.thinkaurelius.titan.diskstorage.PermanentStorageException) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) TemporaryStorageException(com.thinkaurelius.titan.diskstorage.TemporaryStorageException) StorageException(com.thinkaurelius.titan.diskstorage.StorageException)

Example 3 with RetryPolicy

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++;
        }
    }
}
Also used : MutationBatch(com.netflix.astyanax.MutationBatch) BusyLockException(com.netflix.astyanax.recipes.locks.BusyLockException) RetryPolicy(com.netflix.astyanax.retry.RetryPolicy)

Aggregations

RetryPolicy (com.netflix.astyanax.retry.RetryPolicy)3 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)2 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)2 MutationBatch (com.netflix.astyanax.MutationBatch)1 BusyLockException (com.netflix.astyanax.recipes.locks.BusyLockException)1 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)1 StorageException (com.thinkaurelius.titan.diskstorage.StorageException)1 TemporaryStorageException (com.thinkaurelius.titan.diskstorage.TemporaryStorageException)1 BackendException (org.janusgraph.diskstorage.BackendException)1 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)1 TemporaryBackendException (org.janusgraph.diskstorage.TemporaryBackendException)1