Search in sources :

Example 1 with DefaultJRaftServiceFactory

use of org.apache.ignite.raft.jraft.core.DefaultJRaftServiceFactory in project ignite-3 by apache.

the class SnapshotExecutorTest method setup.

@BeforeEach
public void setup() throws Exception {
    timerManager = new TimerManager(5);
    raftOptions = new RaftOptions();
    writer = new LocalSnapshotWriter(path.toString(), snapshotStorage, raftOptions);
    reader = new LocalSnapshotReader(snapshotStorage, null, new Endpoint("localhost", 8081), raftOptions, path.toString());
    Mockito.lenient().when(snapshotStorage.open()).thenReturn(reader);
    Mockito.lenient().when(snapshotStorage.create(true)).thenReturn(writer);
    table = new LocalSnapshotMetaTable(raftOptions);
    table.addFile("testFile", raftOptions.getRaftMessagesFactory().localFileMeta().checksum("test").build());
    table.setMeta(raftOptions.getRaftMessagesFactory().snapshotMeta().lastIncludedIndex(1).lastIncludedTerm(1).build());
    uri = "remote://" + hostPort + "/" + readerId;
    copyOpts = new CopyOptions();
    Mockito.when(node.getRaftOptions()).thenReturn(new RaftOptions());
    options = new NodeOptions();
    options.setCommonExecutor(JRaftUtils.createExecutor("test-executor", Utils.cpus()));
    options.setScheduler(timerManager);
    Mockito.when(node.getOptions()).thenReturn(options);
    Mockito.when(node.getRpcClientService()).thenReturn(raftClientService);
    Mockito.when(node.getServiceFactory()).thenReturn(new DefaultJRaftServiceFactory());
    executor = new SnapshotExecutorImpl();
    final SnapshotExecutorOptions opts = new SnapshotExecutorOptions();
    opts.setFsmCaller(fSMCaller);
    opts.setInitTerm(0);
    opts.setNode(node);
    opts.setLogManager(logManager);
    opts.setUri(path.toString());
    addr = new Endpoint("localhost", 8081);
    opts.setAddr(addr);
    assertTrue(executor.init(opts));
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) Endpoint(org.apache.ignite.raft.jraft.util.Endpoint) LocalSnapshotMetaTable(org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotMetaTable) LocalSnapshotReader(org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotReader) SnapshotExecutorImpl(org.apache.ignite.raft.jraft.storage.snapshot.SnapshotExecutorImpl) CopyOptions(org.apache.ignite.raft.jraft.option.CopyOptions) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) DefaultJRaftServiceFactory(org.apache.ignite.raft.jraft.core.DefaultJRaftServiceFactory) TimerManager(org.apache.ignite.raft.jraft.core.TimerManager) LocalSnapshotWriter(org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotWriter) SnapshotExecutorOptions(org.apache.ignite.raft.jraft.option.SnapshotExecutorOptions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

DefaultJRaftServiceFactory (org.apache.ignite.raft.jraft.core.DefaultJRaftServiceFactory)1 TimerManager (org.apache.ignite.raft.jraft.core.TimerManager)1 CopyOptions (org.apache.ignite.raft.jraft.option.CopyOptions)1 NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)1 RaftOptions (org.apache.ignite.raft.jraft.option.RaftOptions)1 SnapshotExecutorOptions (org.apache.ignite.raft.jraft.option.SnapshotExecutorOptions)1 SnapshotExecutorImpl (org.apache.ignite.raft.jraft.storage.snapshot.SnapshotExecutorImpl)1 LocalSnapshotMetaTable (org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotMetaTable)1 LocalSnapshotReader (org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotReader)1 LocalSnapshotWriter (org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotWriter)1 Endpoint (org.apache.ignite.raft.jraft.util.Endpoint)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1