Repository: geode
Updated Branches:
  refs/heads/feature/GEM-1483 56a3fa75a -> 96c9745f9


fix-2


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/96c9745f
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/96c9745f
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/96c9745f

Branch: refs/heads/feature/GEM-1483
Commit: 96c9745f98fc6654357f5b73d3960d5050fde32e
Parents: 56a3fa7
Author: zhouxh <gz...@pivotal.io>
Authored: Sun Jun 18 00:10:03 2017 -0700
Committer: zhouxh <gz...@pivotal.io>
Committed: Sun Jun 18 00:10:03 2017 -0700

----------------------------------------------------------------------
 .../cache/PartitionedRegionDataStore.java       | 36 ++++++++++++++++++--
 1 file changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/96c9745f/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
index 74b8e6d..95dff75 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionDataStore.java
@@ -1417,6 +1417,31 @@ public class PartitionedRegionDataStore implements 
HasCachePerfStats {
     }
   }
 
+  public boolean isRemotePrimaryReadyForColocatedChildren(int bucketId) {
+    InternalDistributedMember myId =
+        
this.partitionedRegion.getDistributionManager().getDistributionManagerId();
+    boolean isRemotePrimaryReady = true;
+
+    List<PartitionedRegion> colocatedChildPRs =
+        ColocationHelper.getColocatedChildRegions(this.partitionedRegion);
+    if (colocatedChildPRs != null) {
+      for (PartitionedRegion pr : colocatedChildPRs) {
+        InternalDistributedMember primaryChild = pr.getBucketPrimary(bucketId);
+        if (primaryChild == null || myId.equals(primaryChild)) {
+          if (logger.isDebugEnabled()) {
+            logger.debug("Colocated bucket region " + pr + " " + bucketId
+                + " does not have a remote primary yet. Not to remove.");
+            return false;
+          }
+        } else {
+          return isRemotePrimaryReady
+              && 
pr.getDataStore().isRemotePrimaryReadyForColocatedChildren(bucketId);
+        }
+      }
+    }
+    return isRemotePrimaryReady;
+  }
+
   /**
    * Removes a redundant bucket hosted by this data store. The rebalancer 
invokes this method
    * directly or sends this member a message to invoke it.
@@ -1482,9 +1507,6 @@ public class PartitionedRegionDataStore implements 
HasCachePerfStats {
         }
         return false;
       }
-      if (logger.isDebugEnabled()) {
-        logger.debug("Bucket region " + bucketRegion + " has primary at " + 
primary);
-      }
       Lock writeLock = bucketAdvisor.getActiveWriteLock();
 
       // Fix for 43613 - don't remove the bucket
@@ -1497,6 +1519,14 @@ public class PartitionedRegionDataStore implements 
HasCachePerfStats {
           return false;
         }
 
+        if (!isRemotePrimaryReadyForColocatedChildren(bucketId)) {
+          return false;
+        }
+
+        if (logger.isDebugEnabled()) {
+          logger.debug("Bucket region " + bucketRegion + " has primary at " + 
primary);
+        }
+
         // recurse down to each tier of children to remove first
         removeBucketForColocatedChildren(bucketId, forceRemovePrimary);
 

Reply via email to