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.
    • 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 name
        leaseId - lease identifier
        proposal - 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 key
        proposal - 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 name
        listener - 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