use of io.dingodb.store.row.metadata.RegionStats in project dingo by dingodb.
the class RegionHeartbeatSender method collectRegionStats.
public RegionStats collectRegionStats(final TimeInterval timeInterval) {
final RegionStats stats = new RegionStats();
stats.setRegionId(region.getId());
// Leader Peer sending the heartbeat
stats.setLeader(new Peer(region.getId(), this.storeId, this.regionEngine.getStoreEngine().getSelfEndpoint()));
// Leader considers that these peers are down
// TODO
// Pending peers are the peers that the leader can't consider as working followers
// TODO
// Bytes written for the region during this period
stats.setBytesWritten(bytesWritten());
// Bytes read for the region during this period
stats.setBytesRead(bytesRead());
// Keys written for the region during this period
stats.setKeysWritten(keysWritten());
// Keys read for the region during this period
stats.setKeysRead(keysRead());
// Approximate region size
// TODO very important
// Approximate number of keys
ApproximateKVStats rangeStats = store().getApproximateKVStatsInRange(region.getStartKey(), region.getEndKey());
stats.setApproximateKeys(rangeStats.getKeysCnt());
stats.setApproximateSize(rangeStats.getSizeInBytes());
// Actually reported time interval
stats.setInterval(timeInterval);
if (log.isDebugEnabled()) {
log.info("Collect [RegionStats]: {}.", stats);
}
return stats;
}
use of io.dingodb.store.row.metadata.RegionStats in project dingo by dingodb.
the class StatsCollector method collectRegionStats.
public RegionStats collectRegionStats(final Region region, final TimeInterval timeInterval) {
final RegionStats stats = new RegionStats();
stats.setRegionId(region.getId());
// Leader Peer sending the heartbeat
stats.setLeader(new Peer(region.getId(), this.storeEngine.getStoreId(), this.storeEngine.getSelfEndpoint()));
// Leader considers that these peers are down
// TODO
// Pending peers are the peers that the leader can't consider as working followers
// TODO
// Bytes written for the region during this period
stats.setBytesWritten(getRegionBytesWritten(region, true));
// Bytes read for the region during this period
stats.setBytesRead(getRegionBytesRead(region, true));
// Keys written for the region during this period
stats.setKeysWritten(getRegionKeysWritten(region, true));
// Keys read for the region during this period
stats.setKeysRead(getRegionKeysRead(region, true));
// Approximate region size
// TODO very important
// Approximate number of keys
// ApproximateKVStats rangeStats = this.rawKVStore.getApproximateKVStatsInRange(
// region.getStartKey(), region.getEndKey());
// stats.setApproximateKeys(rangeStats.getKeysCnt());
// stats.setApproximateSize(rangeStats.getSizeInBytes());
// Actually reported time interval
stats.setInterval(timeInterval);
LOG.info("Collect [RegionStats]: {}.", stats);
return stats;
}
use of io.dingodb.store.row.metadata.RegionStats in project dingo by dingodb.
the class RegionHeartbeatHandler method split.
private Instruction split(RegionHeartbeatRequest request) {
Region region = request.getRegion();
RegionStats regionStats = request.getRegionStats();
clusterStatsManager.addOrUpdateRegionStats(region, regionStats);
final Set<String> stores = rowStoreMetaAdaptor.storeLocation().keySet();
if (stores.isEmpty()) {
return null;
}
if (clusterStatsManager.regionSize() >= stores.size()) {
// one store one region is perfect
return null;
}
final Pair<Region, RegionStats> modelWorker = clusterStatsManager.findModelWorkerRegion();
if (!isSplitNeeded(request, modelWorker)) {
return null;
}
final String newRegionId = rowStoreMetaAdaptor.newRegionId().seqNo().toString();
final Instruction.RangeSplit rangeSplit = new Instruction.RangeSplit();
rangeSplit.setNewRegionId(newRegionId);
final Instruction instruction = new Instruction();
instruction.setRegion(modelWorker.getKey().copy());
instruction.setRangeSplit(rangeSplit);
return instruction;
}
Aggregations