Class RequestTable<T>

java.lang.Object
org.jgroups.raft.util.RequestTable<T>

public class RequestTable<T> extends Object
Keeps track of AppendEntriesRequest messages and responses.

Each AppendEntry request is keyed by the index at which it was inserted at the leader. The values (RequestEntry) contain the responses from followers. When a response is added, and the majority has been reached, add() returns true and the key/value pair will be removed. (subsequent responses will be ignored). On a majority, the commit index is advanced.

Only created on leader
Since:
0.1
Author:
Bela Ban
  • Field Details

  • Constructor Details

    • RequestTable

      public RequestTable()
  • Method Details

    • create

      public void create(long index, T vote, CompletableFuture<byte[]> future, Supplier<Integer> majority)
    • create

      public void create(long index, T vote, CompletableFuture<byte[]> future, Supplier<Integer> majority, Options opts)
    • destroy

      public void destroy(Throwable t)
      Completes all uncommitted requests with the provided exception.

      This method should be invoked before setting the instance to null when the leader steps down. This provides a more responsive completion of requests to the users, instead of having requests time out. Internal operations, such as membership changes, do not have a timeout associated, which would hang and any subsequent changes would not complete.

      Parameters:
      t - : Throwable to complete the requests exceptionally.
    • add

      public boolean add(long index, T sender, Supplier<Integer> majority)
      Adds a response to the response set. If the majority has been reached, returns true
      Returns:
      True if a majority has been reached, false otherwise. Note that this is done exactly once
    • isCommitted

      public boolean isCommitted(long index)
      Whether or not the entry at index is committed
    • size

      public int size()
      number of requests being processed
    • remove

      public RequestTable.Entry<T> remove(long index)
    • notifyAndRemove

      public void notifyAndRemove(long index, byte[] response)
      Notifies the CompletableFuture and then removes the entry for index
    • toString

      public String toString()
      Overrides:
      toString in class Object