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();
}
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));
}
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());
}
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);
}
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"));
}
Aggregations