Class RetryStorageOperation

java.lang.Object
com.google.jenkins.plugins.storage.util.RetryStorageOperation

public class RetryStorageOperation extends Object
A class to facilitate retries on storage operations.
  • Field Details

    • MAX_REMOTE_CREDENTIAL_EXPIRED_RETRIES

      public static final int MAX_REMOTE_CREDENTIAL_EXPIRED_RETRIES
      See Also:
  • Constructor Details

    • RetryStorageOperation

      public RetryStorageOperation()
  • Method Details

    • performRequestWithRetry

      public static void performRequestWithRetry(com.google.jenkins.plugins.util.Executor executor, RetryStorageOperation.Operation a, int attempts) throws IOException, InterruptedException, com.google.jenkins.plugins.util.ExecutorException
      Perform the given operation retrying on error. The operation is retried if either IOException or InterruptedException occur. After the given number of retries, throws the last error received. Any other exceptions are passed through.
      Parameters:
      executor - The executor to use for the operation
      a - The operation to execute.
      attempts - How many attempts to make. Must be at least 1.
      Throws:
      IOException - If performing the operation threw an IOException.
      InterruptedException - If performing the operation threw an InterruptedException.
      com.google.jenkins.plugins.util.ExecutorException - If the executor threw an exception while performing the operation.
    • performRequestWithReinitCredentials

      public static <Ex extends Throwable> void performRequestWithReinitCredentials(RetryStorageOperation.RepeatOperation<Ex> a, int retries) throws IOException, InterruptedException, com.google.jenkins.plugins.util.ExecutorException, Ex
      Keeps performing actions until credentials expire. When they do, calls initCredentials() and continues. It relies on the RepeatOperation to keep any state required to start where it left off.

      HttpResponseException with the code Unauthorized is caught. Any other exceptions are passed through.

      Type Parameters:
      Ex - An action-specific exception that might be throwns.
      Parameters:
      a - Operation to execute
      retries - How many times to attempt to refresh credentials if there is no progress. (Every time an action successfully completes, the retry budget is reset)
      Throws:
      IOException - If performing the operation threw an IOException.
      InterruptedException - If performing the operation threw an InterruptedException.
      com.google.jenkins.plugins.util.ExecutorException - If the executor threw an exception while performing the operation.
      Ex - Custom exception thrown by the RetryStorageOperation.Operation.
    • performRequestWithReinitCredentials

      public static <Ex extends Throwable> void performRequestWithReinitCredentials(RetryStorageOperation.RepeatOperation<Ex> a) throws IOException, InterruptedException, com.google.jenkins.plugins.util.ExecutorException, Ex
      Throws:
      IOException
      InterruptedException
      com.google.jenkins.plugins.util.ExecutorException
      Ex extends Throwable