hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1355532 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/master/AssignmentManager.java test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
Date Fri, 29 Jun 2012 19:42:54 GMT
Author: tedyu
Date: Fri Jun 29 19:42:53 2012
New Revision: 1355532

URL: http://svn.apache.org/viewvc?rev=1355532&view=rev
Log:
HBASE-6281 Assignment need not be called for disabling table regions during clean cluster
start up (Rajesh)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1355532&r1=1355531&r2=1355532&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Fri Jun 29 19:42:53 2012
@@ -2385,11 +2385,16 @@ public class AssignmentManager extends Z
     List<ServerName> destServers = serverManager.createDestinationServersList();
 
     // If there are no servers we need not proceed with region assignment.
-    if(destServers.isEmpty()) return;
+    if (destServers.isEmpty()) return;
 
+    // Skip assignment for regions of tables in DISABLING state because during clean cluster
startup
+    // no RS is alive and regions map also doesn't have any information about the regions.
+    // See HBASE-6281. 
+    Set<String> disablingAndDisabledTables = new HashSet<String>(this.disablingTables);
+    disablingAndDisabledTables.addAll(this.zkTable.getDisabledTables());
     // Scan META for all user regions, skipping any disabled tables
-    Map<HRegionInfo, ServerName> allRegions =
-      MetaReader.fullScan(catalogTracker, this.zkTable.getDisabledTables(), true);
+    Map<HRegionInfo, ServerName> allRegions = MetaReader.fullScan(catalogTracker,
+        disablingAndDisabledTables, true);
     if (allRegions == null || allRegions.isEmpty()) return;
 
     // Determine what type of assignment to do on startup

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java?rev=1355532&r1=1355531&r2=1355532&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
Fri Jun 29 19:42:53 2012
@@ -18,6 +18,7 @@
 package org.apache.hadoop.hbase.master;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -762,6 +763,13 @@ public class TestAssignmentManager {
       this.gate.set(true);
       return randomServerName;
     }
+    
+    @Override
+    public Map<ServerName, List<HRegionInfo>> retainAssignment(
+        Map<HRegionInfo, ServerName> regions, List<ServerName> servers) {
+      this.gate.set(true);
+      return super.retainAssignment(regions, servers);
+    }
   }
   
   /**
@@ -793,6 +801,50 @@ public class TestAssignmentManager {
     assertTrue("The region should be assigned immediately.", null != am.regionPlans.get(REGIONINFO
         .getEncodedName()));
   }
+  
+  /**
+   * Test verifies whether assignment is skipped for regions of tables in DISABLING state
during
+   * clean cluster startup. See HBASE-6281.
+   * 
+   * @throws KeeperException
+   * @throws IOException
+   * @throws Exception
+   */
+  @Test
+  public void testDisablingTableRegionsAssignmentDuringCleanClusterStartup()
+      throws KeeperException, IOException, Exception {
+    this.server.getConfiguration().setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
+        MockedLoadBalancer.class, LoadBalancer.class);
+    Mockito.when(this.serverManager.getOnlineServers()).thenReturn(
+        new HashMap<ServerName, ServerLoad>(0));
+    List<ServerName> destServers = new ArrayList<ServerName>(1);
+    destServers.add(SERVERNAME_A);
+    Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
+    // To avoid cast exception in DisableTableHandler process.
+    Server server = new HMaster(HTU.getConfiguration());
+    AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
+        this.serverManager);
+    AtomicBoolean gate = new AtomicBoolean(false);
+    if (balancer instanceof MockedLoadBalancer) {
+      ((MockedLoadBalancer) balancer).setGateVariable(gate);
+    }
+    try{
+      // set table in disabling state.
+      am.getZKTable().setDisablingTable(REGIONINFO.getTableNameAsString());
+      am.joinCluster();
+      // should not call retainAssignment if we get empty regions in assignAllUserRegions.
+      assertFalse(
+          "Assign should not be invoked for disabling table regions during clean cluster
startup.",
+          gate.get());
+      // need to change table state from disabling to disabled.
+      assertTrue("Table should be disabled.",
+          am.getZKTable().isDisabledTable(REGIONINFO.getTableNameAsString()));      
+    } finally {
+      am.getZKTable().setEnabledTable(REGIONINFO.getTableNameAsString());
+      am.shutdown();
+    }
+  }
+
   /**
    * Creates a new ephemeral node in the SPLITTING state for the specified region.
    * Create it ephemeral in case regionserver dies mid-split.
@@ -866,7 +918,7 @@ public class TestAssignmentManager {
     // Get a meta row result that has region up on SERVERNAME_A for REGIONINFO
     Result r = Mocking.getMetaTableRowResult(REGIONINFO, SERVERNAME_A);
     ScanResponse.Builder builder = ScanResponse.newBuilder();
-    builder.setMoreResults(false);
+    builder.setMoreResults(true);
     builder.addResult(ProtobufUtil.toResult(r));
     Mockito.when(ri.scan(
       (RpcController)Mockito.any(), (ScanRequest)Mockito.any())).
@@ -946,6 +998,7 @@ public class TestAssignmentManager {
     {
       assignInvoked = true;
     };
+    
     /** reset the watcher */
     void setWatcher(ZooKeeperWatcher watcher) {
       this.watcher = watcher;



Mime
View raw message