Search in sources :

Example 1 with RocksRawKVStore

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;
}
Also used : RocksRawKVStore(io.dingodb.store.row.storage.RocksRawKVStore) File(java.io.File)

Example 2 with 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();
}
Also used : RowStoreMetaAdaptor(io.dingodb.server.coordinator.meta.RowStoreMetaAdaptor) CoordinatorStateMachine(io.dingodb.server.coordinator.state.CoordinatorStateMachine) Node(io.dingodb.raft.Node) RocksRawKVStore(io.dingodb.store.row.storage.RocksRawKVStore) ScheduleMetaAdaptor(io.dingodb.server.coordinator.meta.ScheduleMetaAdaptor) NodeOptions(io.dingodb.raft.option.NodeOptions) CoordinatorContext(io.dingodb.server.coordinator.context.CoordinatorContext) AsyncKeyValueStore(io.dingodb.server.coordinator.store.AsyncKeyValueStore) RaftAsyncKeyValueStore(io.dingodb.server.coordinator.store.RaftAsyncKeyValueStore) TableMetaAdaptor(io.dingodb.server.coordinator.meta.TableMetaAdaptor) Endpoint(io.dingodb.raft.util.Endpoint) CoordinatorMetaService(io.dingodb.server.coordinator.meta.service.CoordinatorMetaService) PeerId(io.dingodb.raft.entity.PeerId)

Example 3 with RocksRawKVStore

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;
}
Also used : RocksRawKVStore(io.dingodb.store.row.storage.RocksRawKVStore) File(java.io.File)

Aggregations

RocksRawKVStore (io.dingodb.store.row.storage.RocksRawKVStore)3 File (java.io.File)2 Node (io.dingodb.raft.Node)1 PeerId (io.dingodb.raft.entity.PeerId)1 NodeOptions (io.dingodb.raft.option.NodeOptions)1 Endpoint (io.dingodb.raft.util.Endpoint)1 CoordinatorContext (io.dingodb.server.coordinator.context.CoordinatorContext)1 RowStoreMetaAdaptor (io.dingodb.server.coordinator.meta.RowStoreMetaAdaptor)1 ScheduleMetaAdaptor (io.dingodb.server.coordinator.meta.ScheduleMetaAdaptor)1 TableMetaAdaptor (io.dingodb.server.coordinator.meta.TableMetaAdaptor)1 CoordinatorMetaService (io.dingodb.server.coordinator.meta.service.CoordinatorMetaService)1 CoordinatorStateMachine (io.dingodb.server.coordinator.state.CoordinatorStateMachine)1 AsyncKeyValueStore (io.dingodb.server.coordinator.store.AsyncKeyValueStore)1 RaftAsyncKeyValueStore (io.dingodb.server.coordinator.store.RaftAsyncKeyValueStore)1