You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by cj...@apache.org on 2014/09/19 02:38:16 UTC

[4/6] git commit: ACCUMULO-3146 Try to stabilize BalanceAfterCommsFailureIT and SimpleBalancerFairnessIT

ACCUMULO-3146 Try to stabilize BalanceAfterCommsFailureIT and SimpleBalancerFairnessIT


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/7a40f7bf
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7a40f7bf
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7a40f7bf

Branch: refs/heads/1.6.1-rc1
Commit: 7a40f7bfa4c6e30467a24105da974687ac442cdf
Parents: 992414e
Author: Josh Elser <el...@apache.org>
Authored: Thu Sep 18 18:12:12 2014 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Sep 18 18:12:12 2014 -0400

----------------------------------------------------------------------
 .../functional/BalanceAfterCommsFailureIT.java  | 30 +++++++++----
 .../functional/SimpleBalancerFairnessIT.java    | 44 ++++++++++++++------
 2 files changed, 53 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7a40f7bf/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java b/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
index 39e7e70..7b4a774 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/BalanceAfterCommsFailureIT.java
@@ -92,22 +92,33 @@ public class BalanceAfterCommsFailureIT extends ConfigurableMacIT {
     c.tableOperations().addSplits("test", splits);
     // Ensure all of the tablets are actually assigned
     assertEquals(0, Iterables.size(c.createScanner("test", Authorizations.EMPTY)));
-    UtilWaitThread.sleep(10 * 1000);
+    UtilWaitThread.sleep(30 * 1000);
     checkBalance(c);
   }
 
   private void checkBalance(Connector c) throws Exception {
     Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
 
-    MasterClientService.Iface client = null;
     MasterMonitorInfo stats = null;
-    try {
-      client = MasterClient.getConnectionWithRetry(c.getInstance());
-      stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
-    } finally {
-      if (client != null)
-        MasterClient.close(client);
+    int unassignedTablets = 1;
+    for (int i = 0; unassignedTablets > 0 && i < 10; i++) {
+      MasterClientService.Iface client = null;
+      try {
+        client = MasterClient.getConnectionWithRetry(c.getInstance());
+        stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
+      } finally {
+        if (client != null)
+          MasterClient.close(client);
+      }
+      unassignedTablets = stats.getUnassignedTablets();
+      if (unassignedTablets > 0) {
+        log.info("Found " + unassignedTablets + " unassigned tablets, sleeping 3 seconds for tablet assignment");
+        Thread.sleep(3000);
+      }
     }
+
+    assertEquals("Unassigned tablets were not assigned within 30 seconds", 0, unassignedTablets);
+
     List<Integer> counts = new ArrayList<Integer>();
     for (TabletServerStatus server : stats.tServerInfo) {
       int count = 0;
@@ -119,7 +130,8 @@ public class BalanceAfterCommsFailureIT extends ConfigurableMacIT {
     assertTrue("Expected to have at least two TabletServers", counts.size() > 1);
     for (int i = 1; i < counts.size(); i++) {
       int diff = Math.abs(counts.get(0) - counts.get(i));
-      assertTrue("Expected difference in tablets to be less than or equal to " + counts.size() + " but was " + diff, diff <= counts.size());
+      assertTrue("Expected difference in tablets to be less than or equal to " + counts.size() + " but was " + diff + ". Counts " + counts,
+          diff <= counts.size());
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7a40f7bf/test/src/test/java/org/apache/accumulo/test/functional/SimpleBalancerFairnessIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/SimpleBalancerFairnessIT.java b/test/src/test/java/org/apache/accumulo/test/functional/SimpleBalancerFairnessIT.java
index 6904563..7d37615 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/SimpleBalancerFairnessIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/SimpleBalancerFairnessIT.java
@@ -16,12 +16,14 @@
  */
 package org.apache.accumulo.test.functional;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.TreeSet;
 
 import org.apache.accumulo.core.cli.BatchWriterOpts;
 import org.apache.accumulo.core.client.Connector;
@@ -38,6 +40,7 @@ import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
 import org.apache.accumulo.test.TestIngest;
 import org.apache.accumulo.trace.instrument.Tracer;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.Text;
 import org.junit.Test;
 
 public class SimpleBalancerFairnessIT extends ConfigurableMacIT {
@@ -61,24 +64,38 @@ public class SimpleBalancerFairnessIT extends ConfigurableMacIT {
     c.tableOperations().create("test_ingest");
     c.tableOperations().setProperty("test_ingest", Property.TABLE_SPLIT_THRESHOLD.getKey(), "10K");
     c.tableOperations().create("unused");
-    c.tableOperations().addSplits("unused", TestIngest.getSplitPoints(0, 10000000, 2000));
+    TreeSet<Text> splits = TestIngest.getSplitPoints(0, 10000000, 2000);
+    log.info("Creating " + splits.size() + " splits");
+    c.tableOperations().addSplits("unused", splits);
     List<String> tservers = c.instanceOperations().getTabletServers();
     TestIngest.Opts opts = new TestIngest.Opts();
     opts.rows = 200000;
     TestIngest.ingest(c, opts, new BatchWriterOpts());
     c.tableOperations().flush("test_ingest", null, null, false);
-    UtilWaitThread.sleep(15 * 1000);
+    UtilWaitThread.sleep(45 * 1000);
     Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
 
-    MasterClientService.Iface client = null;
     MasterMonitorInfo stats = null;
-    try {
-      client = MasterClient.getConnectionWithRetry(c.getInstance());
-      stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
-    } finally {
-      if (client != null)
-        MasterClient.close(client);
+    int unassignedTablets = 1;
+    for (int i = 0; unassignedTablets > 0 && i < 10; i++) {
+      MasterClientService.Iface client = null;
+      try {
+        client = MasterClient.getConnectionWithRetry(c.getInstance());
+        stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
+      } finally {
+        if (client != null)
+          MasterClient.close(client);
+      }
+      unassignedTablets = stats.getUnassignedTablets();
+      if (unassignedTablets > 0) {
+        log.info("Found " + unassignedTablets + " unassigned tablets, sleeping 3 seconds for tablet assignment");
+        Thread.sleep(3000);
+      }
     }
+
+    assertEquals("Unassigned tablets were not assigned within 30 seconds", 0, unassignedTablets);
+
+    // Compute online tablets per tserver
     List<Integer> counts = new ArrayList<Integer>();
     for (TabletServerStatus server : stats.tServerInfo) {
       int count = 0;
@@ -87,9 +104,12 @@ public class SimpleBalancerFairnessIT extends ConfigurableMacIT {
       }
       counts.add(count);
     }
-    assertTrue(counts.size() > 1);
-    for (int i = 1; i < counts.size(); i++)
-      assertTrue(Math.abs(counts.get(0) - counts.get(i)) <= tservers.size());
+    assertTrue("Expected to have at least two TabletServers", counts.size() > 1);
+    for (int i = 1; i < counts.size(); i++) {
+      int diff = Math.abs(counts.get(0) - counts.get(i));
+      assertTrue("Expected difference in tablets to be less than or equal to " + counts.size() + " but was " + diff + ". Counts " + counts,
+          diff <= tservers.size());
+    }
   }
 
 }