public class Invoker extends Object
retryUntranslated(String, boolean, Retried, Operation);
the other retry() and retryUntranslated() calls are wrappers.
The static once(String, String, Operation) and
once(String, String, VoidOperation) 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, VoidOperation) and
quietlyEval(String, String, Operation) calls exist to take any
operation and quietly catch and log at debug. The return value of
quietlyEval(String, String, Operation) is a java 8 optional,
which can then be used in java8-expressions.| Modifier and Type | Class and Description |
|---|---|
static interface |
Invoker.Operation<T>
Arbitrary operation throwing an IOException.
|
static interface |
Invoker.Retried
Callback for retry and notification operations.
|
static interface |
Invoker.VoidOperation
Void operation which may raise an IOException.
|
| Modifier and Type | Field and Description |
|---|---|
static Invoker.Retried |
LOG_EVENT
Log summary at info, full stack at debug.
|
static Invoker.Retried |
NO_OP
No op for a retrying callback.
|
| Constructor and Description |
|---|
Invoker(org.apache.hadoop.io.retry.RetryPolicy retryPolicy,
Invoker.Retried retryCallback)
Instantiate.
|
| Modifier and Type | Method and Description |
|---|---|
Invoker.Retried |
getRetryCallback() |
org.apache.hadoop.io.retry.RetryPolicy |
getRetryPolicy() |
static <T> void |
ignoreIOExceptions(org.slf4j.Logger log,
String action,
String path,
Invoker.Operation<T> operation)
Execute an operation and ignore all raised IOExceptions; log at INFO;
full stack only at DEBUG.
|
static void |
ignoreIOExceptions(org.slf4j.Logger log,
String action,
String path,
Invoker.VoidOperation operation)
Execute an operation and ignore all raised IOExceptions; log at INFO;
full stack only at DEBUG.
|
static <T> T |
once(String action,
String path,
Invoker.Operation<T> operation)
Execute a function, translating any exception into an IOException.
|
static void |
once(String action,
String path,
Invoker.VoidOperation operation)
Execute an operation with no result.
|
static void |
quietly(String action,
String path,
Invoker.VoidOperation operation)
Execute an operation; any exception raised is simply caught and
logged at debug.
|
static <T> Optional<T> |
quietlyEval(String action,
String path,
Invoker.Operation<T> operation)
Execute an operation; any exception raised is caught and
logged at debug.
|
<T> T |
retry(String action,
String path,
boolean idempotent,
Invoker.Operation<T> operation)
Execute a function with the default retry callback invoked.
|
<T> T |
retry(String action,
String path,
boolean idempotent,
Invoker.Retried retrying,
Invoker.Operation<T> operation)
Execute a function with retry processing.
|
void |
retry(String action,
String path,
boolean idempotent,
Invoker.Retried retrying,
Invoker.VoidOperation operation)
Execute a void operation with retry processing.
|
void |
retry(String action,
String path,
boolean idempotent,
Invoker.VoidOperation operation)
Execute a void operation with the default retry callback invoked.
|
<T> T |
retryUntranslated(String text,
boolean idempotent,
Invoker.Operation<T> operation)
Execute a function with retry processing and no translation.
|
<T> T |
retryUntranslated(String text,
boolean idempotent,
Invoker.Retried retrying,
Invoker.Operation<T> operation)
Execute a function with retry processing: AWS SDK Exceptions
are not translated.
|
public static final Invoker.Retried NO_OP
public static final Invoker.Retried LOG_EVENT
public Invoker(org.apache.hadoop.io.retry.RetryPolicy retryPolicy,
Invoker.Retried retryCallback)
retryPolicy - retry policy for all operations.retryCallback - standard retry policypublic org.apache.hadoop.io.retry.RetryPolicy getRetryPolicy()
public Invoker.Retried getRetryCallback()
@Retries.OnceTranslated public static <T> T once(String action, String path, Invoker.Operation<T> operation) throws IOException
T - type of return valueaction - action to execute (used in error messages)path - path of work (used in error messages)operation - operation to executeIOException - any IOE raised, or translated exception@Retries.OnceTranslated public static void once(String action, String path, Invoker.VoidOperation operation) throws IOException
action - action to execute (used in error messages)path - path of work (used in error messages)operation - operation to executeIOException - any IOE raised, or translated exceptionpublic static <T> void ignoreIOExceptions(org.slf4j.Logger log,
String action,
String path,
Invoker.Operation<T> operation)
T - type of operationlog - log to use.action - action to include in logpath - optional path to include in logoperation - operation to executepublic static void ignoreIOExceptions(org.slf4j.Logger log,
String action,
String path,
Invoker.VoidOperation operation)
log - log to use.action - action to include in logpath - optional path to include in logoperation - operation to execute@Retries.RetryTranslated public void retry(String action, String path, boolean idempotent, Invoker.Retried retrying, Invoker.VoidOperation operation) throws IOException
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 executeIOException - any IOE raised, or translated exception@Retries.RetryTranslated public void retry(String action, String path, boolean idempotent, Invoker.VoidOperation operation) throws IOException
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 executeIOException - any IOE raised, or translated exception@Retries.RetryTranslated public <T> T retry(String action, @Nullable String path, boolean idempotent, Invoker.Operation<T> operation) throws IOException
T - type of return valueaction - 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 executeIOException - any IOE raised, or translated exception@Retries.RetryTranslated public <T> T retry(String action, @Nullable String path, boolean idempotent, Invoker.Retried retrying, Invoker.Operation<T> operation) throws IOException
once(String, String, Operation) as the inner
invocation mechanism before retry logic is performed.T - type of return valueaction - 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 executeIOException - any IOE raised, or translated exception@Retries.RetryRaw public <T> T retryUntranslated(String text, boolean idempotent, Invoker.Operation<T> operation) throws IOException
T - type of return valuetext - 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 executeIOException - any IOE raisedRuntimeException - any Runtime exception raised@Retries.RetryRaw public <T> T retryUntranslated(String text, boolean idempotent, Invoker.Retried retrying, Invoker.Operation<T> operation) throws IOException
T - type of return valuetext - 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 executeIOException - any IOE raisedcom.amazonaws.SdkBaseException - any AWS exception raisedRuntimeException - : these are never caught and retries.public static void quietly(String action, String path, Invoker.VoidOperation operation)
action - action to executepath - path (for exception construction)operation - operationpublic static <T> Optional<T> quietlyEval(String action, String path, Invoker.Operation<T> operation)
T - type to returnaction - action to executepath - path (for exception construction)operation - operationCopyright © 2008–2021 Apache Software Foundation. All rights reserved.