@InterfaceAudience.Private public class Invoker extends Object
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.Modifier and Type | Class and Description |
---|---|
static interface |
Invoker.Retried
Callback for retry and notification operations.
|
Modifier and Type | Field and Description |
---|---|
static Invoker.Retried |
LOG_EVENT
Log retries 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,
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 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.
|
void |
maybeRetry(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.
|
<T> T |
maybeRetry(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.
|
void |
maybeRetry(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.
|
static <T> T |
once(String action,
String path,
org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation)
Execute a function, translating any exception into an IOException.
|
static void |
once(String action,
String path,
org.apache.hadoop.util.functional.InvocationRaisingIOE operation)
Execute an operation with no result.
|
static <T> T |
onceInTheFuture(String action,
String path,
Future<T> future)
Wait for a future, translating SdkException into an IOException.
|
static <T> T |
onceTrackingDuration(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 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.
|
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> T |
retry(String action,
String path,
boolean idempotent,
org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation)
Execute a function with the default retry callback invoked.
|
void |
retry(String action,
String path,
boolean idempotent,
org.apache.hadoop.util.functional.InvocationRaisingIOE operation)
Execute a void operation with the default retry callback invoked.
|
<T> T |
retry(String action,
String path,
boolean idempotent,
Invoker.Retried retrying,
org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation)
Execute a function with retry processing.
|
void |
retry(String action,
String path,
boolean idempotent,
Invoker.Retried retrying,
org.apache.hadoop.util.functional.InvocationRaisingIOE operation)
Execute a void operation with retry processing.
|
<T> T |
retryUntranslated(String text,
boolean idempotent,
org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation)
Execute a function with retry processing and no translation.
|
<T> T |
retryUntranslated(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.
|
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, org.apache.hadoop.util.functional.CallableRaisingIOE<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 <T> T onceTrackingDuration(String action, String path, org.apache.hadoop.fs.statistics.DurationTracker tracker, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException
T
- type of return valueaction
- action to execute (used in error messages)path
- path of work (used in error messages)tracker
- tracker to updateoperation
- operation to executeIOException
- any IOE raised, or translated exception@Retries.OnceTranslated public static void once(String action, String path, org.apache.hadoop.util.functional.InvocationRaisingIOE 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 exception@Retries.OnceTranslated public static <T> T onceInTheFuture(String action, String path, Future<T> future) throws IOException
T
- type of return valueaction
- action to execute (used in error messages)path
- path of work (used in error messages)future
- future to await forIOException
- any IOE raised, or translated exceptionRuntimeException
- any other runtime exceptionpublic static <T> void ignoreIOExceptions(org.slf4j.Logger log, String action, String path, org.apache.hadoop.util.functional.CallableRaisingIOE<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, org.apache.hadoop.util.functional.InvocationRaisingIOE 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, org.apache.hadoop.util.functional.InvocationRaisingIOE 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 maybeRetry(boolean doRetry, String action, String path, boolean idempotent, Invoker.Retried retrying, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) throws IOException
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 executeIOException
- any IOE raised, or translated exception@Retries.RetryTranslated public void retry(String action, String path, boolean idempotent, org.apache.hadoop.util.functional.InvocationRaisingIOE 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 void maybeRetry(boolean doRetry, String action, String path, boolean idempotent, org.apache.hadoop.util.functional.InvocationRaisingIOE operation) throws IOException
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 executeIOException
- any IOE raised, or translated exception@Retries.RetryTranslated public <T> T retry(String action, @Nullable String path, boolean idempotent, org.apache.hadoop.util.functional.CallableRaisingIOE<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, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation) throws IOException
once(String, String, CallableRaisingIOE)
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.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
once(String, String, CallableRaisingIOE)
as the inner
invocation mechanism before retry logic is performed.T
- type of return valuedoRetry
- 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 executeIOException
- any IOE raised, or translated exception@Retries.RetryRaw public <T> T retryUntranslated(String text, boolean idempotent, org.apache.hadoop.util.functional.CallableRaisingIOE<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, org.apache.hadoop.util.functional.CallableRaisingIOE<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 raisedsoftware.amazon.awssdk.core.exception.SdkException
- any AWS exception raisedRuntimeException
- : these are never caught and retries.public static void quietly(String action, String path, org.apache.hadoop.util.functional.InvocationRaisingIOE operation)
action
- action to executepath
- path (for exception construction)operation
- operationpublic static <T> Optional<T> quietlyEval(String action, String path, org.apache.hadoop.util.functional.CallableRaisingIOE<T> operation)
T
- type to returnaction
- action to executepath
- path (for exception construction)operation
- operationCopyright © 2008–2024 Apache Software Foundation. All rights reserved.