Search in sources :

Example 11 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method mapping.

public Store mapping(ExecutorView executorView) {
    if (executorView == null) {
        return null;
    }
    Store store = new Store();
    store.setEndpoint(new Endpoint(executorView.location().getHost(), executorView.location().getPort()));
    store.setId(executorView.resourceId().toString());
    store.setLabels(executorView.labels().entrySet().stream().map(e -> new StoreLabel(e.getKey(), e.getValue())).collect(Collectors.toList()));
    store.setRegions(executorView.apps().stream().map(id -> scheduleMetaAdaptor.namespace().<RegionApp>getApp(id)).map(this::mapping).collect(Collectors.toList()));
    return store;
}
Also used : ExecutorView(io.dingodb.server.coordinator.resource.impl.ExecutorView) StoreStats(io.dingodb.store.row.metadata.StoreStats) GeneralId(io.dingodb.server.coordinator.GeneralId) RegionView(io.dingodb.server.coordinator.app.impl.RegionView) StoreLabel(io.dingodb.store.row.metadata.StoreLabel) BigDecimal(java.math.BigDecimal) RowStoreMetaAdaptor(io.dingodb.server.coordinator.meta.RowStoreMetaAdaptor) Map(java.util.Map) Optional(io.dingodb.common.util.Optional) RegionEpoch(io.dingodb.store.row.metadata.RegionEpoch) Store(io.dingodb.store.row.metadata.Store) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Region(io.dingodb.store.row.metadata.Region) Set(java.util.Set) GeneralIdHelper(io.dingodb.server.coordinator.meta.GeneralIdHelper) Peer(io.dingodb.store.row.metadata.Peer) Collectors(java.util.stream.Collectors) Cluster(io.dingodb.store.row.metadata.Cluster) ScheduleMetaAdaptor(io.dingodb.server.coordinator.meta.ScheduleMetaAdaptor) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ConcurrentHashSet(com.alipay.remoting.util.ConcurrentHashSet) RegionStats(io.dingodb.store.row.metadata.RegionStats) RegionApp(io.dingodb.server.coordinator.app.impl.RegionApp) Endpoint(io.dingodb.raft.util.Endpoint) StoreLabel(io.dingodb.store.row.metadata.StoreLabel) Endpoint(io.dingodb.raft.util.Endpoint) Store(io.dingodb.store.row.metadata.Store) RegionApp(io.dingodb.server.coordinator.app.impl.RegionApp)

Example 12 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

the class BoltRaftRpcFactory method createRpcServer.

@Override
public RpcServer createRpcServer(final Endpoint endpoint, final ConfigHelper<RpcServer> helper) {
    final int port = Requires.requireNonNull(endpoint, "endpoint").getPort();
    Requires.requireTrue(port > 0 && port < 0xFFFF, "port out of range:" + port);
    final com.alipay.remoting.rpc.RpcServer boltImpl = new com.alipay.remoting.rpc.RpcServer(port, true, false);
    final RpcServer rpcServer = new BoltRpcServer(boltImpl);
    if (helper != null) {
        helper.config(rpcServer);
    }
    return rpcServer;
}
Also used : RpcServer(io.dingodb.raft.rpc.RpcServer) Endpoint(io.dingodb.raft.util.Endpoint)

Example 13 with Endpoint

use of io.dingodb.raft.util.Endpoint in project dingo by dingodb.

the class RemoteFileCopier method init.

public boolean init(String uri, final SnapshotThrottle snapshotThrottle, final SnapshotCopierOptions opts) {
    this.rpcService = opts.getRaftClientService();
    this.timerManager = opts.getTimerManager();
    this.raftOptions = opts.getRaftOptions();
    this.snapshotThrottle = snapshotThrottle;
    final int prefixSize = Snapshot.REMOTE_SNAPSHOT_URI_SCHEME.length();
    if (uri == null || !uri.startsWith(Snapshot.REMOTE_SNAPSHOT_URI_SCHEME)) {
        LOG.error("Invalid uri {}.", uri);
        return false;
    }
    uri = uri.substring(prefixSize);
    final int slasPos = uri.indexOf('/');
    final String ipAndPort = uri.substring(0, slasPos);
    uri = uri.substring(slasPos + 1);
    try {
        this.readId = Long.parseLong(uri);
        final String[] ipAndPortStrs = ipAndPort.split(":");
        this.endpoint = new Endpoint(ipAndPortStrs[0], Integer.parseInt(ipAndPortStrs[1]));
    } catch (final Exception e) {
        LOG.error("Fail to parse readerId or endpoint.", e);
        return false;
    }
    if (!this.rpcService.connect(this.endpoint)) {
        LOG.error("Fail to init channel to {}.", this.endpoint);
        return false;
    }
    return true;
}
Also used : Endpoint(io.dingodb.raft.util.Endpoint) Endpoint(io.dingodb.raft.util.Endpoint) IOException(java.io.IOException)

Example 14 with Endpoint

use of io.dingodb.raft.util.Endpoint 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 15 with Endpoint

use of io.dingodb.raft.util.Endpoint 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

Endpoint (io.dingodb.raft.util.Endpoint)25 Store (io.dingodb.store.row.metadata.Store)6 PeerId (io.dingodb.raft.entity.PeerId)5 Cluster (io.dingodb.store.row.metadata.Cluster)5 NodeOptions (io.dingodb.raft.option.NodeOptions)4 Status (io.dingodb.raft.Status)3 FutureHelper (io.dingodb.store.row.client.FutureHelper)3 FailoverClosure (io.dingodb.store.row.client.failover.FailoverClosure)3 RetryRunner (io.dingodb.store.row.client.failover.RetryRunner)3 FailoverClosureImpl (io.dingodb.store.row.client.failover.impl.FailoverClosureImpl)3 CreateRegionIdRequest (io.dingodb.store.row.cmd.pd.CreateRegionIdRequest)3 GetClusterInfoRequest (io.dingodb.store.row.cmd.pd.GetClusterInfoRequest)3 GetStoreIdRequest (io.dingodb.store.row.cmd.pd.GetStoreIdRequest)3 GetStoreInfoRequest (io.dingodb.store.row.cmd.pd.GetStoreInfoRequest)3 SetStoreInfoRequest (io.dingodb.store.row.cmd.pd.SetStoreInfoRequest)3 Region (io.dingodb.store.row.metadata.Region)3 StoreStats (io.dingodb.store.row.metadata.StoreStats)3 RouteTable (io.dingodb.raft.RouteTable)2 Configuration (io.dingodb.raft.conf.Configuration)2 RpcServer (io.dingodb.raft.rpc.RpcServer)2