Search in sources :

Example 6 with NodeId

use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.

the class NodeRequestProcessorTest method testOK.

@Test
public void testOK() {
    Node node = Mockito.mock(Node.class, withSettings().extraInterfaces(RaftServerService.class));
    Mockito.when(node.getGroupId()).thenReturn("test");
    PeerId peerId = new PeerId("localhost", 8081);
    Mockito.when(node.getNodeId()).thenReturn(new NodeId("test", peerId));
    asyncContext.getNodeManager().add(node);
    this.processor.handleRequest(asyncContext, TestUtils.createPingRequest());
    ErrorResponse resp = (ErrorResponse) asyncContext.getResponseObject();
    assertNotNull(resp);
    assertEquals(0, resp.errorCode());
}
Also used : Node(org.apache.ignite.raft.jraft.Node) NodeId(org.apache.ignite.raft.jraft.entity.NodeId) RaftServerService(org.apache.ignite.raft.jraft.rpc.RaftServerService) PeerId(org.apache.ignite.raft.jraft.entity.PeerId) ErrorResponse(org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 7 with NodeId

use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.

the class ReplicatorGroupTest method setup.

@BeforeEach
public void setup() {
    this.timerManager = new TimerManager(5);
    this.replicatorGroup = new ReplicatorGroupImpl();
    final ReplicatorGroupOptions rgOpts = new ReplicatorGroupOptions();
    rgOpts.setHeartbeatTimeoutMs(heartbeatTimeout(this.options.getElectionTimeoutMs()));
    rgOpts.setElectionTimeoutMs(this.options.getElectionTimeoutMs());
    rgOpts.setLogManager(this.logManager);
    rgOpts.setBallotBox(this.ballotBox);
    rgOpts.setNode(this.node);
    rgOpts.setRaftRpcClientService(this.rpcService);
    rgOpts.setSnapshotStorage(this.snapshotStorage);
    rgOpts.setRaftOptions(this.raftOptions);
    rgOpts.setTimerManager(this.timerManager);
    Mockito.when(this.logManager.getLastLogIndex()).thenReturn(10L);
    Mockito.when(this.logManager.getTerm(10)).thenReturn(1L);
    Mockito.when(this.node.getNodeMetrics()).thenReturn(new NodeMetrics(false));
    Mockito.when(this.node.getNodeId()).thenReturn(new NodeId("test", new PeerId("localhost", 8081)));
    mockSendEmptyEntries();
    assertTrue(this.replicatorGroup.init(this.node.getNodeId(), rgOpts));
}
Also used : ReplicatorGroupOptions(org.apache.ignite.raft.jraft.option.ReplicatorGroupOptions) NodeId(org.apache.ignite.raft.jraft.entity.NodeId) PeerId(org.apache.ignite.raft.jraft.entity.PeerId) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with NodeId

use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.

the class AbstractCliRequestProcessorTest method testHandleRequest.

@Test
public void testHandleRequest() {
    this.mockNodes(3);
    Mockito.when(this.node.getGroupId()).thenReturn(this.groupId);
    PeerId peerId = new PeerId();
    peerId.parse(this.peerIdStr);
    Mockito.when(this.node.getOptions()).thenReturn(new NodeOptions());
    Mockito.when(this.node.getNodeId()).thenReturn(new NodeId("test", peerId));
    if (asyncContext != null)
        asyncContext.getNodeManager().add(node);
    BaseCliRequestProcessor<T> processor = newProcessor();
    processor.handleRequest(this.asyncContext, createRequest(this.groupId, peerId));
    ArgumentCaptor<Closure> doneArg = ArgumentCaptor.forClass(Closure.class);
    verify(processor.interest(), this.node, doneArg);
}
Also used : Closure(org.apache.ignite.raft.jraft.Closure) NodeId(org.apache.ignite.raft.jraft.entity.NodeId) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) PeerId(org.apache.ignite.raft.jraft.entity.PeerId) Test(org.junit.jupiter.api.Test)

Example 9 with NodeId

use of org.apache.ignite.raft.jraft.entity.NodeId in project ignite-3 by apache.

the class BaseCliRequestProcessorTest method mockNode.

private Node mockNode(boolean disableCli) {
    Node node = Mockito.mock(Node.class);
    Mockito.when(node.getGroupId()).thenReturn("test");
    Mockito.when(node.getNodeId()).thenReturn(new NodeId("test", this.peer.copy()));
    NodeOptions opts = new NodeOptions();
    opts.setDisableCli(disableCli);
    Mockito.when(node.getOptions()).thenReturn(opts);
    this.asyncContext.getNodeManager().add(node);
    return node;
}
Also used : Node(org.apache.ignite.raft.jraft.Node) NodeId(org.apache.ignite.raft.jraft.entity.NodeId) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions)

Aggregations

NodeId (org.apache.ignite.raft.jraft.entity.NodeId)9 PeerId (org.apache.ignite.raft.jraft.entity.PeerId)6 NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)4 Node (org.apache.ignite.raft.jraft.Node)3 Test (org.junit.jupiter.api.Test)3 ReadOnlyServiceOptions (org.apache.ignite.raft.jraft.option.ReadOnlyServiceOptions)2 ReplicatorGroupOptions (org.apache.ignite.raft.jraft.option.ReplicatorGroupOptions)2 ErrorResponse (org.apache.ignite.raft.jraft.rpc.RpcRequests.ErrorResponse)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ExecutorService (java.util.concurrent.ExecutorService)1 Closure (org.apache.ignite.raft.jraft.Closure)1 Status (org.apache.ignite.raft.jraft.Status)1 ConfigurationEntry (org.apache.ignite.raft.jraft.conf.ConfigurationEntry)1 ConfigurationManager (org.apache.ignite.raft.jraft.conf.ConfigurationManager)1 StripedDisruptor (org.apache.ignite.raft.jraft.disruptor.StripedDisruptor)1 LogId (org.apache.ignite.raft.jraft.entity.LogId)1 BallotBoxOptions (org.apache.ignite.raft.jraft.option.BallotBoxOptions)1 RaftOptions (org.apache.ignite.raft.jraft.option.RaftOptions)1 RaftServerService (org.apache.ignite.raft.jraft.rpc.RaftServerService)1 DefaultRaftClientService (org.apache.ignite.raft.jraft.rpc.impl.core.DefaultRaftClientService)1