use of org.apache.ignite.raft.jraft.option.SnapshotCopierOptions 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.SnapshotCopierOptions 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());
}
use of org.apache.ignite.raft.jraft.option.SnapshotCopierOptions in project ignite-3 by apache.
the class RemoteFileCopierTest method testInitFail.
@Test
public void testInitFail() {
Mockito.when(rpcService.connect(new Endpoint("localhost", 8081))).thenReturn(false);
assertFalse(copier.init("remote://localhost:8081/999", null, new SnapshotCopierOptions(rpcService, timerManager, new RaftOptions(), new NodeOptions())));
}
use of org.apache.ignite.raft.jraft.option.SnapshotCopierOptions in project ignite-3 by apache.
the class SnapshotExecutorImpl method newCopierOpts.
private SnapshotCopierOptions newCopierOpts() {
final SnapshotCopierOptions copierOpts = new SnapshotCopierOptions();
copierOpts.setNodeOptions(this.node.getOptions());
copierOpts.setRaftClientService(this.node.getRpcClientService());
copierOpts.setTimerManager(this.node.getOptions().getScheduler());
copierOpts.setRaftOptions(this.node.getRaftOptions());
return copierOpts;
}
Aggregations