geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bogle...@apache.org
Subject [geode] branch develop updated: GEODE-5478: Modified updateNoCopiesStatistics to handle never had copies case
Date Tue, 31 Jul 2018 16:55:31 GMT
This is an automated email from the ASF dual-hosted git repository.

boglesby pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new e028894  GEODE-5478: Modified updateNoCopiesStatistics to handle never had copies
case
e028894 is described below

commit e0288945084f319f3a3d00b1689785693e1e7c4b
Author: Barry Oglesby <boglesby@users.noreply.github.com>
AuthorDate: Tue Jul 31 09:55:26 2018 -0700

    GEODE-5478: Modified updateNoCopiesStatistics to handle never had copies case
---
 .../org/apache/geode/internal/cache/BucketRedundancyTracker.java   | 4 +++-
 .../apache/geode/internal/cache/BucketRedundancyTrackerTest.java   | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/BucketRedundancyTracker.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/BucketRedundancyTracker.java
index f7340a0..a422741 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/BucketRedundancyTracker.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/BucketRedundancyTracker.java
@@ -23,6 +23,7 @@ class BucketRedundancyTracker {
   private boolean noCopiesDecrementOkay = false;
   // if true decrement allowed; if false increment allowed
   private boolean lowRedundancyDecrementOkay = false;
+  private boolean hasEverHadCopies = false;
   private boolean redundancyEverSatisfied = false;
   private volatile int currentRedundancy = -1;
   private final int targetRedundancy;
@@ -71,9 +72,10 @@ class BucketRedundancyTracker {
   }
 
   private void updateNoCopiesStatistics(int currentBucketHosts) {
-    if (currentBucketHosts == 0) {
+    if (currentBucketHosts == 0 && hasEverHadCopies) {
       incrementNoCopies();
     } else if (currentBucketHosts > 0) {
+      hasEverHadCopies = true;
       decrementNoCopies();
     }
   }
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/BucketRedundancyTrackerTest.java
b/geode-core/src/test/java/org/apache/geode/internal/cache/BucketRedundancyTrackerTest.java
index d48d9c1..0d69bb0 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/BucketRedundancyTrackerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/BucketRedundancyTrackerTest.java
@@ -108,6 +108,13 @@ public class BucketRedundancyTrackerTest {
   }
 
   @Test
+  public void doesNotIncrementNoCopiesWhenNeverHadAnyCopies() {
+    bucketRedundancyTracker.updateStatistics(0);
+    verify(regionRedundancyTracker, never()).incrementNoCopiesBucketCount();
+    assertEquals(-1, bucketRedundancyTracker.getCurrentRedundancy());
+  }
+
+  @Test
   public void incrementsBucketCountOnHavingNoCopiesForBucket() {
     bucketRedundancyTracker.updateStatistics(1);
     bucketRedundancyTracker.updateStatistics(0);


Mime
View raw message