You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2019/07/26 18:38:14 UTC

[accumulo] branch 1.9 updated: Improve busy tracker handling of reloaded tablets (#1296)

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

kturner pushed a commit to branch 1.9
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/1.9 by this push:
     new 6546fc3  Improve busy tracker handling of reloaded tablets (#1296)
6546fc3 is described below

commit 6546fc3c9858885941d87b3de6741bb748c560a6
Author: Keith Turner <kt...@apache.org>
AuthorDate: Fri Jul 26 14:38:09 2019 -0400

    Improve busy tracker handling of reloaded tablets (#1296)
---
 .../apache/accumulo/tserver/BusiestTracker.java    |  7 +++--
 .../accumulo/tserver/BusiestTrackerTest.java       | 32 ++++++++++++++++------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/BusiestTracker.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/BusiestTracker.java
index ea60cad..229ed74 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/BusiestTracker.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/BusiestTracker.java
@@ -61,12 +61,15 @@ public abstract class BusiestTracker {
       counts.put(extent, count);
 
       Long lastCount = lastCounts.get(extent);
-      if (lastCount == null)
+
+      // if a tablet leaves a tserver and come back, then its count will be reset. This could make
+      // lastCount higher than the current count. That is why lastCount > count is checked below.
+      if (lastCount == null || lastCount > count)
         lastCount = 0L;
 
       long delta = count - lastCount;
 
-      // handle case where tablet leaves tserver and returns OR tablet had no activity
+      // handle case where tablet had no activity
       if (delta > 0)
         tabletsWithDelta.add(new ComparablePair<>(delta, extent));
     }
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/BusiestTrackerTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/BusiestTrackerTest.java
index 8e63dfe..cde7c67 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/BusiestTrackerTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/BusiestTrackerTest.java
@@ -38,13 +38,7 @@ import com.google.common.base.Preconditions;
 public class BusiestTrackerTest {
 
   private static BusiestTracker newTestTracker(int numToLog) {
-    return new BusiestTracker(3) {
-
-      @Override
-      protected long extractCount(Tablet tablet) {
-        return tablet.totalIngest();
-      }
-    };
+    return BusiestTracker.newBusiestIngestTracker(numToLog);
   }
 
   private static Collection<Tablet> createTablets(Object... testData) {
@@ -135,10 +129,10 @@ public class BusiestTrackerTest {
     Collection<ComparablePair<Long,KeyExtent>> busy1 = tracker.computeBusiest(data1);
     assertEquals(createExpected("e1", 5L, "e2", 3L), new HashSet<>(busy1));
 
-    // when count is less than previously seen tablet should be ignored
+    // when count is less than previously seen, previous count should be ignored
     Collection<Tablet> data2 = createTablets("e1", 7L, "e2", 1L);
     Collection<ComparablePair<Long,KeyExtent>> busy2 = tracker.computeBusiest(data2);
-    assertEquals(createExpected("e1", 2L), new HashSet<>(busy2));
+    assertEquals(createExpected("e1", 2L, "e2", 1L), new HashSet<>(busy2));
 
     Collection<Tablet> data3 = createTablets("e1", 8L, "e2", 4L);
     Collection<ComparablePair<Long,KeyExtent>> busy3 = tracker.computeBusiest(data3);
@@ -146,6 +140,26 @@ public class BusiestTrackerTest {
   }
 
   @Test
+  public void testReload2() {
+    BusiestTracker tracker = newTestTracker(3);
+
+    // This test differs from testReload because the tablet that has its count decrease does not
+    // show up in busy1
+    Collection<Tablet> data1 = createTablets("e1", 115L, "e2", 73L, "e3", 206L, "e4", 85L);
+    Collection<ComparablePair<Long,KeyExtent>> busy1 = tracker.computeBusiest(data1);
+    assertEquals(createExpected("e3", 206L, "e1", 115L, "e4", 85L), new HashSet<>(busy1));
+
+    // the count for e2 decreases, simulating a tablet leaving a tserver and coming back
+    Collection<Tablet> data2 = createTablets("e1", 118L, "e2", 20L, "e3", 216L, "e4", 89L);
+    Collection<ComparablePair<Long,KeyExtent>> busy2 = tracker.computeBusiest(data2);
+    assertEquals(createExpected("e2", 20L, "e3", 10L, "e4", 4L), new HashSet<>(busy2));
+
+    Collection<Tablet> data3 = createTablets("e1", 118L, "e2", 21L, "e3", 218L, "e4", 89L);
+    Collection<ComparablePair<Long,KeyExtent>> busy3 = tracker.computeBusiest(data3);
+    assertEquals(createExpected("e2", 1L, "e3", 2L), new HashSet<>(busy3));
+  }
+
+  @Test
   public void testOrder() {
     BusiestTracker tracker = newTestTracker(3);