hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-13138 Clean up TestMasterObserver (debug, trying to figure why fails)
Date Mon, 02 Mar 2015 18:54:23 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 b3ebca633 -> c4acac561


HBASE-13138 Clean up TestMasterObserver (debug, trying to figure why fails)


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

Branch: refs/heads/branch-1
Commit: c4acac561ca512692b7f22d513f005cb7d51f465
Parents: b3ebca6
Author: stack <stack@apache.org>
Authored: Mon Mar 2 10:53:30 2015 -0800
Committer: stack <stack@apache.org>
Committed: Mon Mar 2 10:54:10 2015 -0800

----------------------------------------------------------------------
 .../master/handler/DisableTableHandler.java     | 11 ++-
 .../hbase/coprocessor/TestMasterObserver.java   | 83 ++++++++++----------
 2 files changed, 52 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/c4acac56/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
index f6ddf60..562d82c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
@@ -224,12 +224,19 @@ public class DisableTableHandler extends EventHandler {
       long startTime = System.currentTimeMillis();
       long remaining = timeout;
       List<HRegionInfo> regions = null;
+      long lastLogTime = startTime;
       while (!server.isStopped() && remaining > 0) {
         Thread.sleep(waitingTimeForEvents);
         regions = assignmentManager.getRegionStates().getRegionsOfTable(tableName);
-        LOG.debug("Disable waiting until done; " + remaining + " ms remaining; " + regions);
+        long now = System.currentTimeMillis();
+        // Don't log more than once every ten seconds. Its obnoxious. And only log table
regions
+        // if we are waiting a while for them to go down...
+        if (LOG.isDebugEnabled() && ((now - lastLogTime) > 10000)) {
+          lastLogTime =  now;
+          LOG.debug("Disable waiting until done; " + remaining + " ms remaining; " + regions);
+        }
         if (regions.isEmpty()) break;
-        remaining = timeout - (System.currentTimeMillis() - startTime);
+        remaining = timeout - (now - startTime);
       }
       return regions != null && regions.isEmpty();
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/c4acac56/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
index b82665b..7b0594c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
@@ -61,8 +61,10 @@ import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Threads;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
 
 /**
  * Tests invocation of the {@link org.apache.hadoop.hbase.coprocessor.MasterObserver}
@@ -1092,11 +1094,10 @@ public class TestMasterObserver {
 
   private static HBaseTestingUtility UTIL = new HBaseTestingUtility();
   private static byte[] TEST_SNAPSHOT = Bytes.toBytes("observed_snapshot");
-  private static TableName TEST_TABLE = TableName.valueOf("observed_table");
   private static TableName TEST_CLONE = TableName.valueOf("observed_clone");
   private static byte[] TEST_FAMILY = Bytes.toBytes("fam1");
   private static byte[] TEST_FAMILY2 = Bytes.toBytes("fam2");
-  private static byte[] TEST_FAMILY3 = Bytes.toBytes("fam3");
+  @Rule public TestName name = new TestName();
 
   @BeforeClass
   public static void setupBeforeClass() throws Exception {
@@ -1140,7 +1141,7 @@ public class TestMasterObserver {
   @Test (timeout=180000)
   public void testTableOperations() throws Exception {
     MiniHBaseCluster cluster = UTIL.getHBaseCluster();
-
+    final TableName tableName = TableName.valueOf(name.getMethodName());
     HMaster master = cluster.getMaster();
     MasterCoprocessorHost host = master.getMasterCoprocessorHost();
     CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
@@ -1150,7 +1151,7 @@ public class TestMasterObserver {
     assertFalse("No table created yet", cp.wasCreateTableCalled());
 
     // create a table
-    HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
+    HTableDescriptor htd = new HTableDescriptor(tableName);
     htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
     Admin admin = UTIL.getHBaseAdmin();
 
@@ -1165,8 +1166,8 @@ public class TestMasterObserver {
         cp.wasCreateTableHandlerCalled());
 
     tableCreationLatch = new CountDownLatch(1);
-    admin.disableTable(TEST_TABLE);
-    assertTrue(admin.isTableDisabled(TEST_TABLE));
+    admin.disableTable(tableName);
+    assertTrue(admin.isTableDisabled(tableName));
     // preDisableTable can't bypass default action.
     assertTrue("Coprocessor should have been called on table disable",
       cp.wasDisableTableCalled());
@@ -1175,45 +1176,45 @@ public class TestMasterObserver {
 
     // enable
     assertFalse(cp.wasEnableTableCalled());
-    admin.enableTable(TEST_TABLE);
-    assertTrue(admin.isTableEnabled(TEST_TABLE));
+    admin.enableTable(tableName);
+    assertTrue(admin.isTableEnabled(tableName));
     // preEnableTable can't bypass default action.
     assertTrue("Coprocessor should have been called on table enable",
       cp.wasEnableTableCalled());
     assertTrue("Enable table handler should be called.",
         cp.wasEnableTableHandlerCalled());
 
-    admin.disableTable(TEST_TABLE);
-    assertTrue(admin.isTableDisabled(TEST_TABLE));
+    admin.disableTable(tableName);
+    assertTrue(admin.isTableDisabled(tableName));
 
     // modify table
     htd.setMaxFileSize(512 * 1024 * 1024);
-    modifyTableSync(admin, TEST_TABLE, htd);
+    modifyTableSync(admin, tableName, htd);
     // preModifyTable can't bypass default action.
     assertTrue("Test table should have been modified",
       cp.wasModifyTableCalled());
 
     // add a column family
-    admin.addColumn(TEST_TABLE, new HColumnDescriptor(TEST_FAMILY2));
+    admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
     assertTrue("New column family shouldn't have been added to test table",
       cp.preAddColumnCalledOnly());
 
     // modify a column family
     HColumnDescriptor hcd1 = new HColumnDescriptor(TEST_FAMILY2);
     hcd1.setMaxVersions(25);
-    admin.modifyColumn(TEST_TABLE, hcd1);
+    admin.modifyColumn(tableName, hcd1);
     assertTrue("Second column family should be modified",
       cp.preModifyColumnCalledOnly());
 
     // truncate table
-    admin.truncateTable(TEST_TABLE, false);
+    admin.truncateTable(tableName, false);
 
     // delete table
-    admin.disableTable(TEST_TABLE);
-    assertTrue(admin.isTableDisabled(TEST_TABLE));
-    admin.deleteTable(TEST_TABLE);
+    admin.disableTable(tableName);
+    assertTrue(admin.isTableDisabled(tableName));
+    admin.deleteTable(tableName);
     assertFalse("Test table should have been deleted",
-        admin.tableExists(TEST_TABLE));
+        admin.tableExists(tableName));
     // preDeleteTable can't bypass default action.
     assertTrue("Coprocessor should have been called on table delete",
         cp.wasDeleteTableCalled());
@@ -1235,8 +1236,8 @@ public class TestMasterObserver {
     // disable
     assertFalse(cp.wasDisableTableCalled());
     assertFalse(cp.wasDisableTableHandlerCalled());
-    admin.disableTable(TEST_TABLE);
-    assertTrue(admin.isTableDisabled(TEST_TABLE));
+    admin.disableTable(tableName);
+    assertTrue(admin.isTableDisabled(tableName));
     assertTrue("Coprocessor should have been called on table disable",
       cp.wasDisableTableCalled());
     assertTrue("Disable table handler should be called.",
@@ -1244,11 +1245,11 @@ public class TestMasterObserver {
 
     // modify table
     htd.setMaxFileSize(512 * 1024 * 1024);
-    modifyTableSync(admin, TEST_TABLE, htd);
+    modifyTableSync(admin, tableName, htd);
     assertTrue("Test table should have been modified",
         cp.wasModifyTableCalled());
     // add a column family
-    admin.addColumn(TEST_TABLE, new HColumnDescriptor(TEST_FAMILY2));
+    admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
     assertTrue("New column family should have been added to test table",
         cp.wasAddColumnCalled());
     assertTrue("Add column handler should be called.",
@@ -1257,7 +1258,7 @@ public class TestMasterObserver {
     // modify a column family
     HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY2);
     hcd.setMaxVersions(25);
-    admin.modifyColumn(TEST_TABLE, hcd);
+    admin.modifyColumn(tableName, hcd);
     assertTrue("Second column family should be modified",
         cp.wasModifyColumnCalled());
     assertTrue("Modify table handler should be called.",
@@ -1266,23 +1267,23 @@ public class TestMasterObserver {
     // enable
     assertFalse(cp.wasEnableTableCalled());
     assertFalse(cp.wasEnableTableHandlerCalled());
-    admin.enableTable(TEST_TABLE);
-    assertTrue(admin.isTableEnabled(TEST_TABLE));
+    admin.enableTable(tableName);
+    assertTrue(admin.isTableEnabled(tableName));
     assertTrue("Coprocessor should have been called on table enable",
         cp.wasEnableTableCalled());
     assertTrue("Enable table handler should be called.",
         cp.wasEnableTableHandlerCalled());
 
     // disable again
-    admin.disableTable(TEST_TABLE);
-    assertTrue(admin.isTableDisabled(TEST_TABLE));
+    admin.disableTable(tableName);
+    assertTrue(admin.isTableDisabled(tableName));
 
     // delete column
     assertFalse("No column family deleted yet", cp.wasDeleteColumnCalled());
     assertFalse("Delete table column handler should not be called.",
         cp.wasDeleteColumnHandlerCalled());
-    admin.deleteColumn(TEST_TABLE, TEST_FAMILY2);
-    HTableDescriptor tableDesc = admin.getTableDescriptor(TEST_TABLE);
+    admin.deleteColumn(tableName, TEST_FAMILY2);
+    HTableDescriptor tableDesc = admin.getTableDescriptor(tableName);
     assertNull("'"+Bytes.toString(TEST_FAMILY2)+"' should have been removed",
         tableDesc.getFamily(TEST_FAMILY2));
     assertTrue("Coprocessor should have been called on column delete",
@@ -1294,9 +1295,9 @@ public class TestMasterObserver {
     assertFalse("No table deleted yet", cp.wasDeleteTableCalled());
     assertFalse("Delete table handler should not be called.",
         cp.wasDeleteTableHandlerCalled());
-    admin.deleteTable(TEST_TABLE);
+    admin.deleteTable(tableName);
     assertFalse("Test table should have been deleted",
-        admin.tableExists(TEST_TABLE));
+        admin.tableExists(tableName));
     assertTrue("Coprocessor should have been called on table delete",
         cp.wasDeleteTableCalled());
     assertTrue("Delete table handler should be called.",
@@ -1305,6 +1306,7 @@ public class TestMasterObserver {
 
   @Test (timeout=180000)
   public void testSnapshotOperations() throws Exception {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
     MiniHBaseCluster cluster = UTIL.getHBaseCluster();
     HMaster master = cluster.getMaster();
     MasterCoprocessorHost host = master.getMasterCoprocessorHost();
@@ -1313,7 +1315,7 @@ public class TestMasterObserver {
     cp.resetStates();
 
     // create a table
-    HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
+    HTableDescriptor htd = new HTableDescriptor(tableName);
     htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
     Admin admin = UTIL.getHBaseAdmin();
 
@@ -1322,14 +1324,14 @@ public class TestMasterObserver {
     tableCreationLatch.await();
     tableCreationLatch = new CountDownLatch(1);
 
-    admin.disableTable(TEST_TABLE);
-    assertTrue(admin.isTableDisabled(TEST_TABLE));
+    admin.disableTable(tableName);
+    assertTrue(admin.isTableDisabled(tableName));
 
     try {
       // Test snapshot operation
       assertFalse("Coprocessor should not have been called yet",
         cp.wasSnapshotCalled());
-      admin.snapshot(TEST_SNAPSHOT, TEST_TABLE);
+      admin.snapshot(TEST_SNAPSHOT, tableName);
       assertTrue("Coprocessor should have been called on snapshot",
         cp.wasSnapshotCalled());
 
@@ -1340,7 +1342,7 @@ public class TestMasterObserver {
       assertFalse("Coprocessor restore should not have been called on snapshot clone",
         cp.wasRestoreSnapshotCalled());
       admin.disableTable(TEST_CLONE);
-      assertTrue(admin.isTableDisabled(TEST_TABLE));
+      assertTrue(admin.isTableDisabled(tableName));
       admin.deleteTable(TEST_CLONE);
 
       // Test restore operation
@@ -1355,7 +1357,7 @@ public class TestMasterObserver {
       assertTrue("Coprocessor should have been called on snapshot delete",
         cp.wasDeleteSnapshotCalled());
     } finally {
-      admin.deleteTable(TEST_TABLE);
+      admin.deleteTable(tableName);
     }
   }
 
@@ -1448,6 +1450,7 @@ public class TestMasterObserver {
 
   @Test (timeout=180000)
   public void testRegionTransitionOperations() throws Exception {
+    final TableName tableName = TableName.valueOf(name.getMethodName());
     MiniHBaseCluster cluster = UTIL.getHBaseCluster();
 
     HMaster master = cluster.getMaster();
@@ -1457,10 +1460,10 @@ public class TestMasterObserver {
     cp.enableBypass(false);
     cp.resetStates();
 
-    HTable table = UTIL.createMultiRegionTable(TEST_TABLE, TEST_FAMILY);
+    HTable table = UTIL.createMultiRegionTable(tableName, TEST_FAMILY);
 
     try {
-      UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
+      UTIL.waitUntilAllRegionsAssigned(tableName);
 
       NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
       Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;
@@ -1534,7 +1537,7 @@ public class TestMasterObserver {
       assertTrue("Coprocessor should be called on region rebalancing",
           cp.wasBalanceCalled());
     } finally {
-      UTIL.deleteTable(TEST_TABLE);
+      UTIL.deleteTable(tableName);
     }
   }
 


Mime
View raw message