use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.
the class LocalSnapshotWriterTest method setup.
@BeforeEach
public void setup() throws Exception {
opts = new RaftOptions();
this.writer = new LocalSnapshotWriter(path.toString(), snapshotStorage, opts);
assertTrue(this.writer.init(null));
}
use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.
the class LocalSnapshotCopierTest method setup.
@BeforeEach
public void setup() throws Exception {
this.timerManager = new TimerManager(5);
this.raftOptions = new RaftOptions();
this.writer = new LocalSnapshotWriter(this.path.toString(), this.snapshotStorage, this.raftOptions);
this.reader = new LocalSnapshotReader(this.snapshotStorage, null, new Endpoint("localhost", 8081), this.raftOptions, this.path.toString());
Mockito.when(this.snapshotStorage.open()).thenReturn(this.reader);
Mockito.when(this.snapshotStorage.create(true)).thenReturn(this.writer);
this.table = new LocalSnapshotMetaTable(this.raftOptions);
this.table.addFile("testFile", raftOptions.getRaftMessagesFactory().localFileMeta().checksum("test").build());
this.table.setMeta(raftOptions.getRaftMessagesFactory().snapshotMeta().lastIncludedIndex(1).lastIncludedTerm(1).build());
this.uri = "remote://" + this.hostPort + "/" + this.readerId;
this.copier = new LocalSnapshotCopier();
this.copyOpts = new CopyOptions();
Mockito.when(this.raftClientService.connect(new Endpoint("localhost", 8081))).thenReturn(true);
nodeOptions = new NodeOptions();
nodeOptions.setCommonExecutor(JRaftUtils.createExecutor("test-executor", Utils.cpus()));
assertTrue(this.copier.init(this.uri, new SnapshotCopierOptions(this.raftClientService, this.timerManager, this.raftOptions, nodeOptions)));
this.copier.setStorage(this.snapshotStorage);
}
use of org.apache.ignite.raft.jraft.option.RaftOptions 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));
}
use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.
the class LocalRaftMetaStorageTest method testGetAndSetReload.
@Test
public void testGetAndSetReload() {
assertEquals(0, this.raftMetaStorage.getTerm());
assertTrue(this.raftMetaStorage.getVotedFor().isEmpty());
this.raftMetaStorage.setTerm(99);
assertEquals(99, this.raftMetaStorage.getTerm());
assertTrue(this.raftMetaStorage.getVotedFor().isEmpty());
assertTrue(this.raftMetaStorage.setVotedFor(new PeerId("localhost", 8081)));
assertEquals(99, this.raftMetaStorage.getTerm());
assertEquals(new PeerId("localhost", 8081), this.raftMetaStorage.getVotedFor());
assertTrue(this.raftMetaStorage.setTermAndVotedFor(100, new PeerId("localhost", 8083)));
assertEquals(100, this.raftMetaStorage.getTerm());
assertEquals(new PeerId("localhost", 8083), this.raftMetaStorage.getVotedFor());
this.raftMetaStorage = new LocalRaftMetaStorage(this.path.toString(), new RaftOptions());
Mockito.when(this.node.getNodeMetrics()).thenReturn(null);
this.raftMetaStorage.init(newOptions());
assertEquals(100, this.raftMetaStorage.getTerm());
assertEquals(new PeerId("localhost", 8083), this.raftMetaStorage.getVotedFor());
}
use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.
the class RemoteFileCopierTest method testInit.
@Test
public void testInit() {
Mockito.when(rpcService.connect(new Endpoint("localhost", 8081))).thenReturn(true);
assertTrue(copier.init("remote://localhost:8081/999", null, new SnapshotCopierOptions(rpcService, timerManager, new RaftOptions(), new NodeOptions())));
assertEquals(999, copier.getReaderId());
assertEquals("localhost", copier.getEndpoint().getIp());
assertEquals(8081, copier.getEndpoint().getPort());
}
Aggregations