This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch feature/GEODE-7983
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 71d48811b12cdeaabf9e483941c5d8c0da8365e6
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Mon Apr 13 22:21:13 2020 -0700

    GEODE-7983: Clear region writer callbacks should not be invoked for bucket 
regions
---
 .../cache/PartitionedRegionClearDUnitTest.java     | 44 +++++++++++++++++++++-
 .../internal/cache/partitioned/ClearPRMessage.java |  2 +-
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearDUnitTest.java
 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearDUnitTest.java
index a5a22b9..e2e04eb 100644
--- 
a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearDUnitTest.java
+++ 
b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionClearDUnitTest.java
@@ -47,6 +47,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
 
 public class PartitionedRegionClearDUnitTest implements Serializable {
   protected static final String REGION_NAME = "testPR";
+  protected static final int TOTAL_BUCKET_NUM = 10;
   protected static final int NUM_ENTRIES = 1000;
 
   protected int locatorPort;
@@ -103,7 +104,8 @@ public class PartitionedRegionClearDUnitTest implements 
Serializable {
 
   private void initDataStore(boolean withWriter) {
     RegionFactory factory = getCache().createRegionFactory(getRegionShortCut())
-        .setPartitionAttributes(new 
PartitionAttributesFactory().setTotalNumBuckets(10).create());
+        .setPartitionAttributes(
+            new 
PartitionAttributesFactory().setTotalNumBuckets(TOTAL_BUCKET_NUM).create());
     if (withWriter) {
       factory.setCacheWriter(new CountingCacheWriter());
     }
@@ -169,6 +171,26 @@ public class PartitionedRegionClearDUnitTest implements 
Serializable {
     return destroys;
   };
 
+  SerializableCallableIF<Integer> getBucketRegionWriterClears = () -> {
+    int clears = 0;
+    for (int i = 0; i < TOTAL_BUCKET_NUM; i++) {
+      String bucketRegionName = "_B__" + REGION_NAME + "_" + i;
+      clears += clearsByRegion.get(bucketRegionName) == null ? 0
+          : clearsByRegion.get(bucketRegionName).get();
+    }
+    return clears;
+  };
+
+  SerializableCallableIF<Integer> getBucketRegionWriterDestroys = () -> {
+    int destroys = 0;
+    for (int i = 0; i < TOTAL_BUCKET_NUM; i++) {
+      String bucketRegionName = "_B__" + REGION_NAME + "_" + i;
+      destroys += destroysByRegion.get(bucketRegionName) == null ? 0
+          : destroysByRegion.get(bucketRegionName).get();
+    }
+    return destroys;
+  };
+
   void configureServers(boolean dataStoreWithWriter, boolean 
accessorWithWriter) {
     dataStore1.invoke(() -> initDataStore(dataStoreWithWriter));
     dataStore2.invoke(() -> initDataStore(dataStoreWithWriter));
@@ -210,6 +232,10 @@ public class PartitionedRegionClearDUnitTest implements 
Serializable {
         .isEqualTo(1);
     
assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(accessor.invoke(getWriterClears))
         .isEqualTo(0);
+
+    assertThat(dataStore3.invoke(getBucketRegionWriterDestroys))
+        .isEqualTo(dataStore3.invoke(getBucketRegionWriterClears))
+        .isEqualTo(0);
   }
 
   @Test
@@ -237,6 +263,10 @@ public class PartitionedRegionClearDUnitTest implements 
Serializable {
         .isEqualTo(0);
     
assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(accessor.invoke(getWriterClears))
         .isEqualTo(1);
+
+    assertThat(accessor.invoke(getBucketRegionWriterDestroys))
+        .isEqualTo(accessor.invoke(getBucketRegionWriterClears))
+        .isEqualTo(0);
   }
 
   @Test
@@ -264,6 +294,10 @@ public class PartitionedRegionClearDUnitTest implements 
Serializable {
         .isEqualTo(0);
     
assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(accessor.invoke(getWriterClears))
         .isEqualTo(1);
+
+    assertThat(accessor.invoke(getBucketRegionWriterDestroys))
+        .isEqualTo(accessor.invoke(getBucketRegionWriterClears))
+        .isEqualTo(0);
   }
 
   @Test
@@ -291,6 +325,10 @@ public class PartitionedRegionClearDUnitTest implements 
Serializable {
         .isEqualTo(1);
     
assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(accessor.invoke(getWriterClears))
         .isEqualTo(0);
+
+    assertThat(dataStore3.invoke(getBucketRegionWriterDestroys))
+        .isEqualTo(dataStore3.invoke(getBucketRegionWriterClears))
+        .isEqualTo(0);
   }
 
   @Test
@@ -321,6 +359,10 @@ public class PartitionedRegionClearDUnitTest implements 
Serializable {
         .isEqualTo(1);
     
assertThat(accessor.invoke(getWriterDestroys)).isEqualTo(accessor.invoke(getWriterClears))
         .isEqualTo(0);
+
+    assertThat(dataStore3.invoke(getBucketRegionWriterDestroys))
+        .isEqualTo(dataStore3.invoke(getBucketRegionWriterClears))
+        .isEqualTo(0);
   }
 
   public static HashMap<String, AtomicInteger> clearsByRegion = new 
HashMap<>();
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java
index cc01920..2603b78 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/ClearPRMessage.java
@@ -175,7 +175,7 @@ public class ClearPRMessage extends 
PartitionMessageWithDirectReply {
     try {
       RegionEventImpl regionEvent = new RegionEventImpl(bucketRegion, 
Operation.REGION_CLEAR, null,
           false, region.getMyId(), eventID);
-      bucketRegion.cmnClearRegion(regionEvent, true, true);
+      bucketRegion.cmnClearRegion(regionEvent, false, true);
     } catch (PartitionOfflineException poe) {
       logger.info(
           "All members holding data for bucket {} are offline, no more retries 
will be attempted",

Reply via email to