geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject incubator-geode git commit: GEODE-96: fix race condition in unit test testDistributedRegionClientPutRejection
Date Wed, 15 Jul 2015 00:14:29 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-96 [created] ea463fe4f


GEODE-96: fix race condition in unit test testDistributedRegionClientPutRejection

The race condition was caused by WaitCriterion on the server not waiting for
the region to be marked as sick. Instead it was just waiting for OffHeapMemoryMonitor
state to be critical.


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

Branch: refs/heads/feature/GEODE-96
Commit: ea463fe4f085869733a9e0806ca90b6624e64968
Parents: 8c411a8
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue Jul 14 16:53:00 2015 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Tue Jul 14 16:53:00 2015 -0700

----------------------------------------------------------------------
 .../MemoryThresholdsOffHeapDUnitTest.java       | 48 +++++++++++++++-----
 1 file changed, 37 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ea463fe4/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
index aae64c4..0b704a6 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/management/MemoryThresholdsOffHeapDUnitTest.java
@@ -1401,18 +1401,44 @@ public class MemoryThresholdsOffHeapDUnitTest extends BridgeTestCase
{
         final OffHeapMemoryMonitor ohm = irm.getOffHeapMonitor();
         assertTrue(ohm.getState().isNormal());
         getCache().getLoggerI18n().fine(addExpectedExString);
-        getRootRegion().getSubregion(regionName).put(1, new byte[943720]);
-        WaitCriterion wc = new WaitCriterion() {
-          @Override
-          public String description() {
-            return "Expected to go critical";
-          }
+        final LocalRegion r = (LocalRegion) getRootRegion().getSubregion(regionName);
+        final Object key = 1;
+        r.put(key, new byte[943720]);
+        WaitCriterion wc;
+        if (r instanceof PartitionedRegion) {
+          final PartitionedRegion pr = (PartitionedRegion) r;
+          final int bucketId = PartitionedRegionHelper.getHashKey(pr, null, key, null, null);
+          wc = new WaitCriterion() {
+            @Override
+            public String description() {
+              return "Expected to go critical: isCritical=" + ohm.getState().isCritical();
+            }
 
-          @Override
-          public boolean done() {
-            return ohm.getState().isCritical();
-          }
-        };
+            @Override
+            public boolean done() {
+              if (!ohm.getState().isCritical()) return false;
+              // Only done once the bucket has been marked sick
+              try {
+                pr.getRegionAdvisor().checkIfBucketSick(bucketId, key);
+                return false;
+              } catch (LowMemoryException ignore) {
+                return true;
+              }
+            }
+          };
+        } else {
+          wc = new WaitCriterion() {
+            @Override
+            public String description() {
+              return "Expected to go critical: isCritical=" + ohm.getState().isCritical()
+ " memoryThresholdReached=" + r.memoryThresholdReached.get();
+            }
+
+            @Override
+            public boolean done() {
+              return ohm.getState().isCritical() && r.memoryThresholdReached.get();
+            }
+          };
+        }
         waitForCriterion(wc, 5000, 100, true);
         getCache().getLoggerI18n().fine(removeExpectedExString);
         return;


Mime
View raw message