Search in sources :

Example 1 with StripedDisruptor

use of org.apache.ignite.raft.jraft.disruptor.StripedDisruptor in project ignite-3 by apache.

the class ReadOnlyServiceTest method setup.

@BeforeEach
public void setup() {
    this.readOnlyServiceImpl = new ReadOnlyServiceImpl();
    RaftOptions raftOptions = new RaftOptions();
    this.msgFactory = raftOptions.getRaftMessagesFactory();
    final ReadOnlyServiceOptions opts = new ReadOnlyServiceOptions();
    opts.setFsmCaller(this.fsmCaller);
    opts.setNode(this.node);
    opts.setRaftOptions(raftOptions);
    opts.setGroupId("TestSrv");
    opts.setReadOnlyServiceDisruptor(disruptor = new StripedDisruptor<>("TestReadOnlyServiceDisruptor", 1024, () -> new ReadOnlyServiceImpl.ReadIndexEvent(), 1));
    NodeOptions nodeOptions = new NodeOptions();
    ExecutorService executor = JRaftUtils.createExecutor("test-executor", Utils.cpus());
    executors.add(executor);
    nodeOptions.setCommonExecutor(executor);
    ExecutorService clientExecutor = JRaftUtils.createClientExecutor(nodeOptions, "unittest");
    executors.add(clientExecutor);
    nodeOptions.setClientExecutor(clientExecutor);
    Scheduler scheduler = JRaftUtils.createScheduler(nodeOptions);
    this.scheduler = scheduler;
    nodeOptions.setScheduler(scheduler);
    Mockito.when(this.node.getNodeMetrics()).thenReturn(new NodeMetrics(false));
    Mockito.when(this.node.getGroupId()).thenReturn("test");
    Mockito.when(this.node.getOptions()).thenReturn(nodeOptions);
    Mockito.when(this.node.getNodeId()).thenReturn(new NodeId("test", new PeerId("localhost:8081", 0)));
    Mockito.when(this.node.getServerId()).thenReturn(new PeerId("localhost:8081", 0));
    assertTrue(this.readOnlyServiceImpl.init(opts));
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) ReadOnlyServiceOptions(org.apache.ignite.raft.jraft.option.ReadOnlyServiceOptions) ExecutorService(java.util.concurrent.ExecutorService) NodeId(org.apache.ignite.raft.jraft.entity.NodeId) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) StripedDisruptor(org.apache.ignite.raft.jraft.disruptor.StripedDisruptor) PeerId(org.apache.ignite.raft.jraft.entity.PeerId) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with StripedDisruptor

use of org.apache.ignite.raft.jraft.disruptor.StripedDisruptor in project ignite-3 by apache.

the class LogManagerTest method setup.

@BeforeEach
public void setup() throws Exception {
    this.confManager = new ConfigurationManager();
    this.raftOptions = new RaftOptions();
    this.logStorage = newLogStorage(raftOptions);
    this.logManager = new LogManagerImpl();
    final LogManagerOptions opts = new LogManagerOptions();
    NodeOptions nodeOptions = new NodeOptions();
    executor = JRaftUtils.createExecutor("test-executor", Utils.cpus());
    nodeOptions.setCommonExecutor(executor);
    Mockito.when(node.getOptions()).thenReturn(nodeOptions);
    opts.setConfigurationManager(this.confManager);
    opts.setLogEntryCodecFactory(LogEntryV1CodecFactory.getInstance());
    opts.setFsmCaller(this.fsmCaller);
    opts.setNode(node);
    opts.setNodeMetrics(new NodeMetrics(false));
    opts.setLogStorage(this.logStorage);
    opts.setRaftOptions(raftOptions);
    opts.setGroupId("TestSrv");
    opts.setLogManagerDisruptor(disruptor = new StripedDisruptor<>("TestLogManagerDisruptor", 1024, () -> new LogManagerImpl.StableClosureEvent(), 1));
    assertTrue(this.logManager.init(opts));
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) NodeMetrics(org.apache.ignite.raft.jraft.core.NodeMetrics) LogManagerOptions(org.apache.ignite.raft.jraft.option.LogManagerOptions) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) ConfigurationManager(org.apache.ignite.raft.jraft.conf.ConfigurationManager) StripedDisruptor(org.apache.ignite.raft.jraft.disruptor.StripedDisruptor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with StripedDisruptor

use of org.apache.ignite.raft.jraft.disruptor.StripedDisruptor in project ignite-3 by apache.

the class FSMCallerTest method setup.

@BeforeEach
public void setup() {
    this.fsmCaller = new FSMCallerImpl();
    NodeOptions options = new NodeOptions();
    executor = JRaftUtils.createExecutor("test-executor-", Utils.cpus());
    options.setCommonExecutor(executor);
    this.closureQueue = new ClosureQueueImpl(options);
    opts = new FSMCallerOptions();
    Mockito.when(this.node.getNodeMetrics()).thenReturn(new NodeMetrics(false));
    Mockito.when(this.node.getOptions()).thenReturn(options);
    opts.setNode(this.node);
    opts.setFsm(this.fsm);
    opts.setLogManager(this.logManager);
    opts.setBootstrapId(new LogId(10, 1));
    opts.setClosureQueue(this.closureQueue);
    opts.setRaftMessagesFactory(new RaftMessagesFactory());
    opts.setGroupId("TestSrv");
    opts.setfSMCallerExecutorDisruptor(disruptor = new StripedDisruptor<>("TestFSMDisruptor", 1024, () -> new FSMCallerImpl.ApplyTask(), 1));
    assertTrue(this.fsmCaller.init(opts));
}
Also used : FSMCallerOptions(org.apache.ignite.raft.jraft.option.FSMCallerOptions) ClosureQueueImpl(org.apache.ignite.raft.jraft.closure.ClosureQueueImpl) RaftMessagesFactory(org.apache.ignite.raft.jraft.RaftMessagesFactory) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) LogId(org.apache.ignite.raft.jraft.entity.LogId) StripedDisruptor(org.apache.ignite.raft.jraft.disruptor.StripedDisruptor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

StripedDisruptor (org.apache.ignite.raft.jraft.disruptor.StripedDisruptor)3 NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 RaftOptions (org.apache.ignite.raft.jraft.option.RaftOptions)2 ExecutorService (java.util.concurrent.ExecutorService)1 RaftMessagesFactory (org.apache.ignite.raft.jraft.RaftMessagesFactory)1 ClosureQueueImpl (org.apache.ignite.raft.jraft.closure.ClosureQueueImpl)1 ConfigurationManager (org.apache.ignite.raft.jraft.conf.ConfigurationManager)1 NodeMetrics (org.apache.ignite.raft.jraft.core.NodeMetrics)1 LogId (org.apache.ignite.raft.jraft.entity.LogId)1 NodeId (org.apache.ignite.raft.jraft.entity.NodeId)1 PeerId (org.apache.ignite.raft.jraft.entity.PeerId)1 FSMCallerOptions (org.apache.ignite.raft.jraft.option.FSMCallerOptions)1 LogManagerOptions (org.apache.ignite.raft.jraft.option.LogManagerOptions)1 ReadOnlyServiceOptions (org.apache.ignite.raft.jraft.option.ReadOnlyServiceOptions)1