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;
}
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)));
}
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);
}
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);
}
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;
}
Aggregations