@Beta
public interface LeaderElection
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAsyncIfLeader(java.lang.String lockName,
java.lang.Runnable runnable)
Asynchronously executes the runnable, if the current thread is able to become the leader
by optaining the specified lock.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
runAsyncIfLeader(java.lang.String lockName,
java.lang.Runnable runnable,
java.util.concurrent.Executor executor)
Asynchronously executes the runnable, if the current thread is able to become the leader
by optaining the specified lock.
|
void |
runIfLeader(java.lang.String lockName,
java.lang.Runnable runnable)
Synchronously executes the runnable, if the current thread is able to become the leader
by optaining the specified lock.
|
<T> java.util.concurrent.CompletableFuture<T> |
supplyAsyncIfLeader(java.lang.String lockName,
java.util.function.Supplier<T> supplier)
Asynchronously executes the supplier, if the current thread is able to become the leader
by optaining the specified lock.
|
<T> java.util.concurrent.CompletableFuture<T> |
supplyAsyncIfLeader(java.lang.String lockName,
java.util.function.Supplier<T> supplier,
java.util.concurrent.Executor executor)
Asynchronously executes the supplier, if the current thread is able to become the leader
by optaining the specified lock.
|
<T> T |
supplyIfLeader(java.lang.String lockName,
java.util.function.Supplier<T> supplier)
Synchronously executes the supplier, if the current thread is able to become the leader
by optaining the specified lock.
|
void runIfLeader(java.lang.String lockName,
java.lang.Runnable runnable)
lockName - the name of the distributed lock used for leader electionrunnable - the runnable that is executed by the leader<T> T supplyIfLeader(java.lang.String lockName,
java.util.function.Supplier<T> supplier)
T - the type of the object returned by the supplierlockName - the name of the distributed lock used for leader electionsupplier - the supplier that is executed by the leaderjava.util.concurrent.CompletableFuture<java.lang.Void> runAsyncIfLeader(java.lang.String lockName,
java.lang.Runnable runnable)
lockName - the name of the distributed lock used for leader electionrunnable - the runnable that is executed by the leaderCompletableFuture.join() or further process
the result.java.util.concurrent.CompletableFuture<java.lang.Void> runAsyncIfLeader(java.lang.String lockName,
java.lang.Runnable runnable,
java.util.concurrent.Executor executor)
lockName - the name of the distributed lock used for leader electionrunnable - the runnable that is executed by the leaderexecutor - the Executor used to asynchronously run the RunnableCompletableFuture.join() or further process
the result.<T> java.util.concurrent.CompletableFuture<T> supplyAsyncIfLeader(java.lang.String lockName,
java.util.function.Supplier<T> supplier)
T - the type of the object returned by the supplierlockName - the name of the distributed lock used for leader electionsupplier - the supplier that is executed by the leader<T> java.util.concurrent.CompletableFuture<T> supplyAsyncIfLeader(java.lang.String lockName,
java.util.function.Supplier<T> supplier,
java.util.concurrent.Executor executor)
T - the type of the object returned by the supplierlockName - the name of the distributed lock used for leader electionsupplier - the supplier that is executed by the leaderexecutor - the Executor used to asynchronously supply the response