Search in sources :

Example 6 with Pair

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;
}
Also used : RegionStats(com.alipay.sofa.jraft.rhea.metadata.RegionStats) Region(com.alipay.sofa.jraft.rhea.metadata.Region) Pair(com.alipay.sofa.jraft.rhea.util.Pair)

Aggregations

Pair (com.alipay.sofa.jraft.rhea.util.Pair)6 Region (com.alipay.sofa.jraft.rhea.metadata.Region)4 RegionStats (com.alipay.sofa.jraft.rhea.metadata.RegionStats)4 RegionHeartbeatRequest (com.alipay.sofa.jraft.rhea.cmd.pd.RegionHeartbeatRequest)3 Endpoint (com.alipay.sofa.jraft.util.Endpoint)3 MetadataStore (com.alipay.sofa.jraft.rhea.MetadataStore)2 Instruction (com.alipay.sofa.jraft.rhea.metadata.Instruction)2 TimeInterval (com.alipay.sofa.jraft.rhea.metadata.TimeInterval)2 Status (com.alipay.sofa.jraft.Status)1 ClusterStatsManager (com.alipay.sofa.jraft.rhea.ClusterStatsManager)1 Peer (com.alipay.sofa.jraft.rhea.metadata.Peer)1 RegionEpoch (com.alipay.sofa.jraft.rhea.metadata.RegionEpoch)1 StoreStats (com.alipay.sofa.jraft.rhea.metadata.StoreStats)1 FencingKeyDB (com.alipay.sofa.jraft.rhea.storage.MemoryKVStoreSnapshotFile.FencingKeyDB)1 LockerDB (com.alipay.sofa.jraft.rhea.storage.MemoryKVStoreSnapshotFile.LockerDB)1 Segment (com.alipay.sofa.jraft.rhea.storage.MemoryKVStoreSnapshotFile.Segment)1 SequenceDB (com.alipay.sofa.jraft.rhea.storage.MemoryKVStoreSnapshotFile.SequenceDB)1 TailIndex (com.alipay.sofa.jraft.rhea.storage.MemoryKVStoreSnapshotFile.TailIndex)1 Timer (com.codahale.metrics.Timer)1 File (java.io.File)1