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));
}
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));
}
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));
}
Aggregations