Search in sources :

Example 1 with ClosureQueueImpl

use of com.alipay.sofa.jraft.closure.ClosureQueueImpl in project sofa-jraft by sofastack.

the class BallotBoxTest method setup.

@Before
public void setup() {
    BallotBoxOptions opts = new BallotBoxOptions();
    this.closureQueue = new ClosureQueueImpl();
    opts.setClosureQueue(this.closureQueue);
    opts.setWaiter(this.waiter);
    box = new BallotBox();
    assertTrue(box.init(opts));
}
Also used : BallotBoxOptions(com.alipay.sofa.jraft.option.BallotBoxOptions) ClosureQueueImpl(com.alipay.sofa.jraft.closure.ClosureQueueImpl) Before(org.junit.Before)

Example 2 with ClosureQueueImpl

use of com.alipay.sofa.jraft.closure.ClosureQueueImpl in project sofa-jraft by sofastack.

the class FSMCallerTest method setup.

@Before
public void setup() {
    this.fsmCaller = new FSMCallerImpl();
    this.closureQueue = new ClosureQueueImpl();
    final FSMCallerOptions opts = new FSMCallerOptions();
    Mockito.when(this.node.getNodeMetrics()).thenReturn(new NodeMetrics(false));
    opts.setNode(this.node);
    opts.setFsm(this.fsm);
    opts.setLogManager(this.logManager);
    opts.setBootstrapId(new LogId(10, 1));
    opts.setClosureQueue(this.closureQueue);
    assertTrue(this.fsmCaller.init(opts));
}
Also used : FSMCallerOptions(com.alipay.sofa.jraft.option.FSMCallerOptions) ClosureQueueImpl(com.alipay.sofa.jraft.closure.ClosureQueueImpl) LogId(com.alipay.sofa.jraft.entity.LogId) Before(org.junit.Before)

Example 3 with ClosureQueueImpl

use of com.alipay.sofa.jraft.closure.ClosureQueueImpl in project sofa-jraft by sofastack.

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();
    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.setDisruptorBufferSize(this.raftOptions.getDisruptorBufferSize());
    return this.fsmCaller.init(opts);
}
Also used : FSMCallerOptions(com.alipay.sofa.jraft.option.FSMCallerOptions) ClosureQueueImpl(com.alipay.sofa.jraft.closure.ClosureQueueImpl)

Aggregations

ClosureQueueImpl (com.alipay.sofa.jraft.closure.ClosureQueueImpl)3 FSMCallerOptions (com.alipay.sofa.jraft.option.FSMCallerOptions)2 Before (org.junit.Before)2 LogId (com.alipay.sofa.jraft.entity.LogId)1 BallotBoxOptions (com.alipay.sofa.jraft.option.BallotBoxOptions)1