Package org.apache.hadoop.fs.s3a
Class Invoker
java.lang.Object
org.apache.hadoop.fs.s3a.Invoker
Class to provide lambda expression invocation of AWS operations.
The core retry logic is in
retryUntranslated(String, boolean, Retried, CallableRaisingIOE);
the other retry() and retryUntranslated() calls are wrappers.
The static once(String, String, CallableRaisingIOE) and
once(String, String, InvocationRaisingIOE) calls take an
operation and
return it with AWS exceptions translated to IOEs of some form.
The retry logic on a failure is defined by the retry policy passed in
the constructor; the standard retry policy is S3ARetryPolicy,
though others may be used.
The constructor also takes two Invoker.Retried callbacks.
The caughtCallback is called whenever an exception (IOE or AWS)
is caught, before the retry processing looks at it.
The retryCallback is invoked after a retry is scheduled
but before the sleep.
These callbacks can be used for reporting and incrementing statistics.
The static quietly(String, String, InvocationRaisingIOE) and
quietlyEval(String, String, CallableRaisingIOE) calls exist to
take any operation and quietly catch and log at debug.
The return value of quietlyEval(String, String, CallableRaisingIOE)
is a java 8 optional,
which can then be used in java8-expressions.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback for retry and notification operations. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Invoker.RetriedLog retries at debug.static final Invoker.RetriedNo op for a retrying callback. -
Constructor Summary
ConstructorsConstructorDescriptionInvoker(org.apache.hadoop.io.retry.RetryPolicy retryPolicy, Invoker.Retried retryCallback) Instantiate. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.hadoop.io.retry.RetryPolicystatic <T> voidignoreIOExceptions(org.slf4j.Logger log, String action, String path, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute an operation and ignore all raised IOExceptions; log at INFO; full stack only at DEBUG.static voidignoreIOExceptions(org.slf4j.Logger log, String action, String path, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute an operation and ignore all raised IOExceptions; log at INFO; full stack only at DEBUG.<T> TmaybeRetry(boolean doRetry, String action, String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute a function with retry processing when doRetry=true, else just once.voidmaybeRetry(boolean doRetry, String action, String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute a void operation with retry processing when doRetry=true, else just once.voidmaybeRetry(boolean doRetry, String action, String path, boolean idempotent, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute a void operation with the default retry callback invoked when doRetry=true, else just once.static <T> TExecute a function, translating any exception into an IOException.static voidExecute an operation with no result.static <T> TonceInTheFuture(String action, String path, Future<T> future) Wait for a future, translating SdkException into an IOException.static <T> TonceTrackingDuration(String action, String path, org.apache.hadoop.fs.statistics.DurationTracker tracker, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute a function, translating any exception into an IOException.static voidquietly(String action, String path, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute an operation; any exception raised is simply caught and logged at debug.static <T> Optional<T>quietlyEval(String action, String path, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute an operation; any exception raised is caught and logged at debug.<T> Tretry(String action, String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute a function with retry processing.voidretry(String action, String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute a void operation with retry processing.<T> Tretry(String action, String path, boolean idempotent, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute a function with the default retry callback invoked.voidretry(String action, String path, boolean idempotent, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute a void operation with the default retry callback invoked.<T> TretryUntranslated(String text, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute a function with retry processing: AWS SDK Exceptions are not translated.<T> TretryUntranslated(String text, boolean idempotent, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute a function with retry processing and no translation.
-
Field Details
-
NO_OP
No op for a retrying callback. -
LOG_EVENT
Log retries at debug.
-
-
Constructor Details
-
Invoker
Instantiate.- Parameters:
retryPolicy- retry policy for all operations.retryCallback- standard retry policy
-
-
Method Details
-
getRetryPolicy
public org.apache.hadoop.io.retry.RetryPolicy getRetryPolicy() -
getRetryCallback
-
once
@OnceTranslated public static <T> T once(String action, String path, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException Execute a function, translating any exception into an IOException.- Type Parameters:
T- type of return value- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)operation- operation to execute- Returns:
- the result of the function call
- Throws:
IOException- any IOE raised, or translated exception
-
onceTrackingDuration
@OnceTranslated public static <T> T onceTrackingDuration(String action, String path, org.apache.hadoop.fs.statistics.DurationTracker tracker, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException Execute a function, translating any exception into an IOException. The supplied duration tracker instance is updated with success/failure.- Type Parameters:
T- type of return value- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)tracker- tracker to updateoperation- operation to execute- Returns:
- the result of the function call
- Throws:
IOException- any IOE raised, or translated exception
-
once
@OnceTranslated public static void once(String action, String path, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) throws IOException Execute an operation with no result.- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)operation- operation to execute- Throws:
IOException- any IOE raised, or translated exception
-
onceInTheFuture
@OnceTranslated public static <T> T onceInTheFuture(String action, String path, Future<T> future) throws IOException Wait for a future, translating SdkException into an IOException.- Type Parameters:
T- type of return value- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)future- future to await for- Returns:
- the result of the function call
- Throws:
IOException- any IOE raised, or translated exceptionRuntimeException- any other runtime exception
-
ignoreIOExceptions
public static <T> void ignoreIOExceptions(org.slf4j.Logger log, String action, String path, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute an operation and ignore all raised IOExceptions; log at INFO; full stack only at DEBUG.- Type Parameters:
T- type of operation- Parameters:
log- log to use.action- action to include in logpath- optional path to include in logoperation- operation to execute
-
ignoreIOExceptions
public static void ignoreIOExceptions(org.slf4j.Logger log, String action, String path, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute an operation and ignore all raised IOExceptions; log at INFO; full stack only at DEBUG.- Parameters:
log- log to use.action- action to include in logpath- optional path to include in logoperation- operation to execute
-
retry
@RetryTranslated public void retry(String action, String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) throws IOException Execute a void operation with retry processing.- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)idempotent- does the operation have semantics which mean that it can be retried even if was already executed?retrying- callback on retriesoperation- operation to execute- Throws:
IOException- any IOE raised, or translated exception
-
maybeRetry
@RetryTranslated public void maybeRetry(boolean doRetry, String action, String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) throws IOException Execute a void operation with retry processing when doRetry=true, else just once.- Parameters:
doRetry- true if retries should be performedaction- action to execute (used in error messages)path- path of work (used in error messages)idempotent- does the operation have semantics which mean that it can be retried even if was already executed?retrying- callback on retriesoperation- operation to execute- Throws:
IOException- any IOE raised, or translated exception
-
retry
@RetryTranslated public void retry(String action, String path, boolean idempotent, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) throws IOException Execute a void operation with the default retry callback invoked.- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)idempotent- does the operation have semantics which mean that it can be retried even if was already executed?operation- operation to execute- Throws:
IOException- any IOE raised, or translated exception
-
maybeRetry
@RetryTranslated public void maybeRetry(boolean doRetry, String action, String path, boolean idempotent, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) throws IOException Execute a void operation with the default retry callback invoked when doRetry=true, else just once.- Parameters:
doRetry- true if retries should be performedaction- action to execute (used in error messages)path- path of work (used in error messages)idempotent- does the operation have semantics which mean that it can be retried even if was already executed?operation- operation to execute- Throws:
IOException- any IOE raised, or translated exception
-
retry
@RetryTranslated public <T> T retry(String action, @Nullable String path, boolean idempotent, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException Execute a function with the default retry callback invoked.- Type Parameters:
T- type of return value- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)idempotent- does the operation have semantics which mean that it can be retried even if was already executed?operation- operation to execute- Returns:
- the result of the call
- Throws:
IOException- any IOE raised, or translated exception
-
retry
@RetryTranslated public <T> T retry(String action, @Nullable String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException Execute a function with retry processing. Usesonce(String, String, CallableRaisingIOE)as the inner invocation mechanism before retry logic is performed.- Type Parameters:
T- type of return value- Parameters:
action- action to execute (used in error messages)path- path of work (used in error messages)idempotent- does the operation have semantics which mean that it can be retried even if was already executed?retrying- callback on retriesoperation- operation to execute- Returns:
- the result of the call
- Throws:
IOException- any IOE raised, or translated exception
-
maybeRetry
@RetryTranslated public <T> T maybeRetry(boolean doRetry, String action, @Nullable String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException Execute a function with retry processing when doRetry=true, else just once. Usesonce(String, String, CallableRaisingIOE)as the inner invocation mechanism before retry logic is performed.- Type Parameters:
T- type of return value- Parameters:
doRetry- true if retries should be performedaction- action to execute (used in error messages)path- path of work (used in error messages)idempotent- does the operation have semantics which mean that it can be retried even if was already executed?retrying- callback on retriesoperation- operation to execute- Returns:
- the result of the call
- Throws:
IOException- any IOE raised, or translated exception
-
retryUntranslated
@RetryRaw public <T> T retryUntranslated(String text, boolean idempotent, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException Execute a function with retry processing and no translation. and the default retry callback.- Type Parameters:
T- type of return value- Parameters:
text- description for the catching callbackidempotent- does the operation have semantics which mean that it can be retried even if was already executed?operation- operation to execute- Returns:
- the result of the call
- Throws:
IOException- any IOE raisedRuntimeException- any Runtime exception raised
-
retryUntranslated
@RetryRaw public <T> T retryUntranslated(String text, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException Execute a function with retry processing: AWS SDK Exceptions are not translated. This is method which the others eventually invoke.- Type Parameters:
T- type of return value- Parameters:
text- text to include in messagesidempotent- does the operation have semantics which mean that it can be retried even if was already executed?retrying- callback on retriesoperation- operation to execute- Returns:
- the result of the call
- Throws:
IOException- any IOE raisedsoftware.amazon.awssdk.core.exception.SdkException- any AWS exception raisedRuntimeException- : these are never caught and retries.
-
quietly
public static void quietly(String action, String path, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) Execute an operation; any exception raised is simply caught and logged at debug.- Parameters:
action- action to executepath- path (for exception construction)operation- operation
-
quietlyEval
public static <T> Optional<T> quietlyEval(String action, String path, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) Execute an operation; any exception raised is caught and logged at debug. The result is only non-empty if the operation succeeded- Type Parameters:
T- type to return- Parameters:
action- action to executepath- path (for exception construction)operation- operation- Returns:
- the result of a successful operation
-