use of io.dingodb.store.row.storage.RocksRawKVStore in project dingo by dingodb.
the class CoordinatorServer method createRocksDB.
private RocksRawKVStore createRocksDB() {
final String dbPath = svrOpts.getOptions().getStoreDBOptions().getDataPath();
final String dataPath = Paths.get(dbPath, COORDINATOR, "db").toString();
svrOpts.getOptions().getStoreDBOptions().setDataPath(dbPath);
try {
FileUtils.forceMkdir(new File(dataPath));
log.info("data path created: {}", dataPath);
} catch (final Throwable t) {
throw new RuntimeException("Fail to make dir for dbPath: " + dataPath);
}
RocksRawKVStore rocksRawKVStore = new RocksRawKVStore();
if (!rocksRawKVStore.init(svrOpts.getOptions().getStoreDBOptions())) {
throw new RuntimeException("Fail to init RocksRawKVStore.");
}
return rocksRawKVStore;
}
use of io.dingodb.store.row.storage.RocksRawKVStore in project dingo by dingodb.
the class CoordinatorServer method start.
public void start(final CoordinatorOptions opts) throws Exception {
this.svrOpts = opts;
log.info("Coordinator all configuration: {}.", this.svrOpts);
log.info("instance configuration: {}.", DingoOptions.instance());
this.context = new CoordinatorContext();
final String raftId = svrOpts.getRaft().getGroup();
final Endpoint endpoint = new Endpoint(svrOpts.getIp(), svrOpts.getRaft().getPort());
final RocksRawKVStore rawKVStore = createRocksDB();
final CoordinatorStateMachine stateMachine = createStateMachine(raftId, rawKVStore, context);
final Node node = RaftServiceFactory.createRaftNode(raftId, new PeerId(endpoint, 0));
final AsyncKeyValueStore keyValueStore = createStore(rawKVStore, node);
final ScheduleMetaAdaptor scheduleMetaAdaptor = createScheduleMetaAdaptor(keyValueStore);
final TableMetaAdaptor tableMetaAdaptor = createTableMetaAdaptor(keyValueStore, scheduleMetaAdaptor);
final CoordinatorMetaService metaService = createMetaService();
final RowStoreMetaAdaptor rowStoreMetaAdaptor = createRowStoreMetaAdaptor(scheduleMetaAdaptor);
context.coordOpts(svrOpts).endpoint(endpoint).netService(createNetService()).rocksKVStore(rawKVStore).stateMachine(stateMachine).keyValueStore(keyValueStore).node(node).scheduleMetaAdaptor(scheduleMetaAdaptor).serviceProvider(createServiceProvider()).tableMetaAdaptor(tableMetaAdaptor).rowStoreMetaAdaptor(rowStoreMetaAdaptor).metaService(metaService);
NodeManager.getInstance().addAddress(endpoint);
stateMachine.init();
final NodeOptions nodeOptions = initNodeOptions(stateMachine);
node.init(nodeOptions);
keyValueStore.init();
}
use of io.dingodb.store.row.storage.RocksRawKVStore in project dingo by dingodb.
the class StoreEngine method initRocksDB.
private boolean initRocksDB(final StoreEngineOptions opts) {
StoreDBOptions rocksOpts = opts.getStoreDBOptions();
if (rocksOpts == null) {
rocksOpts = new StoreDBOptions();
opts.setStoreDBOptions(rocksOpts);
}
String dbPath = rocksOpts.getDataPath();
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 dbDataPath = JRaftHelper.getDBDataPath(dbPath, this.storeId, opts.getServerAddress().getPort());
rocksOpts.setDataPath(dbDataPath);
this.dbPath = new File(rocksOpts.getDataPath());
final RocksRawKVStore rocksRawKVStore = new RocksRawKVStore();
if (!rocksRawKVStore.init(rocksOpts)) {
LOG.error("Fail to init [RocksRawKVStore].");
return false;
}
this.rawKVStore = rocksRawKVStore;
return true;
}
Aggregations