Class RetryableIndexQueryAction<Q extends InternalQuery<?,Q>,T>
- java.lang.Object
-
- com.google.gerrit.server.update.RetryableAction<T>
-
- com.google.gerrit.server.update.RetryableIndexQueryAction<Q,T>
-
public class RetryableIndexQueryAction<Q extends InternalQuery<?,Q>,T> extends RetryableAction<T>
An action to query an index that is executed with retrying.Instances of this class are created via
RetryHelper.accountIndexQuery(String, IndexQueryAction)
andRetryHelper.changeIndexQuery(String, IndexQueryAction)
.In contrast to normal
RetryableAction.Action
s that are called viaRetryableAction
RetryableIndexQueryAction.IndexQueryAction
s get aInternalQuery
provided.In addition when an index query action is called any exception that is not an unchecked exception gets wrapped into an
StorageException
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RetryableIndexQueryAction.IndexQueryAction<T,Q>
-
Nested classes/interfaces inherited from class com.google.gerrit.server.update.RetryableAction
RetryableAction.Action<T>, RetryableAction.ActionType
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
call()
Executes this action with retry.RetryableIndexQueryAction<Q,T>
defaultTimeoutMultiplier(int multiplier)
Increases the default timeout by the given multiplier.RetryableIndexQueryAction<Q,T>
listener(com.github.rholder.retry.RetryListener retryListener)
Sets a listener that is invoked when the action is retried.RetryableIndexQueryAction<Q,T>
onAutoTrace(Consumer<String> traceIdConsumer)
Sets a callback that is invoked when auto-retry with tracing is triggered.RetryableIndexQueryAction<Q,T>
retryOn(Predicate<Throwable> exceptionPredicate)
Adds an additional condition that should trigger retries.RetryableIndexQueryAction<Q,T>
retryWithTrace(Predicate<Throwable> exceptionPredicate)
Sets a condition that should trigger auto-retry with tracing.
-
-
-
Method Detail
-
retryOn
public RetryableIndexQueryAction<Q,T> retryOn(Predicate<Throwable> exceptionPredicate)
Description copied from class:RetryableAction
Adds an additional condition that should trigger retries.For some exceptions retrying is enabled globally (see
ExceptionHook.shouldRetry(String, String, Throwable)
). Conditions for those exceptions do not need to be specified here again.This method can be invoked multiple times to add further conditions that should trigger retries.
- Overrides:
retryOn
in classRetryableAction<T>
- Parameters:
exceptionPredicate
- predicate that decides if the action should be retried for a given exception- Returns:
- this instance to enable chaining of calls
-
retryWithTrace
public RetryableIndexQueryAction<Q,T> retryWithTrace(Predicate<Throwable> exceptionPredicate)
Description copied from class:RetryableAction
Sets a condition that should trigger auto-retry with tracing.This condition is only relevant if an exception occurs that doesn't trigger (normal) retry.
Auto-retry with tracing automatically captures traces for unexpected exceptions so that they can be investigated.
Every call of this method overwrites any previously set condition for auto-retry with tracing.
- Overrides:
retryWithTrace
in classRetryableAction<T>
- Parameters:
exceptionPredicate
- predicate that decides if the action should be retried with tracing for a given exception- Returns:
- this instance to enable chaining of calls
-
onAutoTrace
public RetryableIndexQueryAction<Q,T> onAutoTrace(Consumer<String> traceIdConsumer)
Description copied from class:RetryableAction
Sets a callback that is invoked when auto-retry with tracing is triggered.Via the callback callers can find out with trace ID was used for the retry.
Every call of this method overwrites any previously set trace ID consumer.
- Overrides:
onAutoTrace
in classRetryableAction<T>
- Parameters:
traceIdConsumer
- trace ID consumer- Returns:
- this instance to enable chaining of calls
-
listener
public RetryableIndexQueryAction<Q,T> listener(com.github.rholder.retry.RetryListener retryListener)
Description copied from class:RetryableAction
Sets a listener that is invoked when the action is retried.Every call of this method overwrites any previously set listener.
- Overrides:
listener
in classRetryableAction<T>
- Parameters:
retryListener
- retry listener- Returns:
- this instance to enable chaining of calls
-
defaultTimeoutMultiplier
public RetryableIndexQueryAction<Q,T> defaultTimeoutMultiplier(int multiplier)
Description copied from class:RetryableAction
Increases the default timeout by the given multiplier.Every call of this method overwrites any previously set timeout.
- Overrides:
defaultTimeoutMultiplier
in classRetryableAction<T>
- Parameters:
multiplier
- multiplier for the default timeout- Returns:
- this instance to enable chaining of calls
-
call
public T call()
Description copied from class:RetryableAction
Executes this action with retry.- Overrides:
call
in classRetryableAction<T>
- Returns:
- the result of the action
-
-