Package io.etcd.jetcd
Interface Election
-
- All Superinterfaces:
java.lang.AutoCloseable,CloseableClient
public interface Election extends CloseableClient
Interface of leader election client talking to etcd.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceElection.ListenerInterface of leadership notification listener.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<CampaignResponse>campaign(ByteSequence electionName, long leaseId, ByteSequence proposal)Campaign waits to acquire leadership in an election, returning a leader key representing the leadership if successful.java.util.concurrent.CompletableFuture<LeaderResponse>leader(ByteSequence electionName)Returns the current election proclamation, if any.voidobserve(ByteSequence electionName, Election.Listener listener)Listens to election proclamations in-order as made by the election's elected leaders.java.util.concurrent.CompletableFuture<ProclaimResponse>proclaim(LeaderKey leaderKey, ByteSequence proposal)Proclaim updates the leader's posted value with a new value.java.util.concurrent.CompletableFuture<ResignResponse>resign(LeaderKey leaderKey)Resign releases election leadership so other campaigners may acquire leadership on the election.-
Methods inherited from interface io.etcd.jetcd.support.CloseableClient
close
-
-
-
-
Method Detail
-
campaign
java.util.concurrent.CompletableFuture<CampaignResponse> campaign(ByteSequence electionName, long leaseId, ByteSequence proposal)
Campaign waits to acquire leadership in an election, returning a leader key representing the leadership if successful. The leader key can then be used to issue new values on the election, transactionally guard API requests on leadership still being held, and resign from the election.- Parameters:
electionName- election nameleaseId- lease identifierproposal- proposal- Returns:
- the response
-
proclaim
java.util.concurrent.CompletableFuture<ProclaimResponse> proclaim(LeaderKey leaderKey, ByteSequence proposal)
Proclaim updates the leader's posted value with a new value. Only active leader can change the value.- Parameters:
leaderKey- leader keyproposal- new proposal- Returns:
- the response
-
leader
java.util.concurrent.CompletableFuture<LeaderResponse> leader(ByteSequence electionName)
Returns the current election proclamation, if any.- Parameters:
electionName- election name- Returns:
- the response
-
observe
void observe(ByteSequence electionName, Election.Listener listener)
Listens to election proclamations in-order as made by the election's elected leaders.- Parameters:
electionName- election namelistener- listener
-
resign
java.util.concurrent.CompletableFuture<ResignResponse> resign(LeaderKey leaderKey)
Resign releases election leadership so other campaigners may acquire leadership on the election.- Parameters:
leaderKey- leader key- Returns:
- the response
-
-