public class LockRegistryLeaderInitiator extends Object implements SmartLifecycle, DisposableBean, ApplicationEventPublisherAware
| Modifier and Type | Class and Description |
|---|---|
protected class |
LockRegistryLeaderInitiator.LeaderSelector |
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_BUSY_WAIT_TIME |
static long |
DEFAULT_HEART_BEAT_TIME |
DEFAULT_PHASE| Constructor and Description |
|---|
LockRegistryLeaderInitiator(LockRegistry locks)
Create a new leader initiator with the provided lock registry and a default
candidate (which just logs the leadership events).
|
LockRegistryLeaderInitiator(LockRegistry locks,
Candidate candidate)
Create a new leader initiator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
Context |
getContext() |
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isPublishFailedEvents() |
boolean |
isRunning() |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setAutoStartup(boolean autoStartup) |
void |
setBusyWaitMillis(long busyWaitMillis) |
void |
setExecutorService(ExecutorService executorService)
Set the
ExecutorService, where is not provided then a default of
single thread Executor will be used. |
void |
setHeartBeatMillis(long heartBeatMillis) |
void |
setLeaderEventPublisher(LeaderEventPublisher leaderEventPublisher)
Set the
LeaderEventPublisher. |
void |
setPhase(int phase) |
void |
setPublishFailedEvents(boolean publishFailedEvents)
Enable or disable the publishing of failed events to the
specified applicationEventPublisher.
|
void |
start()
Start the registration of the
candidate for leader election. |
void |
stop()
Stop the registration of the
candidate for leader election. |
void |
stop(Runnable runnable) |
public static final long DEFAULT_HEART_BEAT_TIME
public static final long DEFAULT_BUSY_WAIT_TIME
public LockRegistryLeaderInitiator(LockRegistry locks)
locks - lock registrypublic LockRegistryLeaderInitiator(LockRegistry locks, Candidate candidate)
locks - lock registrycandidate - leadership election candidatepublic void setExecutorService(ExecutorService executorService)
ExecutorService, where is not provided then a default of
single thread Executor will be used.executorService - the executor servicepublic void setHeartBeatMillis(long heartBeatMillis)
public void setBusyWaitMillis(long busyWaitMillis)
public void setLeaderEventPublisher(LeaderEventPublisher leaderEventPublisher)
LeaderEventPublisher.leaderEventPublisher - the event publisherpublic void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface ApplicationEventPublisherAwarepublic boolean isRunning()
public int getPhase()
getPhase in interface PhasedgetPhase in interface SmartLifecyclepublic void setPhase(int phase)
phase - the phaseSmartLifecyclepublic boolean isAutoStartup()
isAutoStartup in interface SmartLifecyclepublic void setAutoStartup(boolean autoStartup)
autoStartup - true to start automaticallySmartLifecyclepublic Context getContext()
public boolean isPublishFailedEvents()
public void setPublishFailedEvents(boolean publishFailedEvents)
publishFailedEvents - boolean that if true, failed events will
be published. If false, no failures will be published. Default is false.public void start()
candidate for leader election.public void destroy()
destroy in interface DisposableBeanpublic void stop(Runnable runnable)
stop in interface SmartLifecycle