Search in sources :

Example 1 with TimerManager

use of org.apache.ignite.raft.jraft.core.TimerManager 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 TimerManager

use of org.apache.ignite.raft.jraft.core.TimerManager 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)

Example 3 with TimerManager

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

the class CopySessionTest method setup.

@BeforeEach
public void setup() {
    this.timerManager = new TimerManager(5);
    this.copyOpts = new CopyOptions();
    this.raftOpts = new RaftOptions();
    this.rb = raftOpts.getRaftMessagesFactory().getFileRequest().readerId(99).filename("data");
    this.nodeOptions = new NodeOptions();
    this.nodeOptions.setCommonExecutor(Executors.newSingleThreadExecutor());
    this.session = new CopySession(rpcService, timerManager, null, raftOpts, this.nodeOptions, rb, address);
    this.session.setCopyOptions(copyOpts);
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) 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 4 with TimerManager

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

the class RemoteFileCopierTest method setup.

@BeforeEach
public void setup() {
    this.timerManager = new TimerManager(5);
    copier = new RemoteFileCopier();
}
Also used : TimerManager(org.apache.ignite.raft.jraft.core.TimerManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

TimerManager (org.apache.ignite.raft.jraft.core.TimerManager)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 CopyOptions (org.apache.ignite.raft.jraft.option.CopyOptions)3 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)2 DefaultJRaftServiceFactory (org.apache.ignite.raft.jraft.core.DefaultJRaftServiceFactory)1 SnapshotCopierOptions (org.apache.ignite.raft.jraft.option.SnapshotCopierOptions)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