R
- The type of the result from the unit of work.public static class Transaction.Workload<R> extends Object
Transaction.Workload
represents a unit of work constructed by the
Transaction.submit(java.util.function.Function)
method on the Transaction
interface.
The unit of work is a Function
typically containing mutations to the Graph
. The
Transaction.Workload
is responsible for executing the unit of work in the context of a retry strategy, such that a
failed unit of work is rolled back and executed again until retries are exhausted or the unit of work succeeds
with a commit operation.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_DELAY_MS |
static int |
DEFAULT_TRIES |
Constructor and Description |
---|
Workload(Graph g,
Function<Graph,R> work)
Creates a new
Transaction.Workload that will be tried to be executed within a transaction. |
Modifier and Type | Method and Description |
---|---|
R |
attempt(BiFunction<Graph,Function<Graph,R>,R> retryStrategy)
Try to execute a
Transaction.Workload with a mapper retry strategy. |
R |
exponentialBackoff()
Executes the
Transaction.Workload with the default number of retries and with a exponentially increasing
number of milliseconds between each retry using the default retry delay. |
R |
exponentialBackoff(int tries)
Executes the
Transaction.Workload with a number of retries and with a exponentially increasing number of
milliseconds between each retry using the default retry delay. |
R |
exponentialBackoff(int tries,
long initialDelay)
Executes the
Transaction.Workload with a number of retries and with a exponentially increasing number of
milliseconds between each retry. |
R |
exponentialBackoff(int tries,
long initialDelay,
Set<Class> exceptionsToRetryOn)
Executes the
Transaction.Workload with a number of retries and with a exponentially increasing number of
milliseconds between each retry. |
R |
fireAndForget()
Executes the
Transaction.Workload committing if possible and rolling back on failure. |
R |
oneAndDone()
Executes the
Transaction.Workload committing if possible and rolling back on failure. |
R |
retry()
Executes the
Transaction.Workload with the default number of retries and with the default number of
milliseconds delay between each try. |
R |
retry(int tries)
Executes the
Transaction.Workload with a number of retries and with the default number of milliseconds delay
between each try. |
R |
retry(int tries,
long delay)
Executes the
Transaction.Workload with a number of retries and with a number of milliseconds delay between
each try. |
R |
retry(int tries,
long delay,
Set<Class> exceptionsToRetryOn)
Executes the
Transaction.Workload with a number of retries and with a number of milliseconds delay between each
try and will only retry on the set of supplied exceptions. |
public static final long DEFAULT_DELAY_MS
public static final int DEFAULT_TRIES
public Workload(Graph g, Function<Graph,R> work)
Transaction.Workload
that will be tried to be executed within a transaction.g
- The Graph
instance on which the work will be performed.work
- The work to be executed on the Graph instance which will optionally return a value.public R attempt(BiFunction<Graph,Function<Graph,R>,R> retryStrategy)
Transaction.Workload
with a mapper retry strategy.retryStrategy
- The first argument to this function is the Graph instance and the second is
the encapsulated work to be performed. The function should ultimately return the
result of the encapsulated work function.public R oneAndDone()
Transaction.Workload
committing if possible and rolling back on failure. On failure, an exception
is reported.public R fireAndForget()
Transaction.Workload
committing if possible and rolling back on failure. On failure no exception
is reported.public R retry()
Transaction.Workload
with the default number of retries and with the default number of
milliseconds delay between each try.public R retry(int tries)
Transaction.Workload
with a number of retries and with the default number of milliseconds delay
between each try.public R retry(int tries, long delay)
Transaction.Workload
with a number of retries and with a number of milliseconds delay between
each try.public R retry(int tries, long delay, Set<Class> exceptionsToRetryOn)
Transaction.Workload
with a number of retries and with a number of milliseconds delay between each
try and will only retry on the set of supplied exceptions. Exceptions outside of that set will generate a
RuntimeException and immediately fail.public R exponentialBackoff()
Transaction.Workload
with the default number of retries and with a exponentially increasing
number of milliseconds between each retry using the default retry delay.public R exponentialBackoff(int tries)
Transaction.Workload
with a number of retries and with a exponentially increasing number of
milliseconds between each retry using the default retry delay.public R exponentialBackoff(int tries, long initialDelay)
Transaction.Workload
with a number of retries and with a exponentially increasing number of
milliseconds between each retry.public R exponentialBackoff(int tries, long initialDelay, Set<Class> exceptionsToRetryOn)
Transaction.Workload
with a number of retries and with a exponentially increasing number of
milliseconds between each retry. It will only retry on the set of supplied exceptions. Exceptions outside
of that set will generate a RuntimeException
and immediately fail.Copyright © 2013–2015 Apache Software Foundation. All rights reserved.