Search in sources :

Example 6 with Store

use of io.dingodb.store.row.metadata.Store in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method cluster.

@Override
public Cluster cluster() {
    List<Store> stores = scheduleMetaAdaptor.namespaceView().resourceViews().values().stream().filter(ExecutorView.class::isInstance).map(ExecutorView.class::cast).map(this::mapping).collect(Collectors.toList());
    Cluster cluster = new Cluster(0, stores);
    log.debug("Get cluster, cluster: {}", cluster);
    return cluster;
}
Also used : ExecutorView(io.dingodb.server.coordinator.resource.impl.ExecutorView) Store(io.dingodb.store.row.metadata.Store) Cluster(io.dingodb.store.row.metadata.Cluster)

Example 7 with Store

use of io.dingodb.store.row.metadata.Store in project dingo by dingodb.

the class MetadataRpcClient method internalGetStoreInfo.

private void internalGetStoreInfo(final long clusterId, final Endpoint selfEndpoint, final CompletableFuture<Store> future, final int retriesLeft, final Errors lastCause) {
    final RetryRunner retryRunner = retryCause -> internalGetStoreInfo(clusterId, selfEndpoint, future, retriesLeft - 1, retryCause);
    final FailoverClosure<Store> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
    final GetStoreInfoRequest request = new GetStoreInfoRequest();
    request.setClusterId(clusterId);
    request.setEndpoint(selfEndpoint);
    this.pdRpcService.callPdServerWithRpc(request, closure, lastCause);
}
Also used : CreateRegionIdRequest(io.dingodb.store.row.cmd.pd.CreateRegionIdRequest) GetClusterInfoRequest(io.dingodb.store.row.cmd.pd.GetClusterInfoRequest) Errors(io.dingodb.store.row.errors.Errors) FailoverClosure(io.dingodb.store.row.client.failover.FailoverClosure) Store(io.dingodb.store.row.metadata.Store) CompletableFuture(java.util.concurrent.CompletableFuture) Cluster(io.dingodb.store.row.metadata.Cluster) SetStoreInfoRequest(io.dingodb.store.row.cmd.pd.SetStoreInfoRequest) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) GetStoreInfoRequest(io.dingodb.store.row.cmd.pd.GetStoreInfoRequest) GetStoreIdRequest(io.dingodb.store.row.cmd.pd.GetStoreIdRequest) Endpoint(io.dingodb.raft.util.Endpoint) FutureHelper(io.dingodb.store.row.client.FutureHelper) FailoverClosureImpl(io.dingodb.store.row.client.failover.impl.FailoverClosureImpl) Store(io.dingodb.store.row.metadata.Store) GetStoreInfoRequest(io.dingodb.store.row.cmd.pd.GetStoreInfoRequest) RetryRunner(io.dingodb.store.row.client.failover.RetryRunner)

Example 8 with Store

use of io.dingodb.store.row.metadata.Store 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

Store (io.dingodb.store.row.metadata.Store)8 Cluster (io.dingodb.store.row.metadata.Cluster)6 Endpoint (io.dingodb.raft.util.Endpoint)5 Region (io.dingodb.store.row.metadata.Region)4 NodeOptions (io.dingodb.raft.option.NodeOptions)2 ExecutorView (io.dingodb.server.coordinator.resource.impl.ExecutorView)2 FutureHelper (io.dingodb.store.row.client.FutureHelper)2 FailoverClosure (io.dingodb.store.row.client.failover.FailoverClosure)2 RetryRunner (io.dingodb.store.row.client.failover.RetryRunner)2 FailoverClosureImpl (io.dingodb.store.row.client.failover.impl.FailoverClosureImpl)2 CreateRegionIdRequest (io.dingodb.store.row.cmd.pd.CreateRegionIdRequest)2 GetClusterInfoRequest (io.dingodb.store.row.cmd.pd.GetClusterInfoRequest)2 GetStoreIdRequest (io.dingodb.store.row.cmd.pd.GetStoreIdRequest)2 GetStoreInfoRequest (io.dingodb.store.row.cmd.pd.GetStoreInfoRequest)2 SetStoreInfoRequest (io.dingodb.store.row.cmd.pd.SetStoreInfoRequest)2 Errors (io.dingodb.store.row.errors.Errors)2 RegionEngineOptions (io.dingodb.store.row.options.RegionEngineOptions)2 List (java.util.List)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ConcurrentHashSet (com.alipay.remoting.util.ConcurrentHashSet)1