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 |
| 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 |
isRunning() |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setAutoStartup(boolean autoStartup) |
void |
setBusyWaitMillis(long busyWaitMillis) |
void |
setHeartBeatMillis(long heartBeatMillis) |
void |
setLeaderEventPublisher(LeaderEventPublisher leaderEventPublisher)
Sets the
LeaderEventPublisher. |
void |
setPhase(int phase) |
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 setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface ApplicationEventPublisherAwarepublic void setHeartBeatMillis(long heartBeatMillis)
public void setBusyWaitMillis(long busyWaitMillis)
public void setLeaderEventPublisher(LeaderEventPublisher leaderEventPublisher)
LeaderEventPublisher.leaderEventPublisher - the event publisherpublic boolean isRunning()
public 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 void start()
candidate for leader election.public void destroy()
throws Exception
destroy in interface DisposableBeanExceptionpublic void stop(Runnable runnable)
stop in interface SmartLifecycle