hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [18/50] hbase git commit: HBASE-15927 Remove HMaster.assignRegion()
Date Sat, 11 Jun 2016 04:56:04 GMT
HBASE-15927 Remove HMaster.assignRegion()


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

Branch: refs/heads/hbase-12439
Commit: f0c159b5fed732cdc08bd2fd924ae81677d66a30
Parents: 0cbce07
Author: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Authored: Fri Jun 3 12:36:25 2016 -0700
Committer: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Committed: Fri Jun 3 12:36:25 2016 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/master/HMaster.java |  4 --
 .../hadoop/hbase/HBaseTestingUtility.java       | 15 +++++
 .../hbase/client/TestMetaWithReplicas.java      |  2 +-
 .../master/TestAssignmentManagerOnCluster.java  | 61 ++++++++------------
 .../hadoop/hbase/util/TestHBaseFsckOneRS.java   | 20 +++----
 .../hadoop/hbase/util/TestHBaseFsckTwoRS.java   | 23 +++-----
 6 files changed, 58 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f0c159b5/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index f8d0003..d368ffb 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -2378,10 +2378,6 @@ public class HMaster extends HRegionServer implements MasterServices
{
     return this.initializationBeforeMetaAssignment;
   }
 
-  public void assignRegion(HRegionInfo hri) {
-    assignmentManager.assign(hri);
-  }
-
   /**
    * Compute the average load across all region servers.
    * Currently, this uses a very naive computation - just uses the number of

http://git-wip-us.apache.org/repos/asf/hbase/blob/f0c159b5/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index 7b35815..bfa14cb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -3200,6 +3200,21 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility
{
   }
 
   /**
+   * Uses directly the assignment manager to assign the region.
+   * and waits until the specified region has completed assignment.
+   * @param tableName the table name
+   * @throws IOException
+   * @throw InterruptedException
+   * @return true if the region is assigned false otherwise.
+   */
+  public boolean assignRegion(final HRegionInfo regionInfo)
+      throws IOException, InterruptedException {
+    final AssignmentManager am = getHBaseCluster().getMaster().getAssignmentManager();
+    am.assign(regionInfo);
+    return am.waitForAssignment(regionInfo);
+  }
+
+  /**
    * Wait until all regions for a table in hbase:meta have a non-empty
    * info:server, up to a configuable timeout value (default is 60 seconds)
    * This means all regions have been deployed,

http://git-wip-us.apache.org/repos/asf/hbase/blob/f0c159b5/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java
index 5e302d2..8e87ceb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMetaWithReplicas.java
@@ -448,7 +448,7 @@ public class TestMetaWithReplicas {
     // create in-memory state otherwise master won't assign
     TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
              .getRegionStates().createRegionState(h);
-    TEST_UTIL.getMiniHBaseCluster().getMaster().assignRegion(h);
+    TEST_UTIL.assignRegion(h);
     HBaseFsckRepair.waitUntilAssigned(TEST_UTIL.getHBaseAdmin(), h);
     // check that problem exists
     HBaseFsck hbck = doFsck(TEST_UTIL.getConfiguration(), false);

http://git-wip-us.apache.org/repos/asf/hbase/blob/f0c159b5/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
index 95ef6d5..7d3d2e9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
@@ -191,9 +191,8 @@ public class TestAssignmentManagerOnCluster {
       MetaTableAccessor.addRegionToMeta(meta, hri);
 
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
-      am.waitForAssignment(hri);
+      TEST_UTIL.assignRegion(hri);
 
       RegionStates regionStates = am.getRegionStates();
       ServerName serverName = regionStates.getRegionServerOfRegion(hri);
@@ -248,7 +247,7 @@ public class TestAssignmentManagerOnCluster {
       final AssignmentManager am = master.getAssignmentManager();
       RegionPlan plan = new RegionPlan(hri, null, deadServer);
       am.addPlan(hri.getEncodedName(), plan);
-      master.assignRegion(hri);
+      TEST_UTIL.assignRegion(hri);
 
       TEST_UTIL.waitFor(60000, new Waiter.Predicate<Exception>() {
         @Override
@@ -446,9 +445,8 @@ public class TestAssignmentManagerOnCluster {
       MetaTableAccessor.addRegionToMeta(meta, hri);
 
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
-      assertTrue(am.waitForAssignment(hri));
+      assertTrue(TEST_UTIL.assignRegion(hri));
 
       ServerName sn = am.getRegionStates().getRegionServerOfRegion(hri);
       TEST_UTIL.assertRegionOnServer(hri, sn, 6000);
@@ -495,9 +493,8 @@ public class TestAssignmentManagerOnCluster {
       MetaTableAccessor.addRegionToMeta(meta, hri);
 
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
-      assertTrue(am.waitForAssignment(hri));
+      assertTrue(TEST_UTIL.assignRegion(hri));
       ServerName sn = am.getRegionStates().getRegionServerOfRegion(hri);
       TEST_UTIL.assertRegionOnServer(hri, sn, 6000);
 
@@ -543,9 +540,8 @@ public class TestAssignmentManagerOnCluster {
       MyLoadBalancer.controledRegion = hri;
 
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
-      assertFalse(am.waitForAssignment(hri));
+      assertFalse(TEST_UTIL.assignRegion(hri));
 
       RegionState state = am.getRegionStates().getRegionState(hri);
       assertEquals(RegionState.State.FAILED_OPEN, state.getState());
@@ -553,8 +549,7 @@ public class TestAssignmentManagerOnCluster {
       assertNull(state.getServerName());
 
       MyLoadBalancer.controledRegion = null;
-      master.assignRegion(hri);
-      assertTrue(am.waitForAssignment(hri));
+      assertTrue(TEST_UTIL.assignRegion(hri));
 
       ServerName serverName = master.getAssignmentManager().
         getRegionStates().getRegionServerOfRegion(hri);
@@ -581,17 +576,15 @@ public class TestAssignmentManagerOnCluster {
         desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
       MetaTableAccessor.addRegionToMeta(meta, hri);
 
-      MyLoadBalancer.controledRegion = hri;
-
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
       AssignmentManager am = master.getAssignmentManager();
+
       // round-robin assignment but balancer cannot find a plan
       // assignment should fail
-      am.assign(Arrays.asList(hri));
-
+      MyLoadBalancer.controledRegion = hri;
       // if bulk assignment cannot update region state to online
       // or failed_open this waits until timeout
-      assertFalse(am.waitForAssignment(hri));
+      assertFalse(TEST_UTIL.assignRegion(hri));
       RegionState state = am.getRegionStates().getRegionState(hri);
       assertEquals(RegionState.State.FAILED_OPEN, state.getState());
       // Failed to open since no plan, so it's on no server
@@ -599,8 +592,7 @@ public class TestAssignmentManagerOnCluster {
 
       // try again with valid plan
       MyLoadBalancer.controledRegion = null;
-      am.assign(Arrays.asList(hri));
-      assertTrue(am.waitForAssignment(hri));
+      assertTrue(TEST_UTIL.assignRegion(hri));
 
       ServerName serverName = master.getAssignmentManager().
         getRegionStates().getRegionServerOfRegion(hri);
@@ -689,9 +681,8 @@ public class TestAssignmentManagerOnCluster {
       fs.create(regionDir, true);
 
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
-      assertFalse(am.waitForAssignment(hri));
+      assertFalse(TEST_UTIL.assignRegion(hri));
 
       RegionState state = am.getRegionStates().getRegionState(hri);
       assertEquals(RegionState.State.FAILED_OPEN, state.getState());
@@ -702,8 +693,7 @@ public class TestAssignmentManagerOnCluster {
 
       // remove the blocking file, so that region can be opened
       fs.delete(regionDir, true);
-      master.assignRegion(hri);
-      assertTrue(am.waitForAssignment(hri));
+      assertTrue(TEST_UTIL.assignRegion(hri));
 
       ServerName serverName = master.getAssignmentManager().
         getRegionStates().getRegionServerOfRegion(hri);
@@ -768,9 +758,8 @@ public class TestAssignmentManagerOnCluster {
       MetaTableAccessor.addRegionToMeta(meta, hri);
 
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
-      assertTrue(am.waitForAssignment(hri));
+      assertTrue(TEST_UTIL.assignRegion(hri));
       ServerName sn = am.getRegionStates().getRegionServerOfRegion(hri);
       TEST_UTIL.assertRegionOnServer(hri, sn, 6000);
 
@@ -816,8 +805,9 @@ public class TestAssignmentManagerOnCluster {
       MyRegionObserver.postOpenEnabled.set(true);
       MyRegionObserver.postOpenCalled = false;
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
+      AssignmentManager am = master.getAssignmentManager();
       // Region will be opened, but it won't complete
-      master.assignRegion(hri);
+      am.assign(hri);
       long end = EnvironmentEdgeManager.currentTime() + 20000;
       // Wait till postOpen is called
       while (!MyRegionObserver.postOpenCalled ) {
@@ -826,7 +816,6 @@ public class TestAssignmentManagerOnCluster {
         Thread.sleep(300);
       }
 
-      AssignmentManager am = master.getAssignmentManager();
       // Now let's unassign it, it should do nothing
       am.unassign(hri);
       RegionState state = am.getRegionStates().getRegionState(hri);
@@ -887,12 +876,14 @@ public class TestAssignmentManagerOnCluster {
 
       // Assign the region
       master = (MyMaster)cluster.getMaster();
-      master.assignRegion(hri);
+      AssignmentManager am = master.getAssignmentManager();
+
+      am.assign(hri);
 
       // Hold SSH before killing the hosting server
       master.enableSSH(false);
 
-      AssignmentManager am = master.getAssignmentManager();
+
       RegionStates regionStates = am.getRegionStates();
       ServerName metaServer = regionStates.getRegionServerOfRegion(
         HRegionInfo.FIRST_META_REGIONINFO);
@@ -1015,10 +1006,9 @@ public class TestAssignmentManagerOnCluster {
 
       // Assign the region
       master = (MyMaster)cluster.getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
       RegionStates regionStates = am.getRegionStates();
-      assertTrue(am.waitForAssignment(hri));
+      assertTrue(TEST_UTIL.assignRegion(hri));
 
       // Disable the table
       admin.disableTable(table);
@@ -1056,9 +1046,9 @@ public class TestAssignmentManagerOnCluster {
 
       // Assign the region
       master = (MyMaster)cluster.getMaster();
-      master.assignRegion(hri);
-
       AssignmentManager am = master.getAssignmentManager();
+      am.assign(hri);
+
       RegionStates regionStates = am.getRegionStates();
       ServerName metaServer = regionStates.getRegionServerOfRegion(
         HRegionInfo.FIRST_META_REGIONINFO);
@@ -1129,9 +1119,9 @@ public class TestAssignmentManagerOnCluster {
 
       // Assign the region
       master = (MyMaster)cluster.getMaster();
-      master.assignRegion(hri);
-
       AssignmentManager am = master.getAssignmentManager();
+      am.assign(hri);
+
       RegionStates regionStates = am.getRegionStates();
       ServerName metaServer = regionStates.getRegionServerOfRegion(
         HRegionInfo.FIRST_META_REGIONINFO);
@@ -1196,9 +1186,8 @@ public class TestAssignmentManagerOnCluster {
           new HRegionInfo(desc.getTableName(), Bytes.toBytes("A"), Bytes.toBytes("Z"));
       MetaTableAccessor.addRegionToMeta(meta, hri);
       HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
-      master.assignRegion(hri);
       AssignmentManager am = master.getAssignmentManager();
-      am.waitForAssignment(hri);
+      TEST_UTIL.assignRegion(hri);
       RegionStates regionStates = am.getRegionStates();
       ServerName serverName = regionStates.getRegionServerOfRegion(hri);
       // Assert the the region is actually open on the server

http://git-wip-us.apache.org/repos/asf/hbase/blob/f0c159b5/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
index 866a12d..2140b39 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
@@ -310,9 +310,8 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
 
       HRegionInfo hriOverlap =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A2"), Bytes.toBytes("B"));
-      TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriOverlap);
-      TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
-          .waitForAssignment(hriOverlap);
+      TEST_UTIL.assignRegion(hriOverlap);
+
       ServerName server = regionStates.getRegionServerOfRegion(hriOverlap);
       TEST_UTIL.assertRegionOnServer(hriOverlap, server, REGION_ONLINE_TIMEOUT);
 
@@ -350,9 +349,8 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
       // Mess it up by creating an overlap in the metadata
       HRegionInfo hriOverlap =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A2"), Bytes.toBytes("B2"));
-      TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriOverlap);
-      TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
-          .waitForAssignment(hriOverlap);
+      TEST_UTIL.assignRegion(hriOverlap);
+
       ServerName server = regionStates.getRegionServerOfRegion(hriOverlap);
       TEST_UTIL.assertRegionOnServer(hriOverlap, server, REGION_ONLINE_TIMEOUT);
 
@@ -1225,9 +1223,8 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
 
       HRegionInfo hriOverlap =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A2"), Bytes.toBytes("B"));
-      TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriOverlap);
-      TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
-          .waitForAssignment(hriOverlap);
+      TEST_UTIL.assignRegion(hriOverlap);
+
       ServerName server = regionStates.getRegionServerOfRegion(hriOverlap);
       TEST_UTIL.assertRegionOnServer(hriOverlap, server, REGION_ONLINE_TIMEOUT);
 
@@ -1351,9 +1348,8 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
       // Now let's mess it up, by adding a region with a duplicate startkey
       HRegionInfo hriDupe =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("B"), Bytes.toBytes("B"));
-      TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriDupe);
-      TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
-          .waitForAssignment(hriDupe);
+      TEST_UTIL.assignRegion(hriDupe);
+
       ServerName server = regionStates.getRegionServerOfRegion(hriDupe);
       TEST_UTIL.assertRegionOnServer(hriDupe, server, REGION_ONLINE_TIMEOUT);
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/f0c159b5/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
index 7f023e0..17ac778 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckTwoRS.java
@@ -136,9 +136,8 @@ public class TestHBaseFsckTwoRS extends BaseTestHBaseFsck {
       // Now let's mess it up, by adding a region with a duplicate startkey
       HRegionInfo hriDupe =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A"), Bytes.toBytes("A2"));
-      TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriDupe);
-      TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
-          .waitForAssignment(hriDupe);
+      TEST_UTIL.assignRegion(hriDupe);
+
       ServerName server = regionStates.getRegionServerOfRegion(hriDupe);
       TEST_UTIL.assertRegionOnServer(hriDupe, server, REGION_ONLINE_TIMEOUT);
 
@@ -176,10 +175,8 @@ public class TestHBaseFsckTwoRS extends BaseTestHBaseFsck {
       // Now let's mess it up, by adding a region with a duplicate startkey
       HRegionInfo hriDupe =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A"), Bytes.toBytes("B"));
+      TEST_UTIL.assignRegion(hriDupe);
 
-      TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriDupe);
-      TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
-          .waitForAssignment(hriDupe);
       ServerName server = regionStates.getRegionServerOfRegion(hriDupe);
       TEST_UTIL.assertRegionOnServer(hriDupe, server, REGION_ONLINE_TIMEOUT);
 
@@ -228,9 +225,8 @@ public class TestHBaseFsckTwoRS extends BaseTestHBaseFsck {
       // Mess it up by creating an overlap in the metadata
       HRegionInfo hriOverlap =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A2"), Bytes.toBytes("B"));
-      TEST_UTIL.getHBaseCluster().getMaster().assignRegion(hriOverlap);
-      TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager()
-          .waitForAssignment(hriOverlap);
+      TEST_UTIL.assignRegion(hriOverlap);
+
       ServerName server = regionStates.getRegionServerOfRegion(hriOverlap);
       TEST_UTIL.assertRegionOnServer(hriOverlap, server, REGION_ONLINE_TIMEOUT);
 
@@ -317,12 +313,11 @@ public class TestHBaseFsckTwoRS extends BaseTestHBaseFsck {
       HMaster master = cluster.getMaster();
       HRegionInfo hriOverlap1 =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("A"), Bytes.toBytes("AB"));
-      master.assignRegion(hriOverlap1);
-      master.getAssignmentManager().waitForAssignment(hriOverlap1);
+      TEST_UTIL.assignRegion(hriOverlap1);
+
       HRegionInfo hriOverlap2 =
           createRegion(tbl.getTableDescriptor(), Bytes.toBytes("AB"), Bytes.toBytes("B"));
-      master.assignRegion(hriOverlap2);
-      master.getAssignmentManager().waitForAssignment(hriOverlap2);
+      TEST_UTIL.assignRegion(hriOverlap2);
 
       HBaseFsck hbck = doFsck(conf, false);
       assertErrors(hbck, new HBaseFsck.ErrorReporter.ERROR_CODE[] {HBaseFsck.ErrorReporter.ERROR_CODE.DUPE_STARTKEYS,
@@ -458,7 +453,7 @@ public class TestHBaseFsckTwoRS extends BaseTestHBaseFsck {
     scanner.close();
     meta.close();
   }
-  
+
   /**
    * This creates and fixes a bad table with a missing region -- hole in meta and data present
but
    * .regioninfo missing (an orphan hdfs region)in the fs. At last we check every row was
present


Mime
View raw message