Search in sources :

Example 1 with FSMCallerOptions

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

the class NodeImpl method initFSMCaller.

private boolean initFSMCaller(final LogId bootstrapId) {
    if (this.fsmCaller == null) {
        LOG.error("Fail to init fsm caller, null instance, bootstrapId={}.", bootstrapId);
        return false;
    }
    this.closureQueue = new ClosureQueueImpl(this.getOptions());
    final FSMCallerOptions opts = new FSMCallerOptions();
    opts.setAfterShutdown(status -> afterShutdown());
    opts.setLogManager(this.logManager);
    opts.setFsm(this.options.getFsm());
    opts.setClosureQueue(this.closureQueue);
    opts.setNode(this);
    opts.setBootstrapId(bootstrapId);
    opts.setRaftMessagesFactory(raftOptions.getRaftMessagesFactory());
    opts.setfSMCallerExecutorDisruptor(options.getfSMCallerExecutorDisruptor());
    opts.setGroupId(groupId);
    return this.fsmCaller.init(opts);
}
Also used : FSMCallerOptions(org.apache.ignite.raft.jraft.option.FSMCallerOptions) ClosureQueueImpl(org.apache.ignite.raft.jraft.closure.ClosureQueueImpl)

Example 2 with FSMCallerOptions

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

ClosureQueueImpl (org.apache.ignite.raft.jraft.closure.ClosureQueueImpl)2 FSMCallerOptions (org.apache.ignite.raft.jraft.option.FSMCallerOptions)2 RaftMessagesFactory (org.apache.ignite.raft.jraft.RaftMessagesFactory)1 StripedDisruptor (org.apache.ignite.raft.jraft.disruptor.StripedDisruptor)1 LogId (org.apache.ignite.raft.jraft.entity.LogId)1 NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1