public class EtcdLeaderElection extends Object implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static interface |
EtcdLeaderElection.ElectionListener |
| Modifier and Type | Field and Description |
|---|---|
protected com.google.protobuf.ByteString |
bytesPrefix |
protected RangeCache |
candidates |
protected String |
id |
protected boolean |
initialized |
protected boolean |
leader |
protected String |
leaderId |
protected List<EtcdLeaderElection.ElectionListener> |
listeners |
protected static org.slf4j.Logger |
logger |
protected PersistentLeaseKey |
ourCandidate |
protected int |
prefixLen |
| Constructor and Description |
|---|
EtcdLeaderElection(EtcdClient client,
com.google.protobuf.ByteString prefix)
Observer-only mode, won't participate in election, leaders have no effect
|
EtcdLeaderElection(EtcdClient client,
com.google.protobuf.ByteString prefix,
String candidateId) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(EtcdLeaderElection.ElectionListener listener) |
protected com.google.protobuf.ByteString |
cacheKey(String str) |
protected static String |
candId(KeyValue kv) |
void |
close() |
String |
getId() |
String |
getLeaderId() |
boolean |
isLeader() |
protected void |
notifyListeners(boolean isLeader) |
boolean |
removeListener(EtcdLeaderElection.ElectionListener listener) |
void |
start() |
protected static final org.slf4j.Logger logger
protected final com.google.protobuf.ByteString bytesPrefix
protected final int prefixLen
protected final String id
protected final RangeCache candidates
protected final PersistentLeaseKey ourCandidate
protected final List<EtcdLeaderElection.ElectionListener> listeners
protected volatile String leaderId
protected volatile boolean leader
protected boolean initialized
public EtcdLeaderElection(EtcdClient client, com.google.protobuf.ByteString prefix)
public EtcdLeaderElection(EtcdClient client, com.google.protobuf.ByteString prefix, String candidateId)
public String getId()
public String getLeaderId()
public boolean isLeader()
public void addListener(EtcdLeaderElection.ElectionListener listener)
public boolean removeListener(EtcdLeaderElection.ElectionListener listener)
protected void notifyListeners(boolean isLeader)
public void start()
public void close()
close in interface AutoCloseableprotected com.google.protobuf.ByteString cacheKey(String str)
Copyright © 2023. All rights reserved.