Search in sources :

Example 6 with ExecutorView

use of io.dingodb.server.coordinator.resource.impl.ExecutorView 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

ExecutorView (io.dingodb.server.coordinator.resource.impl.ExecutorView)6 GeneralId (io.dingodb.server.coordinator.GeneralId)5 ConcurrentHashSet (com.alipay.remoting.util.ConcurrentHashSet)2 Endpoint (io.dingodb.raft.util.Endpoint)2 RegionApp (io.dingodb.server.coordinator.app.impl.RegionApp)2 RegionView (io.dingodb.server.coordinator.app.impl.RegionView)2 GeneralIdHelper (io.dingodb.server.coordinator.meta.GeneralIdHelper)2 Region (io.dingodb.store.row.metadata.Region)2 Map (java.util.Map)2 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 RowStoreMetaAdaptor (io.dingodb.server.coordinator.meta.RowStoreMetaAdaptor)1 ScheduleMetaAdaptor (io.dingodb.server.coordinator.meta.ScheduleMetaAdaptor)1 Cluster (io.dingodb.store.row.metadata.Cluster)1 Peer (io.dingodb.store.row.metadata.Peer)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