Search in sources :

Example 1 with SnapshotCopierOptions

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);
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) SnapshotCopierOptions(org.apache.ignite.raft.jraft.option.SnapshotCopierOptions) Endpoint(org.apache.ignite.raft.jraft.util.Endpoint) CopyOptions(org.apache.ignite.raft.jraft.option.CopyOptions) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) TimerManager(org.apache.ignite.raft.jraft.core.TimerManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with SnapshotCopierOptions

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());
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) SnapshotCopierOptions(org.apache.ignite.raft.jraft.option.SnapshotCopierOptions) Endpoint(org.apache.ignite.raft.jraft.util.Endpoint) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) Test(org.junit.jupiter.api.Test)

Example 3 with SnapshotCopierOptions

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())));
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) SnapshotCopierOptions(org.apache.ignite.raft.jraft.option.SnapshotCopierOptions) Endpoint(org.apache.ignite.raft.jraft.util.Endpoint) NodeOptions(org.apache.ignite.raft.jraft.option.NodeOptions) Test(org.junit.jupiter.api.Test)

Example 4 with SnapshotCopierOptions

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;
}
Also used : SnapshotCopierOptions(org.apache.ignite.raft.jraft.option.SnapshotCopierOptions)

Aggregations

SnapshotCopierOptions (org.apache.ignite.raft.jraft.option.SnapshotCopierOptions)4 NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)3 RaftOptions (org.apache.ignite.raft.jraft.option.RaftOptions)3 Endpoint (org.apache.ignite.raft.jraft.util.Endpoint)3 Test (org.junit.jupiter.api.Test)2 TimerManager (org.apache.ignite.raft.jraft.core.TimerManager)1 CopyOptions (org.apache.ignite.raft.jraft.option.CopyOptions)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1