use of org.apache.ignite.raft.jraft.option.LogStorageOptions in project ignite-3 by apache.
the class LogManagerImpl method init.
@Override
public boolean init(final LogManagerOptions opts) {
this.writeLock.lock();
try {
if (opts.getLogStorage() == null) {
LOG.error("Fail to init log manager, log storage is null");
return false;
}
this.raftOptions = opts.getRaftOptions();
this.nodeMetrics = opts.getNodeMetrics();
this.logStorage = opts.getLogStorage();
this.configManager = opts.getConfigurationManager();
this.nodeOptions = opts.getNode().getOptions();
this.groupId = opts.getGroupId();
LogStorageOptions lsOpts = new LogStorageOptions();
lsOpts.setConfigurationManager(this.configManager);
lsOpts.setLogEntryCodecFactory(opts.getLogEntryCodecFactory());
if (!this.logStorage.init(lsOpts)) {
LOG.error("Fail to init logStorage");
return false;
}
this.firstLogIndex = this.logStorage.getFirstLogIndex();
this.lastLogIndex = this.logStorage.getLastLogIndex();
this.diskId = new LogId(this.lastLogIndex, getTermFromLogStorage(this.lastLogIndex));
this.fsmCaller = opts.getFsmCaller();
this.disruptor = opts.getLogManagerDisruptor();
this.diskQueue = disruptor.subscribe(groupId, new StableClosureEventHandler(), (event, ex) -> reportError(-1, "LogManager handle event error"));
if (this.nodeMetrics.getMetricRegistry() != null) {
this.nodeMetrics.getMetricRegistry().register("jraft-log-manager-disruptor", new DisruptorMetricSet(this.diskQueue));
}
} finally {
this.writeLock.unlock();
}
return true;
}
use of org.apache.ignite.raft.jraft.option.LogStorageOptions in project ignite-3 by apache.
the class BaseLogStorageTest method setup.
@BeforeEach
public void setup() throws Exception {
this.confManager = new ConfigurationManager();
this.logEntryCodecFactory = LogEntryV1CodecFactory.getInstance();
this.logStorage = newLogStorage();
final LogStorageOptions opts = newLogStorageOptions();
this.logStorage.init(opts);
}
use of org.apache.ignite.raft.jraft.option.LogStorageOptions in project ignite-3 by apache.
the class BaseLogStorageTest method newLogStorageOptions.
protected LogStorageOptions newLogStorageOptions() {
final LogStorageOptions opts = new LogStorageOptions();
opts.setConfigurationManager(this.confManager);
opts.setLogEntryCodecFactory(this.logEntryCodecFactory);
return opts;
}
use of org.apache.ignite.raft.jraft.option.LogStorageOptions 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();
}
Aggregations