use of com.alipay.sofa.jraft.rhea.util.Pair in project sofa-jraft by sofastack.
the class SplittingJudgeByApproximateKeysHandler method isSplitNeeded.
private boolean isSplitNeeded(final RegionHeartbeatRequest request, final Pair<Region, RegionStats> modelWorker) {
if (modelWorker == null) {
return false;
}
final long modelApproximateKeys = modelWorker.getValue().getApproximateKeys();
if (request.getLeastKeysOnSplit() > modelApproximateKeys) {
return false;
}
final Region modelRegion = modelWorker.getKey();
final List<Pair<Region, RegionStats>> regionStatsList = request.getRegionStatsList();
for (final Pair<Region, RegionStats> p : regionStatsList) {
if (modelRegion.equals(p.getKey())) {
return true;
}
}
return false;
}
Aggregations