Class ResilientOperation

java.lang.Object
com.google.cloud.hadoop.util.ResilientOperation

public class ResilientOperation extends Object
A class which defines static functions to be called to make a user-provided function more resilient by attempting retries.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    nextSleep(com.google.api.client.util.BackOff backoff, com.google.api.client.util.Sleeper sleeper, Exception currentException)
    Determines the amount to sleep for and sleeps if needed.
    static <T, X extends Exception>
    T
    retry(Callable<T> callable, com.google.api.client.util.BackOff backoff, RetryDeterminer<? super X> retryDet, Class<X> classType)
    Retries the given executable function in the case of transient errors defined by the RetryDeterminer and uses default sleeper.
    static <T, X extends Exception>
    T
    retry(Callable<T> callable, com.google.api.client.util.BackOff backoff, RetryDeterminer<? super X> retryDet, Class<X> classType, com.google.api.client.util.Sleeper sleeper)
    Retries the given executable function in the case of transient errors defined by the RetryDeterminer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResilientOperation

      public ResilientOperation()
  • Method Details

    • retry

      public static <T, X extends Exception> T retry(Callable<T> callable, com.google.api.client.util.BackOff backoff, RetryDeterminer<? super X> retryDet, Class<X> classType, com.google.api.client.util.Sleeper sleeper) throws X, InterruptedException
      Retries the given executable function in the case of transient errors defined by the RetryDeterminer.

      Does not support unchecked exceptions that are not instances of RuntimeException.

      Type Parameters:
      T - Type of object returned by the call.
      X - Type of exception thrown by the call.
      Parameters:
      callable - Callable to retry execution of
      backoff - BackOff to determine how long to sleep for
      retryDet - RetryDeterminer to determine when to retry
      classType - class type of X
      sleeper - Used to sleep
      Throws:
      X - What is thrown from the executable or the RetryDeterminer
      InterruptedException - - Exception thrown from sleep
    • retry

      public static <T, X extends Exception> T retry(Callable<T> callable, com.google.api.client.util.BackOff backoff, RetryDeterminer<? super X> retryDet, Class<X> classType) throws X, InterruptedException
      Retries the given executable function in the case of transient errors defined by the RetryDeterminer and uses default sleeper.
      Type Parameters:
      T - Type of object returned by the call.
      X - Type of exception thrown by the call.
      Parameters:
      callable - Callable to retry execution of
      backoff - BackOff to determine how long to sleep for
      retryDet - RetryDeterminer to determine when to retry
      classType - class type of X
      Throws:
      X - What is thrown from the executable or the RetryDeterminer
      InterruptedException - - Exception thrown from sleep
    • nextSleep

      public static boolean nextSleep(com.google.api.client.util.BackOff backoff, com.google.api.client.util.Sleeper sleeper, Exception currentException) throws InterruptedException
      Determines the amount to sleep for and sleeps if needed.
      Parameters:
      backoff - BackOff to determine how long to sleep for
      sleeper - Used to sleep
      currentException - exception that caused the retry and sleep. For logging.
      Throws:
      InterruptedException - if sleep is interrupted