use of io.dingodb.server.coordinator.app.impl.RegionApp 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;
}
use of io.dingodb.server.coordinator.app.impl.RegionApp 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.app.impl.RegionApp 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);
}
use of io.dingodb.server.coordinator.app.impl.RegionApp 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