public class LeaderInitiator extends Object implements org.springframework.context.Lifecycle, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
candidates
with etcd. Upon construction, start()
must be invoked to
register the candidate for leadership election.Constructor and Description |
---|
LeaderInitiator(mousio.etcd4j.EtcdClient client,
org.springframework.cloud.cluster.leader.Candidate candidate,
String namespace)
Construct a
LeaderInitiator . |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
destroy() |
boolean |
isRunning() |
void |
setLeaderEventPublisher(org.springframework.cloud.cluster.leader.event.LeaderEventPublisher leaderEventPublisher)
Sets the
LeaderEventPublisher . |
void |
start()
Start the registration of the
candidate for leader election. |
void |
stop()
Stop the registration of the
candidate for leader election. |
public LeaderInitiator(mousio.etcd4j.EtcdClient client, org.springframework.cloud.cluster.leader.Candidate candidate, String namespace)
LeaderInitiator
.client
- EtcdClient
instancecandidate
- leadership election candidatenamespace
- Etcd namespacepublic void start()
candidate
for leader election.start
in interface org.springframework.context.Lifecycle
public void stop()
candidate
for leader election.
If the candidate is currently leader, its leadership will be revoked.stop
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
candidate
is runningpublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public void destroy() throws Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
Exception
public void setLeaderEventPublisher(org.springframework.cloud.cluster.leader.event.LeaderEventPublisher leaderEventPublisher)
LeaderEventPublisher
.leaderEventPublisher
- the event publisherCopyright © 2016 Pivotal Software, Inc.. All rights reserved.