Package org.infinispan.xsite.irac
Class IracExecutor
- java.lang.Object
-
- org.infinispan.xsite.irac.IracExecutor
-
- All Implemented Interfaces:
Runnable
,Function<Void,CompletionStage<Void>>
public class IracExecutor extends Object implements Function<Void,CompletionStage<Void>>, Runnable
Executes the "IRAC" sending task in a single thread.This executor makes sure no more than one task is running at the same time. Also, it avoids "queueing" multiple tasks by queuing at most one. This is possible because the task does the same thing: iterator over pending updates and send them to the remote site.
In addition, it iteracts with the
ExponentialBackOff
to add delays in case of network failures.- Since:
- 12
- Author:
- Pedro Ruivo
-
-
Constructor Summary
Constructors Constructor Description IracExecutor(Supplier<CompletionStage<Void>> runnable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>
apply(Void unused)
Used byCompletableFuture.thenComposeAsync(Function, Executor)
, it adds theExponentialBackOff
delay.void
disableBackOff()
void
enableBackOff()
void
run()
Executes, in a new thread, or queues the task.void
setBackOff(ExponentialBackOff backOff)
void
setExecutor(Executor executor)
-
-
-
Constructor Detail
-
IracExecutor
public IracExecutor(Supplier<CompletionStage<Void>> runnable)
-
-
Method Detail
-
setExecutor
public void setExecutor(Executor executor)
-
setBackOff
public void setBackOff(ExponentialBackOff backOff)
-
run
public void run()
Executes, in a new thread, or queues the task.
-
enableBackOff
public void enableBackOff()
-
disableBackOff
public void disableBackOff()
-
apply
public CompletionStage<Void> apply(Void unused)
Used byCompletableFuture.thenComposeAsync(Function, Executor)
, it adds theExponentialBackOff
delay.- Specified by:
apply
in interfaceFunction<Void,CompletionStage<Void>>
- Parameters:
unused
- Unused value.- Returns:
- The
CompletionStage
fromExponentialBackOff.asyncBackOff()
.
-
-