Search in sources :

Example 1 with GeneralId

use of io.dingodb.server.coordinator.GeneralId in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method mapping.

public ExecutorView mapping(Store store) {
    if (store == null) {
        return null;
    }
    GeneralId generalId = GeneralId.fromStr(store.getId());
    ExecutorView view = new ExecutorView(generalId, store.getEndpoint());
    store.getRegions().stream().map(Region::getId).map(GeneralIdHelper::region).forEach(view::addApp);
    return view;
}
Also used : ExecutorView(io.dingodb.server.coordinator.resource.impl.ExecutorView) Region(io.dingodb.store.row.metadata.Region) GeneralId(io.dingodb.server.coordinator.GeneralId)

Example 2 with GeneralId

use of io.dingodb.server.coordinator.GeneralId in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method saveStore.

@Override
public void saveStore(Store store) {
    GeneralId id = GeneralId.fromStr(store.getId());
    ExecutorView view = mapping(store);
    scheduleMetaAdaptor.updateExecutorView(view);
    storeMap.put(id, store);
    endpointStoreId.put(store.getEndpoint(), id);
    storeRegion.put(id, store.getRegions().stream().map(Region::getId).map(GeneralIdHelper::region).collect(Collectors.toCollection(ConcurrentHashSet::new)));
}
Also used : ExecutorView(io.dingodb.server.coordinator.resource.impl.ExecutorView) ConcurrentHashSet(com.alipay.remoting.util.ConcurrentHashSet) GeneralIdHelper(io.dingodb.server.coordinator.meta.GeneralIdHelper) GeneralId(io.dingodb.server.coordinator.GeneralId)

Example 3 with GeneralId

use of io.dingodb.server.coordinator.GeneralId 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 4 with GeneralId

use of io.dingodb.server.coordinator.GeneralId in project dingo by dingodb.

the class RowStoreMetaAdaptorImpl method saveStoreStats.

@Override
public void saveStoreStats(StoreStats storeStats) {
    GeneralId id = GeneralId.fromStr(storeStats.getStoreId());
    ExecutorView view = scheduleMetaAdaptor.executorView(id);
    view.stats(storeStats);
    scheduleMetaAdaptor.updateExecutorView(view);
    storeStatsMap.put(id, storeStats);
}
Also used : ExecutorView(io.dingodb.server.coordinator.resource.impl.ExecutorView) GeneralId(io.dingodb.server.coordinator.GeneralId)

Example 5 with GeneralId

use of io.dingodb.server.coordinator.GeneralId 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

GeneralId (io.dingodb.server.coordinator.GeneralId)5 ExecutorView (io.dingodb.server.coordinator.resource.impl.ExecutorView)4 RegionApp (io.dingodb.server.coordinator.app.impl.RegionApp)2 RegionView (io.dingodb.server.coordinator.app.impl.RegionView)2 ConcurrentHashSet (com.alipay.remoting.util.ConcurrentHashSet)1 Location (io.dingodb.meta.Location)1 LocationGroup (io.dingodb.meta.LocationGroup)1 Endpoint (io.dingodb.raft.util.Endpoint)1 AppView (io.dingodb.server.coordinator.app.AppView)1 GeneralIdHelper (io.dingodb.server.coordinator.meta.GeneralIdHelper)1 Peer (io.dingodb.store.row.metadata.Peer)1 Region (io.dingodb.store.row.metadata.Region)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 TreeMap (java.util.TreeMap)1