Search in sources :

Example 6 with RpcContext

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

the class AppendEntriesRequestProcessorTest method testTooManyPendingResponses.

@Test
public void testTooManyPendingResponses() {
    final PeerId peer = mockNode();
    nodeManager.get(this.groupId, peer).getRaftOptions().setMaxReplicatorInflightMsgs(2);
    final RpcContext asyncContext = Mockito.mock(RpcContext.class);
    final AppendEntriesRequestProcessor processor = (AppendEntriesRequestProcessor) newProcessor();
    final PeerPair pair = processor.pairOf(this.peerIdStr, this.serverId);
    final PingRequest msg = TestUtils.createPingRequest();
    final PeerRequestContext ctx = processor.getOrCreatePeerRequestContext(this.groupId, pair, nodeManager);
    assertNotNull(ctx);
    processor.sendSequenceResponse(this.groupId, pair, 1, asyncContext, msg);
    processor.sendSequenceResponse(this.groupId, pair, 2, asyncContext, msg);
    processor.sendSequenceResponse(this.groupId, pair, 3, asyncContext, msg);
    Mockito.verify(asyncContext, Mockito.never()).sendResponse(msg);
    final PeerRequestContext newCtx = processor.getOrCreatePeerRequestContext(this.groupId, pair, nodeManager);
    assertNotNull(newCtx);
    assertNotSame(ctx, newCtx);
}
Also used : RpcContext(org.apache.ignite.raft.jraft.rpc.RpcContext) PingRequest(org.apache.ignite.raft.jraft.rpc.RpcRequests.PingRequest) PeerPair(org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestProcessor.PeerPair) PeerRequestContext(org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestProcessor.PeerRequestContext) PeerId(org.apache.ignite.raft.jraft.entity.PeerId) Test(org.junit.jupiter.api.Test)

Aggregations

RpcContext (org.apache.ignite.raft.jraft.rpc.RpcContext)6 Test (org.junit.jupiter.api.Test)6 Message (org.apache.ignite.raft.jraft.rpc.Message)4 RpcRequestClosure (org.apache.ignite.raft.jraft.rpc.RpcRequestClosure)4 RpcRequests (org.apache.ignite.raft.jraft.rpc.RpcRequests)4 PingRequest (org.apache.ignite.raft.jraft.rpc.RpcRequests.PingRequest)2 PeerPair (org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestProcessor.PeerPair)2 PeerId (org.apache.ignite.raft.jraft.entity.PeerId)1 PeerRequestContext (org.apache.ignite.raft.jraft.rpc.impl.core.AppendEntriesRequestProcessor.PeerRequestContext)1