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;
}
Aggregations