hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1225312 - in /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase: HConstants.java master/BaseScanner.java master/PreferredAssignmentManager.java
Date Wed, 28 Dec 2011 19:37:22 GMT
Author: nspiegelberg
Date: Wed Dec 28 19:37:21 2011
New Revision: 1225312

URL: http://svn.apache.org/viewvc?rev=1225312&view=rev
Log:
BaseScanner looks for favorednodes hints in META

Summary:
** 89 master only **
The favored nodes used for explicit placement of regions are persisted
as a column in the .META. table. This change reads those columns in the
base scanner and updates the persistent preferred assignments in the
RegionManager as necessary.

Test Plan:
manually enter hints into META and verify that they are passed to the
region manager by inspecting log output

Reviewers: kranganathan, kannan

Reviewed By: kranganathan

CC: hbase-eng@lists, kranganathan

Differential Revision: 375699

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/BaseScanner.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/PreferredAssignmentManager.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1225312&r1=1225311&r2=1225312&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java Wed Dec 28
19:37:21 2011
@@ -255,6 +255,9 @@ public final class HConstants {
   /** The upper-half split region column qualifier */
   public static final byte [] SPLITB_QUALIFIER = Bytes.toBytes("splitB");
 
+  /** The favored nodes column qualifier*/
+  public static final byte [] FAVOREDNODES_QUALIFIER = Bytes.toBytes("favorednodes");
+
   // Other constants
 
   /**

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/BaseScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/BaseScanner.java?rev=1225312&r1=1225311&r2=1225312&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/BaseScanner.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/BaseScanner.java Wed
Dec 28 19:37:21 2011
@@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.Chore;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.UnknownScannerException;
@@ -197,6 +198,20 @@ abstract class BaseScanner extends Chore
           splitParents.put(info, values);
         }
         rows += 1;
+
+        byte[] favoredNodes = values.getValue(HConstants.CATALOG_FAMILY,
+            HConstants.FAVOREDNODES_QUALIFIER);
+        if (favoredNodes != null) {
+          List<HServerAddress> addresses = new ArrayList<HServerAddress>();
+          for (String address : new String(favoredNodes).split(",")) {
+            addresses.add(new HServerAddress(address));
+          }
+          this.master.getRegionManager().assignmentManager
+              .addPersistentAssignment(info, addresses);
+        } else {
+          this.master.getRegionManager().assignmentManager
+              .removePersistentAssignment(info);
+        }
       }
       if (rootRegion) {
         this.master.getRegionManager().setNumMetaRegions(rows);

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/PreferredAssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/PreferredAssignmentManager.java?rev=1225312&r1=1225311&r2=1225312&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/PreferredAssignmentManager.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/PreferredAssignmentManager.java
Wed Dec 28 19:37:21 2011
@@ -95,11 +95,33 @@ public class PreferredAssignmentManager 
     persistentAssignments.put(region, servers);
     if (servers != null && !servers.equals(oldServers)) {
       putTransientFromPersistent(region);
+      if (LOG.isDebugEnabled()) {
+        StringBuffer sb = new StringBuffer();
+        for (HServerAddress server : servers) {
+          sb.append(server.getHostname() + ":" + server.getPort() + ",");
+          if (master.getServerManager().getHServerInfo(server) == null) {
+            LOG.info("Found persistent assignment for region " +
+                region.getRegionNameAsString() + " to unknown server " +
+                server);
+          }
+        }
+        LOG.debug("Added persistent assignment for region " +
+            region.getRegionNameAsString() + " to " + sb.toString());
+      }
     }
   }
 
   public List<HServerAddress> removePersistentAssignment(HRegionInfo region) {
-    return persistentAssignments.remove(region);
+    List<HServerAddress> servers = persistentAssignments.remove(region);
+    if (LOG.isDebugEnabled() && servers != null) {
+      StringBuffer sb = new StringBuffer();
+      for (HServerAddress server : servers) {
+        sb.append(server.getHostname() + ":" + server.getPort() + ",");
+      }
+      LOG.debug("Removed persistent assignment for region " +
+          region.getRegionNameAsString() + " to " + sb.toString());
+    }
+    return servers;
   }
 
   public void addTransientAssignment(HServerAddress server,



Mime
View raw message