Search in sources :

Example 1 with RegionView

use of io.dingodb.server.coordinator.app.impl.RegionView in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method saveRegionHeartbeat.

@Override
public void saveRegionHeartbeat(Region region, RegionStats regionStats) {
    final GeneralId regionId = GeneralIdHelper.region(region.getId());
    RegionApp regionApp = mapping(region);
    RegionView regionView = mapping(regionApp, regionStats);
    GeneralId storeId = GeneralId.fromStr(regionStats.getLeader().getStoreId());
    Set<GeneralId> nodes = region.getPeers().stream().map(Peer::getEndpoint).map(scheduleMetaAdaptor::storeId).collect(Collectors.toSet());
    regionView.nodes(nodes);
    regionView.leader(storeId);
    regionView.followers(nodes);
    scheduleMetaAdaptor.updateRegionView(regionApp, regionView);
    updateLeader(regionId, storeId);
    regionMap.put(regionId, region);
    regionStatsMap.put(GeneralId.appViewOf(regionId.seqNo(), regionId.name()), regionStats);
}
Also used : RegionView(io.dingodb.server.coordinator.app.impl.RegionView) Peer(io.dingodb.store.row.metadata.Peer) RegionApp(io.dingodb.server.coordinator.app.impl.RegionApp) GeneralId(io.dingodb.server.coordinator.GeneralId)

Example 2 with RegionView

use of io.dingodb.server.coordinator.app.impl.RegionView in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method mapping.

public Region mapping(RegionApp regionApp) {
    if (regionApp == null) {
        return null;
    }
    String regionId = regionApp.regionId();
    RegionView regionView = scheduleMetaAdaptor.regionView(regionApp.view());
    List<Peer> peerIds = regionView.nodeResources().stream().map(id -> new Peer(regionId, id.toString(), GeneralIdHelper.storeEndpoint(id))).collect(Collectors.toList());
    return new Region(regionId, regionApp.startKey(), regionApp.endKey(), new RegionEpoch(regionApp.version(), regionView.confVer()), peerIds);
}
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) RegionView(io.dingodb.server.coordinator.app.impl.RegionView) Peer(io.dingodb.store.row.metadata.Peer) Region(io.dingodb.store.row.metadata.Region) RegionEpoch(io.dingodb.store.row.metadata.RegionEpoch)

Example 3 with RegionView

use of io.dingodb.server.coordinator.app.impl.RegionView in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method mapping.

public RegionView mapping(RegionApp app, RegionStats stats) {
    if (app == null || stats == null) {
        return null;
    }
    RegionView view = new RegionView(GeneralIdHelper.regionView(app.appId().seqNo()), app.appId(), stats);
    app.view(view.viewId());
    return view;
}
Also used : RegionView(io.dingodb.server.coordinator.app.impl.RegionView)

Example 4 with RegionView

use of io.dingodb.server.coordinator.app.impl.RegionView in project dingo by dingodb.

the class TableMetaAdaptorImpl method rangeLocationGroup.

@Override
public NavigableMap<byte[], LocationGroup> rangeLocationGroup() {
    NavigableMap<byte[], LocationGroup> result = new TreeMap<>(BytesUtil.getDefaultByteArrayComparator());
    Map<GeneralId, AppView<?, ?>> map = this.scheduleMetaAdaptor.namespaceView().appViews();
    for (Map.Entry<GeneralId, AppView<?, ?>> entry : map.entrySet()) {
        if (entry.getValue() instanceof RegionView) {
            RegionView view = (RegionView) entry.getValue();
            ExecutorView executorView = this.scheduleMetaAdaptor.executorView(view.leader());
            Endpoint endpoint = executorView.stats().getLocation();
            Location location = new Location(endpoint.getIp(), endpoint.getPort(), DATA_DIR);
            List<Location> locationList = view.nodeResources().stream().map(id -> this.scheduleMetaAdaptor.namespaceView().<ExecutorView>getResourceView(id)).map(ExecutorView::location).collect(Collectors.toList());
            LocationGroup locationGroup = new LocationGroup(location, locationList);
            RegionApp regionApp = this.scheduleMetaAdaptor.regionApp(view.app());
            result.put(BytesUtil.nullToEmpty(regionApp.startKey()), locationGroup);
        }
    }
    return result;
}
Also used : AppView(io.dingodb.server.coordinator.app.AppView) ExecutorView(io.dingodb.server.coordinator.resource.impl.ExecutorView) TreeMap(java.util.TreeMap) RegionApp(io.dingodb.server.coordinator.app.impl.RegionApp) GeneralId(io.dingodb.server.coordinator.GeneralId) Endpoint(io.dingodb.raft.util.Endpoint) RegionView(io.dingodb.server.coordinator.app.impl.RegionView) LocationGroup(io.dingodb.meta.LocationGroup) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Location(io.dingodb.meta.Location)

Aggregations

RegionView (io.dingodb.server.coordinator.app.impl.RegionView)4 GeneralId (io.dingodb.server.coordinator.GeneralId)3 RegionApp (io.dingodb.server.coordinator.app.impl.RegionApp)3 Endpoint (io.dingodb.raft.util.Endpoint)2 ExecutorView (io.dingodb.server.coordinator.resource.impl.ExecutorView)2 Peer (io.dingodb.store.row.metadata.Peer)2 Map (java.util.Map)2 ConcurrentHashSet (com.alipay.remoting.util.ConcurrentHashSet)1 Optional (io.dingodb.common.util.Optional)1 Location (io.dingodb.meta.Location)1 LocationGroup (io.dingodb.meta.LocationGroup)1 AppView (io.dingodb.server.coordinator.app.AppView)1 GeneralIdHelper (io.dingodb.server.coordinator.meta.GeneralIdHelper)1 RowStoreMetaAdaptor (io.dingodb.server.coordinator.meta.RowStoreMetaAdaptor)1 ScheduleMetaAdaptor (io.dingodb.server.coordinator.meta.ScheduleMetaAdaptor)1 Cluster (io.dingodb.store.row.metadata.Cluster)1 Region (io.dingodb.store.row.metadata.Region)1 RegionEpoch (io.dingodb.store.row.metadata.RegionEpoch)1 RegionStats (io.dingodb.store.row.metadata.RegionStats)1 Store (io.dingodb.store.row.metadata.Store)1