mhansonp commented on a change in pull request #6845:
URL: https://github.com/apache/geode/pull/6845#discussion_r705691727
##########
File path:
geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/rebalance/model/Member.java
##########
@@ -40,21 +43,73 @@
private final boolean isCritical;
private final boolean enforceLocalMaxMemory;
- Member(AddressComparor addressComparor, InternalDistributedMember memberId,
boolean isCritical,
+ @VisibleForTesting
+ public Member(AddressComparor addressComparor, InternalDistributedMember
memberId,
+ boolean isCritical,
boolean enforceLocalMaxMemory) {
this.addressComparor = addressComparor;
this.memberId = memberId;
this.isCritical = isCritical;
this.enforceLocalMaxMemory = enforceLocalMaxMemory;
}
- Member(AddressComparor addressComparor, InternalDistributedMember memberId,
float weight,
+ @VisibleForTesting
+ public Member(AddressComparor addressComparor, InternalDistributedMember
memberId, float weight,
long localMaxMemory, boolean isCritical, boolean enforceLocalMaxMemory) {
this(addressComparor, memberId, isCritical, enforceLocalMaxMemory);
this.weight = weight;
this.localMaxMemory = localMaxMemory;
}
+ /**
+ * Check to see if the member is the last copy of the bucket in the
redundancy zone
+ *
+ * @param bucket -- bucket to be deleted from the member
+ * @param distributionManager -- used to check members of redundancy zones
+ */
+
+ public RefusalReason canDelete(Bucket bucket, DistributionManager
distributionManager) {
+ // This code only applies to Clusters.
+ if (!(distributionManager instanceof ClusterDistributionManager)) {
+ return RefusalReason.NONE;
+ }
+
+ ClusterDistributionManager clstrDistrMgr = (ClusterDistributionManager)
distributionManager;
+ String myRedundancyZone = clstrDistrMgr.getRedundancyZone(memberId);
+ boolean lastMemberOfZone = true;
+
+ if (myRedundancyZone == null) {
+ // Not using redundancy zones, so...
+ return RefusalReason.NONE;
+ }
+
+ for (Member member : bucket.getMembersHosting()) {
+ // Don't look at yourself because you are not redundant for yourself
+ if (member.getMemberId().equals(this.getMemberId())) {
+ continue;
+ }
+
+ String memberRedundancyZone =
clstrDistrMgr.getRedundancyZone(member.memberId);
+ if (memberRedundancyZone == null) {
+ // Not using redundancy zones, so...
+ continue;
+ }
+
+ // Does the member redundancy zone match my redundancy zone?
+ // if so we are not the last in the redundancy zone.
+ if (memberRedundancyZone.equals(myRedundancyZone)) {
+ lastMemberOfZone = false;
Review comment:
good suggestion
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]