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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
stop
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 ApplicationEventPublisherAware
public boolean isRunning()
public int getPhase()
getPhase
in interface Phased
getPhase
in interface SmartLifecycle
public void setPhase(int phase)
phase
- the phaseSmartLifecycle
public boolean isAutoStartup()
isAutoStartup
in interface SmartLifecycle
public void setAutoStartup(boolean autoStartup)
autoStartup
- true to start automaticallySmartLifecycle
public 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 DisposableBean