java.lang.Object
org.jgroups.raft.util.RequestTable<T>
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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a response to the response set.voidcreate(long index, T vote, CompletableFuture<byte[]> future, Supplier<Integer> majority) voidcreate(long index, T vote, CompletableFuture<byte[]> future, Supplier<Integer> majority, Options opts) voidCompletes all uncommitted requests with the provided exception.booleanisCommitted(long index) Whether or not the entry at index is committedvoidnotifyAndRemove(long index, byte[] response) Notifies the CompletableFuture and then removes the entry for indexremove(long index) intsize()number of requests being processedtoString()
-
Field Details
-
requests
-
-
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
Completes all uncommitted requests with the provided exception.This method should be invoked before setting the instance to
nullwhen 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
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
-
notifyAndRemove
public void notifyAndRemove(long index, byte[] response) Notifies the CompletableFuture and then removes the entry for index -
toString
-