Class ReadOnlyRequestRepository<R>

java.lang.Object
org.jgroups.raft.util.ReadOnlyRequestRepository<R>
Type Parameters:
R - The type of requests.

public final class ReadOnlyRequestRepository<R> extends Object
Repository for read-only operations.

This repository utilizes an ordered set to map between a log index and multiple pending requests. Read-only operations in RAFT do not update the log index, in contrast with RequestTable. This maps multiple requests to the same index in the log, or the same key in the requests map.

Since:
1.1.2
Author:
José Bolina
  • Method Details

    • destroy

      public void destroy()
      Invokes the registered destroyer with all pending requests.

      Subsequent calls to register operations after destroy will automatically invoke the destroyer listener.

    • advance

      public void advance(long index)
      Advances the commit index.

      Once the commit index advances, this method will complete the requests up-to, and including, the index. The listener is invoked for all requests in the range.

      Parameters:
      index - The current index the log was advanced to.
    • commit

      public void commit(long index)
      Register an accept from a follower to the given index.

      Register the accept response of a single follower node to all requests of a given index and below. The completion listener is invoked once a majority of accepts is registered.

      Parameters:
      index - The index accepted by the follower node.
    • register

      public void register(long index, R request)
      Register a new request submitted at the given index.

      If the repository was already destroyed by invoking destroy(), the destroyer listener is invoked with the provided request.

      Parameters:
      index - The commit index at the time the request was submitted.
      request - The request to store.
    • builder

      public static <R> ReadOnlyRequestRepository.Builder<R> builder(Supplier<Integer> majority)