Search in sources :

Example 1 with RocksDBOptions

use of com.alipay.sofa.jraft.rhea.options.RocksDBOptions in project sofa-jraft by sofastack.

the class BaseKVStoreTest method setup.

protected void setup() throws Exception {
    File file = getTempDir();
    this.tempPath = file.getAbsolutePath();
    this.kvStore = new RocksRawKVStore();
    this.dbOptions = new RocksDBOptions();
    this.dbOptions.setStatisticsCallbackIntervalSeconds(10);
    this.dbOptions.setDbPath(this.tempPath);
    this.kvStore.init(this.dbOptions);
}
Also used : RocksRawKVStore(com.alipay.sofa.jraft.rhea.storage.RocksRawKVStore) File(java.io.File) RocksDBOptions(com.alipay.sofa.jraft.rhea.options.RocksDBOptions)

Example 2 with RocksDBOptions

use of com.alipay.sofa.jraft.rhea.options.RocksDBOptions in project sofa-jraft by sofastack.

the class BaseRawStoreBenchmark method setup.

protected void setup() throws Exception {
    File file = getTempDir();
    this.tempPath = file.getAbsolutePath();
    System.out.println(this.tempPath);
    this.kvStore = new RocksRawKVStore();
    this.dbOptions = new RocksDBOptions();
    this.dbOptions.setDbPath(this.tempPath);
    this.dbOptions.setSync(false);
    this.kvStore.init(this.dbOptions);
}
Also used : RocksRawKVStore(com.alipay.sofa.jraft.rhea.storage.RocksRawKVStore) File(java.io.File) RocksDBOptions(com.alipay.sofa.jraft.rhea.options.RocksDBOptions)

Example 3 with RocksDBOptions

use of com.alipay.sofa.jraft.rhea.options.RocksDBOptions in project sofa-jraft by sofastack.

the class StoreEngine method initRocksDB.

private boolean initRocksDB(final StoreEngineOptions opts) {
    RocksDBOptions rocksOpts = opts.getRocksDBOptions();
    if (rocksOpts == null) {
        rocksOpts = new RocksDBOptions();
        opts.setRocksDBOptions(rocksOpts);
    }
    String dbPath = rocksOpts.getDbPath();
    if (Strings.isNotBlank(dbPath)) {
        try {
            FileUtils.forceMkdir(new File(dbPath));
        } catch (final Throwable t) {
            LOG.error("Fail to make dir for dbPath {}.", dbPath);
            return false;
        }
    } else {
        dbPath = "";
    }
    final String childPath = "db_" + this.storeId + "_" + opts.getServerAddress().getPort();
    rocksOpts.setDbPath(Paths.get(dbPath, childPath).toString());
    this.dbPath = new File(rocksOpts.getDbPath());
    final RocksRawKVStore rocksRawKVStore = new RocksRawKVStore();
    if (!rocksRawKVStore.init(rocksOpts)) {
        LOG.error("Fail to init [RocksRawKVStore].");
        return false;
    }
    this.rawKVStore = rocksRawKVStore;
    return true;
}
Also used : RocksRawKVStore(com.alipay.sofa.jraft.rhea.storage.RocksRawKVStore) File(java.io.File) RocksDBOptions(com.alipay.sofa.jraft.rhea.options.RocksDBOptions)

Aggregations

RocksDBOptions (com.alipay.sofa.jraft.rhea.options.RocksDBOptions)3 RocksRawKVStore (com.alipay.sofa.jraft.rhea.storage.RocksRawKVStore)3 File (java.io.File)3