Search in sources :

Example 1 with ReadIndexRequestBuilder

use of org.apache.ignite.raft.jraft.rpc.ReadIndexRequestBuilder in project ignite-3 by apache.

the class ReadOnlyServiceImpl method executeReadIndexEvents.

private void executeReadIndexEvents(final List<ReadIndexEvent> events) {
    if (events.isEmpty())
        return;
    ReadIndexRequestBuilder rb = raftOptions.getRaftMessagesFactory().readIndexRequest().groupId(this.node.getGroupId()).serverId(this.node.getServerId().toString());
    List<ReadIndexState> states = new ArrayList<>(events.size());
    List<ByteString> entries = new ArrayList<>(events.size());
    for (ReadIndexEvent event : events) {
        byte[] ctx = event.requestContext.get();
        entries.add(ctx == null ? ByteString.EMPTY : new ByteString(ctx));
        states.add(new ReadIndexState(event.requestContext, event.done, event.startTime));
    }
    ReadIndexRequest request = rb.entriesList(entries).build();
    this.node.handleReadIndexRequest(request, new ReadIndexResponseClosure(states, request));
}
Also used : ReadIndexRequest(org.apache.ignite.raft.jraft.rpc.RpcRequests.ReadIndexRequest) ByteString(org.apache.ignite.raft.jraft.util.ByteString) ReadIndexState(org.apache.ignite.raft.jraft.entity.ReadIndexState) ReadIndexRequestBuilder(org.apache.ignite.raft.jraft.rpc.ReadIndexRequestBuilder) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 ReadIndexState (org.apache.ignite.raft.jraft.entity.ReadIndexState)1 ReadIndexRequestBuilder (org.apache.ignite.raft.jraft.rpc.ReadIndexRequestBuilder)1 ReadIndexRequest (org.apache.ignite.raft.jraft.rpc.RpcRequests.ReadIndexRequest)1 ByteString (org.apache.ignite.raft.jraft.util.ByteString)1