All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.astyanax.connectionpool.impl.AbstractExecutionImpl Maven / Gradle / Ivy

There is a newer version: 3.10.2
Show newest version
package com.netflix.astyanax.connectionpool.impl;

import com.netflix.astyanax.Execution;
import com.netflix.astyanax.connectionpool.OperationResult;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import com.netflix.astyanax.connectionpool.exceptions.IsRetryableException;
import com.netflix.astyanax.retry.RetryPolicy;

/**
 * Abstract impl that repeatedly executes while consulting a {@link RetryPolicy}
 * 
 * @author elandau
 *
 * @param 
 * 
 * @see {@link RetryPolicy}
 */
public abstract class AbstractExecutionImpl implements Execution {
    public OperationResult executeWithRetry(RetryPolicy retry) throws ConnectionException {
        ConnectionException lastException = null;
        retry.begin();
        do {
            try {
                return execute();
            }
            catch (ConnectionException ex) {
                if (ex instanceof IsRetryableException)
                    lastException = ex;
                else
                    throw ex;
            }
        } while (retry.allowRetry());

        throw lastException;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy