Search in sources :

Example 1 with ClosureQueueImpl

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

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

Example 3 with ClosureQueueImpl

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

ClosureQueueImpl (org.apache.ignite.raft.jraft.closure.ClosureQueueImpl)3 FSMCallerOptions (org.apache.ignite.raft.jraft.option.FSMCallerOptions)2 NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)2 BeforeEach (org.junit.jupiter.api.BeforeEach)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 BallotBoxOptions (org.apache.ignite.raft.jraft.option.BallotBoxOptions)1