Search in sources :

Example 31 with NodeOptions

use of org.apache.ignite.raft.jraft.option.NodeOptions in project ignite-3 by apache.

the class IgniteRpcTest method createServer.

/**
 * {@inheritDoc}
 */
@Override
public RpcServer<?> createServer(Endpoint endpoint) {
    ClusterService service = ClusterServiceTestUtils.clusterService(testInfo, endpoint.getPort(), new StaticNodeFinder(Collections.emptyList()), new TestScaleCubeClusterServiceFactory());
    NodeOptions nodeOptions = new NodeOptions();
    requestExecutor = JRaftUtils.createRequestExecutor(nodeOptions);
    var server = new TestIgniteRpcServer(service, new NodeManager(), nodeOptions, requestExecutor) {

        @Override
        public void shutdown() {
            super.shutdown();
            service.stop();
        }
    };
    service.start();
    return server;
}
Also used : NodeManager(org.apache.ignite.raft.jraft.NodeManager) ClusterService(org.apache.ignite.network.ClusterService) TestScaleCubeClusterServiceFactory(org.apache.ignite.network.scalecube.TestScaleCubeClusterServiceFactory) StaticNodeFinder(org.apache.ignite.network.StaticNodeFinder) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions)

Example 32 with NodeOptions

use of org.apache.ignite.raft.jraft.option.NodeOptions 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 33 with NodeOptions

use of org.apache.ignite.raft.jraft.option.NodeOptions 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)

Example 34 with NodeOptions

use of org.apache.ignite.raft.jraft.option.NodeOptions in project ignite-3 by apache.

the class BallotBoxTest method setup.

@BeforeEach
public void setup() {
    BallotBoxOptions opts = new BallotBoxOptions();
    NodeOptions options = new NodeOptions();
    executor = JRaftUtils.createExecutor("test-executor-", Utils.cpus());
    options.setCommonExecutor(executor);
    this.closureQueue = new ClosureQueueImpl(options);
    opts.setClosureQueue(this.closureQueue);
    opts.setWaiter(this.waiter);
    box = new BallotBox();
    assertTrue(box.init(opts));
}
Also used : BallotBoxOptions(org.apache.ignite.raft.jraft.option.BallotBoxOptions) ClosureQueueImpl(org.apache.ignite.raft.jraft.closure.ClosureQueueImpl) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)34 PeerId (org.apache.ignite.raft.jraft.entity.PeerId)17 Test (org.junit.jupiter.api.Test)14 Endpoint (org.apache.ignite.raft.jraft.util.Endpoint)13 RaftGroupService (org.apache.ignite.raft.jraft.RaftGroupService)11 BeforeEach (org.junit.jupiter.api.BeforeEach)11 Node (org.apache.ignite.raft.jraft.Node)10 Configuration (org.apache.ignite.raft.jraft.conf.Configuration)8 RaftOptions (org.apache.ignite.raft.jraft.option.RaftOptions)8 ExecutorService (java.util.concurrent.ExecutorService)5 NodeId (org.apache.ignite.raft.jraft.entity.NodeId)4 ByteBuffer (java.nio.ByteBuffer)3 ArrayList (java.util.ArrayList)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ClusterService (org.apache.ignite.network.ClusterService)3 NetworkAddress (org.apache.ignite.network.NetworkAddress)3 SynchronizedClosure (org.apache.ignite.raft.jraft.closure.SynchronizedClosure)3 BootstrapOptions (org.apache.ignite.raft.jraft.option.BootstrapOptions)3 File (java.io.File)2 Path (java.nio.file.Path)2