Search in sources :

Example 16 with RaftOptions

use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.

the class LogStorageBenchmark method main.

public static void main(final String[] args) {
    String testPath = Paths.get(SystemPropertyUtil.get("user.dir"), "log_storage").toString();
    System.out.println("Test log storage path: " + testPath);
    int batchSize = 100;
    int logSize = 16 * 1024;
    int totalLogs = 30 * 1024;
    LogStorage logStorage = new RocksDBLogStorage(testPath, new RaftOptions());
    // LogStorage logStorage = new LocalLogStorage(testPath, new RaftOptions());
    LogStorageOptions opts = new LogStorageOptions();
    opts.setConfigurationManager(new ConfigurationManager());
    opts.setLogEntryCodecFactory(LogEntryV1CodecFactory.getInstance());
    logStorage.init(opts);
    new LogStorageBenchmark(logStorage, logSize, totalLogs, batchSize).doTest();
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) LogStorageOptions(org.apache.ignite.raft.jraft.option.LogStorageOptions) LogStorage(org.apache.ignite.raft.jraft.storage.LogStorage) ConfigurationManager(org.apache.ignite.raft.jraft.conf.ConfigurationManager)

Example 17 with RaftOptions

use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.

the class LocalSnapshotReaderTest method setup.

@BeforeEach
public void setup() throws Exception {
    RaftOptions opts = new RaftOptions();
    String snapPath = this.path + File.separator + Snapshot.JRAFT_SNAPSHOT_PREFIX + snapshotIndex;
    new File(snapPath).mkdirs();
    this.table = new LocalSnapshotMetaTable(opts);
    this.table.addFile("testFile", opts.getRaftMessagesFactory().localFileMeta().checksum("test").build());
    table.saveToFile(snapPath + File.separator + Snapshot.JRAFT_SNAPSHOT_META_FILE);
    this.reader = new LocalSnapshotReader(snapshotStorage, null, new Endpoint("localhost", 8081), opts, snapPath);
    assertTrue(this.reader.init(null));
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) Endpoint(org.apache.ignite.raft.jraft.util.Endpoint) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 18 with RaftOptions

use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.

the class LocalSnapshotWriterTest method testSyncInit.

@Test
public void testSyncInit() throws Exception {
    LocalFileMetaOutter.LocalFileMeta meta = opts.getRaftMessagesFactory().localFileMeta().checksum("test").source(LocalFileMetaOutter.FileSource.FILE_SOURCE_LOCAL).build();
    assertTrue(this.writer.addFile("data1", meta));
    assertTrue(this.writer.addFile("data2"));
    assertEquals(meta, this.writer.getFileMeta("data1"));
    assertNull(((LocalFileMetaOutter.LocalFileMeta) this.writer.getFileMeta("data2")).checksum());
    assertFalse(((LocalFileMetaOutter.LocalFileMeta) this.writer.getFileMeta("data2")).hasUserMeta());
    this.writer.sync();
    // create a new writer
    LocalSnapshotWriter newWriter = new LocalSnapshotWriter(path.toString(), snapshotStorage, new RaftOptions());
    assertTrue(newWriter.init(null));
    assertNotSame(writer, newWriter);
    assertEquals(meta, newWriter.getFileMeta("data1"));
    assertNull(((LocalFileMetaOutter.LocalFileMeta) newWriter.getFileMeta("data2")).checksum());
    assertFalse(((LocalFileMetaOutter.LocalFileMeta) newWriter.getFileMeta("data2")).hasUserMeta());
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) LocalFileMetaOutter(org.apache.ignite.raft.jraft.entity.LocalFileMetaOutter) BaseStorageTest(org.apache.ignite.raft.jraft.storage.BaseStorageTest) Test(org.junit.jupiter.api.Test)

Example 19 with RaftOptions

use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.

the class SnapshotFileReaderTest method setup.

@BeforeEach
public void setup() throws Exception {
    this.reader = new SnapshotFileReader(path.toString(), null);
    opts = new RaftOptions();
    metaTable = new LocalSnapshotMetaTable(opts);
    this.reader.setMetaTable(metaTable);
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 20 with RaftOptions

use of org.apache.ignite.raft.jraft.option.RaftOptions in project ignite-3 by apache.

the class SnapshotFileReaderTest method testReadMetaFile.

@Test
public void testReadMetaFile() throws Exception {
    final ByteBufferCollector bufRef = ByteBufferCollector.allocate(1024);
    final LocalFileMetaOutter.LocalFileMeta meta = addDataMeta();
    assertEquals(-1, this.reader.readFile(bufRef, Snapshot.JRAFT_SNAPSHOT_META_FILE, 0, Integer.MAX_VALUE));
    final ByteBuffer buf = bufRef.getBuffer();
    buf.flip();
    final LocalSnapshotMetaTable newTable = new LocalSnapshotMetaTable(new RaftOptions());
    newTable.loadFromIoBufferAsRemote(buf);
    assertEquals(meta, newTable.getFileMeta("data"));
}
Also used : RaftOptions(org.apache.ignite.raft.jraft.option.RaftOptions) LocalFileMetaOutter(org.apache.ignite.raft.jraft.entity.LocalFileMetaOutter) ByteBufferCollector(org.apache.ignite.raft.jraft.util.ByteBufferCollector) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test) BaseStorageTest(org.apache.ignite.raft.jraft.storage.BaseStorageTest)

Aggregations

RaftOptions (org.apache.ignite.raft.jraft.option.RaftOptions)23 BeforeEach (org.junit.jupiter.api.BeforeEach)12 Test (org.junit.jupiter.api.Test)11 NodeOptions (org.apache.ignite.raft.jraft.option.NodeOptions)8 Endpoint (org.apache.ignite.raft.jraft.util.Endpoint)8 PeerId (org.apache.ignite.raft.jraft.entity.PeerId)6 LocalFileMetaOutter (org.apache.ignite.raft.jraft.entity.LocalFileMetaOutter)4 File (java.io.File)3 ByteBuffer (java.nio.ByteBuffer)3 TimerManager (org.apache.ignite.raft.jraft.core.TimerManager)3 CopyOptions (org.apache.ignite.raft.jraft.option.CopyOptions)3 SnapshotCopierOptions (org.apache.ignite.raft.jraft.option.SnapshotCopierOptions)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutorService (java.util.concurrent.ExecutorService)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Node (org.apache.ignite.raft.jraft.Node)2 ConfigurationManager (org.apache.ignite.raft.jraft.conf.ConfigurationManager)2 RpcClientEx (org.apache.ignite.raft.jraft.rpc.RpcClientEx)2