Search in sources :

Example 1 with AddressComparor

use of org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.AddressComparor in project geode by apache.

the class PartitionedRegionRebalanceOp method buildModel.

/**
   * Build a model of the load on the partitioned region, which can determine which buckets to move,
   * etc.
   * 
   * @param detailsMap
   * @param resourceManager
   */
private PartitionedRegionLoadModel buildModel(BucketOperator operator, Map<PartitionedRegion, InternalPRInfo> detailsMap, InternalResourceManager resourceManager) {
    PartitionedRegionLoadModel model;
    final boolean isDebugEnabled = logger.isDebugEnabled();
    final DM dm = leaderRegion.getDistributionManager();
    AddressComparor comparor = new AddressComparor() {

        public boolean areSameZone(InternalDistributedMember member1, InternalDistributedMember member2) {
            return dm.areInSameZone(member1, member2);
        }

        public boolean enforceUniqueZones() {
            return dm.enforceUniqueZone();
        }
    };
    int redundantCopies = leaderRegion.getRedundantCopies();
    int totalNumberOfBuckets = leaderRegion.getTotalNumberOfBuckets();
    Set<InternalDistributedMember> criticalMembers = resourceManager.getResourceAdvisor().adviseCritialMembers();
    ;
    boolean removeOverRedundancy = true;
    debug("Building Model for rebalancing " + leaderRegion + ". redundantCopies=" + redundantCopies + ", totalNumBuckets=" + totalNumberOfBuckets + ", criticalMembers=" + criticalMembers + ", simulate=" + simulate);
    model = new PartitionedRegionLoadModel(operator, redundantCopies, totalNumberOfBuckets, comparor, criticalMembers, leaderRegion);
    for (Map.Entry<PartitionedRegion, InternalPRInfo> entry : detailsMap.entrySet()) {
        PartitionedRegion region = entry.getKey();
        InternalPRInfo details = entry.getValue();
        OfflineMemberDetails offlineDetails;
        if (replaceOfflineData) {
            offlineDetails = OfflineMemberDetails.EMPTY_DETAILS;
        } else {
            offlineDetails = details.getOfflineMembers();
        }
        boolean enforceLocalMaxMemory = !region.isEntryEvictionPossible();
        debug("Added Region to model region=" + region + ", offlineDetails=" + offlineDetails + ", enforceLocalMaxMemory=" + enforceLocalMaxMemory);
        for (PartitionMemberInfo memberDetails : details.getPartitionMemberInfo()) {
            debug("For Region: " + region + ", Member: " + memberDetails.getDistributedMember() + "LOAD=" + ((InternalPartitionDetails) memberDetails).getPRLoad() + ", equivalentMembers=" + dm.getMembersInSameZone((InternalDistributedMember) memberDetails.getDistributedMember()));
        }
        Set<InternalPartitionDetails> memberDetailSet = details.getInternalPartitionDetails();
        model.addRegion(region.getFullPath(), memberDetailSet, offlineDetails, enforceLocalMaxMemory);
    }
    model.initialize();
    debug("Rebalancing {} starting. Model:\n{}", leaderRegion, model);
    return model;
}
Also used : AddressComparor(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.AddressComparor) DM(org.apache.geode.distributed.internal.DM) PartitionedRegionLoadModel(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) PartitionMemberInfo(org.apache.geode.cache.partition.PartitionMemberInfo) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 PartitionMemberInfo (org.apache.geode.cache.partition.PartitionMemberInfo)1 DM (org.apache.geode.distributed.internal.DM)1 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 PartitionedRegionLoadModel (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel)1 AddressComparor (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.AddressComparor)1