Search in sources :

Example 1 with RegionEngineOptions

use of io.dingodb.store.row.options.RegionEngineOptions in project dingo by dingodb.

the class FakePlacementDriverClient method getStoreMetadata.

@Override
public Store getStoreMetadata(final StoreEngineOptions opts) {
    final Store store = new Store();
    final List<RegionEngineOptions> rOptsList = opts.getRegionEngineOptionsList();
    final List<Region> regionList = Lists.newArrayListWithCapacity(rOptsList.size());
    store.setId("-1");
    store.setEndpoint(opts.getServerAddress());
    for (final RegionEngineOptions rOpts : rOptsList) {
        regionList.add(getLocalRegionMetadata(rOpts));
    }
    store.setRegions(regionList);
    return store;
}
Also used : Store(io.dingodb.store.row.metadata.Store) Region(io.dingodb.store.row.metadata.Region) RegionEngineOptions(io.dingodb.store.row.options.RegionEngineOptions)

Example 2 with RegionEngineOptions

use of io.dingodb.store.row.options.RegionEngineOptions in project dingo by dingodb.

the class MultiRegionEngineOptionsConfigured method getOrCreateOptsById.

private RegionEngineOptions getOrCreateOptsById(final String regionId) {
    Requires.requireNonNull(regionId, "regionId");
    RegionEngineOptions opts = this.optsTable.get(regionId);
    if (opts != null) {
        return opts;
    }
    opts = new RegionEngineOptions();
    opts.setRegionId(regionId);
    this.optsTable.put(regionId, opts);
    return opts;
}
Also used : RegionEngineOptions(io.dingodb.store.row.options.RegionEngineOptions)

Example 3 with RegionEngineOptions

use of io.dingodb.store.row.options.RegionEngineOptions in project dingo by dingodb.

the class RemotePlacementDriverClient method getStoreMetadata.

@Override
public Store getStoreMetadata(final StoreEngineOptions opts) {
    final Endpoint selfEndpoint = opts.getServerAddress();
    /**
     * for debugger.
     */
    for (RegionEngineOptions opt : opts.getRegionEngineOptionsList()) {
        LOG.info("RegionEngineOptions-before: update from local conf. opt:{}", opt.toString());
    }
    // remote conf is the preferred
    final Store remoteStore = this.metadataRpcClient.getStoreInfo(this.clusterId, selfEndpoint);
    if (!remoteStore.isEmpty()) {
        final List<Region> regions = remoteStore.getRegions();
        Long metricsReportPeriodMs = opts.getMetricsReportPeriod();
        if (opts.getRegionEngineOptionsList() != null && opts.getRegionEngineOptionsList().size() > 0) {
            metricsReportPeriodMs = opts.getRegionEngineOptionsList().get(0).getMetricsReportPeriod();
        }
        opts.getRegionEngineOptionsList().clear();
        for (final Region region : regions) {
            super.regionRouteTable.addOrUpdateRegion(region);
            RegionEngineOptions engineOptions = new RegionEngineOptions();
            engineOptions.setRegionId(region.getId());
            engineOptions.setStartKey(BytesUtil.readUtf8(region.getStartKey()));
            engineOptions.setStartKeyBytes(region.getStartKey());
            engineOptions.setEndKey(BytesUtil.readUtf8(region.getEndKey()));
            engineOptions.setEndKeyBytes(region.getEndKey());
            engineOptions.setNodeOptions(new NodeOptions());
            engineOptions.setRaftGroupId(JRaftHelper.getJRaftGroupId(this.clusterName, region.getId()));
            String raftDataPath = JRaftHelper.getRaftDataPath(opts.getRaftStoreOptions().getDataPath(), region.getId(), opts.getServerAddress().getPort());
            engineOptions.setRaftDataPath(raftDataPath);
            engineOptions.setServerAddress(opts.getServerAddress());
            String initServerList = region.getPeers().stream().map(x -> x.getEndpoint().toString()).collect(Collectors.joining(","));
            engineOptions.setInitialServerList(initServerList);
            engineOptions.setMetricsReportPeriod(metricsReportPeriodMs);
            opts.getRegionEngineOptionsList().add(engineOptions);
        }
        /**
         * for debugger.
         */
        for (RegionEngineOptions opt : opts.getRegionEngineOptionsList()) {
            LOG.info("RegionEngineOptions-After: update from remote PD. opt:{}", opt.toString());
        }
        return remoteStore;
    }
    // local conf
    final Store localStore = new Store();
    final List<RegionEngineOptions> rOptsList = opts.getRegionEngineOptionsList();
    final List<Region> regionList = Lists.newArrayListWithCapacity(rOptsList.size());
    localStore.setId(remoteStore.getId());
    localStore.setEndpoint(selfEndpoint);
    for (final RegionEngineOptions rOpts : rOptsList) {
        regionList.add(getLocalRegionMetadata(rOpts));
    }
    localStore.setRegions(regionList);
    refreshStore(localStore);
    return localStore;
}
Also used : Logger(org.slf4j.Logger) Store(io.dingodb.store.row.metadata.Store) RegionEngineOptions(io.dingodb.store.row.options.RegionEngineOptions) StoreEngineOptions(io.dingodb.store.row.options.StoreEngineOptions) LoggerFactory(org.slf4j.LoggerFactory) Region(io.dingodb.store.row.metadata.Region) RouteTable(io.dingodb.raft.RouteTable) NodeOptions(io.dingodb.raft.option.NodeOptions) Lists(io.dingodb.store.row.util.Lists) Collectors(java.util.stream.Collectors) Cluster(io.dingodb.store.row.metadata.Cluster) Strings(io.dingodb.store.row.util.Strings) PlacementDriverOptions(io.dingodb.store.row.options.PlacementDriverOptions) List(java.util.List) PeerId(io.dingodb.raft.entity.PeerId) RouteTableException(io.dingodb.store.row.errors.RouteTableException) BytesUtil(io.dingodb.raft.util.BytesUtil) Endpoint(io.dingodb.raft.util.Endpoint) JRaftHelper(io.dingodb.store.row.JRaftHelper) Endpoint(io.dingodb.raft.util.Endpoint) Store(io.dingodb.store.row.metadata.Store) Region(io.dingodb.store.row.metadata.Region) NodeOptions(io.dingodb.raft.option.NodeOptions) RegionEngineOptions(io.dingodb.store.row.options.RegionEngineOptions)

Aggregations

RegionEngineOptions (io.dingodb.store.row.options.RegionEngineOptions)3 Region (io.dingodb.store.row.metadata.Region)2 Store (io.dingodb.store.row.metadata.Store)2 RouteTable (io.dingodb.raft.RouteTable)1 PeerId (io.dingodb.raft.entity.PeerId)1 NodeOptions (io.dingodb.raft.option.NodeOptions)1 BytesUtil (io.dingodb.raft.util.BytesUtil)1 Endpoint (io.dingodb.raft.util.Endpoint)1 JRaftHelper (io.dingodb.store.row.JRaftHelper)1 RouteTableException (io.dingodb.store.row.errors.RouteTableException)1 Cluster (io.dingodb.store.row.metadata.Cluster)1 PlacementDriverOptions (io.dingodb.store.row.options.PlacementDriverOptions)1 StoreEngineOptions (io.dingodb.store.row.options.StoreEngineOptions)1 Lists (io.dingodb.store.row.util.Lists)1 Strings (io.dingodb.store.row.util.Strings)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1