hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1584192 - in /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master: AssignmentDomain.java HMaster.java RegionPlacement.java
Date Wed, 02 Apr 2014 21:11:01 GMT
Author: liyin
Date: Wed Apr  2 21:11:01 2014
New Revision: 1584192

URL: http://svn.apache.org/r1584192
Log:
[HBASE-10425] Hook RegionPlacement up to stored HTableDesciptor serverSet.

Author: elliott

Summary: RegionPlacement runs will now take HTD server set into account when assigning regions.

Test Plan:
Deployed to HBASEDEV038-ASH3. Created a table pinned on three different servers. Ran RegionPlacement
several times. The pinned table stayed on the three chosen servers.
Then I created 5 new tables and saw that creation was still successful and they weren't pinned
to any servers. Then I ran RegionPlacement again and saw that the pinned tables were still
on the selected servers.

Reviewers: adela, liyintang

Reviewed By: adela

CC: hbase-eng@

Differential Revision: https://phabricator.fb.com/D1250475

Task ID: 4039274

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentDomain.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentDomain.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentDomain.java?rev=1584192&r1=1584191&r2=1584192&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentDomain.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/AssignmentDomain.java
Wed Apr  2 21:11:01 2014
@@ -21,17 +21,22 @@ package org.apache.hadoop.hbase.master;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
 import java.util.Set;
 
+import com.google.common.collect.Lists;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HTableDescriptor;
 
 public class AssignmentDomain {
   protected static final Log LOG =
@@ -49,6 +54,27 @@ public class AssignmentDomain {
     rackManager = new RackManager(conf);
     random = new Random();
   }
+
+  public AssignmentDomain(Configuration conf, HTableDescriptor htd,
+      Collection<HServerAddress> liveServers) {
+    this(conf);
+
+    List<HServerAddress> servers = null;
+    // If the table is pinned to servers then respect that.
+    if (htd.getServers() != null) {
+      Set<HServerAddress> hServerAddresses = new HashSet<>(htd.getServers());
+      hServerAddresses.retainAll(liveServers);
+      servers = Lists.newArrayList(hServerAddresses);
+    } else {
+      // Otherwise use all of the live servers
+      servers = Lists.newArrayList(liveServers);
+    }
+
+    // Shuffle the server list based on the tableName
+    Random random = new Random(htd.getNameAsString().hashCode());
+    Collections.shuffle(servers, random);
+    this.addServers(servers);
+  }
   
   /**
    * Set the random seed

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1584192&r1=1584191&r2=1584192&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Wed Apr
 2 21:11:01 2014
@@ -1581,24 +1581,7 @@ public class HMaster extends HasThread i
    * @return the assignment domain for the table.
    */
   private AssignmentDomain getAssignmentDomain(HTableDescriptor htd) {
-    // Get all the online region servers
-    List<HServerAddress> servers = null;
-
-    if (htd.getServers() == null) {
-      servers = this.serverManager.getOnlineRegionServerList();
-    } else {
-      Set<HServerAddress> hServerAddresses = new HashSet<>(htd.getServers());
-      hServerAddresses.retainAll(this.serverManager.getOnlineRegionServerList());
-      servers = Lists.newArrayList(hServerAddresses);
-    }
-
-    // Shuffle the server list based on the tableName
-    Random random = new Random(htd.getNameAsString().hashCode());
-    Collections.shuffle(servers, random);
-    // Add the shuffled server list into the assignment domain
-    AssignmentDomain domain = new AssignmentDomain(this.conf);
-    domain.addServers(servers);
-    return domain;
+    return new AssignmentDomain(this.conf, htd, this.serverManager.getOnlineRegionServerList());
   }
 
   @Override

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java?rev=1584192&r1=1584191&r2=1584192&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/RegionPlacement.java
Wed Apr  2 21:11:01 2014
@@ -50,6 +50,7 @@ import org.apache.hadoop.hbase.HBaseConf
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HTable;
@@ -795,6 +796,8 @@ public class RegionPlacement implements 
       // Get the all the regions for the current table
       List<HRegionInfo> regions =
         assignmentSnapshot.getTableToRegionMap().get(tableName);
+
+      HTableDescriptor tableDescriptor = regions.get(0).getTableDesc();
       int numRegions = regions.size();
 
       // Get the current assignment map
@@ -802,7 +805,8 @@ public class RegionPlacement implements 
         assignmentSnapshot.getRegionToRegionServerMap();
 
       // Get the assignment domain
-      AssignmentDomain domain = assignmentSnapshot.getGlobalAssignmentDomain();
+      AssignmentDomain domain = new AssignmentDomain(conf, tableDescriptor,
+          assignmentSnapshot.getGlobalAssignmentDomain().getAllServers());
 
       // Get the all the region servers
       List<HServerAddress> servers = new ArrayList<HServerAddress>();



Mime
View raw message