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