hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1056037 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Date Thu, 06 Jan 2011 19:46:27 GMT
Author: todd
Date: Thu Jan  6 19:46:26 2011
New Revision: 1056037

URL: http://svn.apache.org/viewvc?rev=1056037&view=rev
Log:
HBASE-3401. Region IPC operations should be high priority

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1056037&r1=1056036&r2=1056037&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Thu Jan  6 19:46:26 2011
@@ -783,6 +783,7 @@ Release 0.90.0 - Unreleased
    HBASE-3423  hbase-env.sh over-rides HBASE_OPTS incorrectly (Ted Dunning via
                Andrew Purtell)
    HBASE-3407  hbck should pause between fixing and re-checking state
+   HBASE-3401  Region IPC operations should be high priority
 
 
   IMPROVEMENTS

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java?rev=1056037&r1=1056036&r2=1056037&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java Thu Jan
 6 19:46:26 2011
@@ -520,7 +520,7 @@ public abstract class HBaseServer {
       } catch (InterruptedException ieo) {
         throw ieo;
       } catch (Exception e) {
-        LOG.debug(getName() + ": readAndProcess threw exception " + e + ". Count of bytes
read: " + count, e);
+        LOG.warn(getName() + ": readAndProcess threw exception " + e + ". Count of bytes
read: " + count, e);
         count = -1; //so that the (count < 0) block is executed
       }
       if (count < 0) {

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1056037&r1=1056036&r2=1056037&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Thu Jan  6 19:46:26 2011
@@ -21,9 +21,12 @@ package org.apache.hadoop.hbase.regionse
 
 import java.io.IOException;
 import java.lang.Thread.UncaughtExceptionHandler;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
 import java.lang.management.ManagementFactory;
 import java.lang.management.MemoryUsage;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
 import java.net.BindException;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
@@ -345,7 +348,26 @@ public class HRegionServer implements HR
   private static final int QOS_THRESHOLD = 10;  // the line between low and high qos
   private static final int HIGH_QOS = 100;
 
+  @Retention(RetentionPolicy.RUNTIME)
+  private @interface QosPriority {
+    int priority() default 0;
+  }
+
   class QosFunction implements Function<Writable,Integer> {
+    private final Map<String, Integer> annotatedQos;
+
+    public QosFunction() {
+      Map<String, Integer> qosMap = new HashMap<String, Integer>();
+      for (Method m : HRegionServer.class.getMethods()) {
+        QosPriority p = m.getAnnotation(QosPriority.class);
+        if (p != null) {
+          qosMap.put(m.getName(), p.priority());
+        }
+      }
+      
+      annotatedQos = qosMap;
+    }
+
     public boolean isMetaRegion(byte[] regionName) {
       HRegion region;
       try {
@@ -362,6 +384,11 @@ public class HRegionServer implements HR
 
       HBaseRPC.Invocation inv = (HBaseRPC.Invocation) from;
       String methodName = inv.getMethodName();
+      
+      Integer priorityByAnnotation = annotatedQos.get(methodName);
+      if (priorityByAnnotation != null) {
+        return priorityByAnnotation;
+      }
 
       // scanner methods...
       if (methodName.equals("next") || methodName.equals("close")) {
@@ -383,13 +410,6 @@ public class HRegionServer implements HR
             return HIGH_QOS;
           }
         }
-      } else if (methodName.equals("getHServerInfo")
-          || methodName.equals("getRegionsAssignment")
-          || methodName.equals("unlockRow")
-          || methodName.equals("getProtocolVersion")
-          || methodName.equals("getClosestRowBefore")) {
-        // LOG.debug("High priority method: " + methodName);
-        return HIGH_QOS;
       } else if (inv.getParameterClasses().length == 0) {
        // Just let it through.  This is getOnlineRegions, etc.
       } else if (inv.getParameterClasses()[0] == byte[].class) {
@@ -1571,6 +1591,7 @@ public class HRegionServer implements HR
   }
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public HRegionInfo getRegionInfo(final byte[] regionName)
   throws NotServingRegionException {
     requestCount.incrementAndGet();
@@ -1965,6 +1986,8 @@ public class HRegionServer implements HR
     return rl;
   }
 
+  @Override
+  @QosPriority(priority=HIGH_QOS)
   public void unlockRow(byte[] regionName, long lockId) throws IOException {
     checkOpen();
     NullPointerException npe = null;
@@ -2029,6 +2052,7 @@ public class HRegionServer implements HR
   // Region open/close direct RPCs
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public void openRegion(HRegionInfo region)
   throws RegionServerStoppedException {
     LOG.info("Received request to open region: " +
@@ -2044,6 +2068,7 @@ public class HRegionServer implements HR
   }
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public void openRegions(List<HRegionInfo> regions)
   throws RegionServerStoppedException {
     LOG.info("Received request to open " + regions.size() + " region(s)");
@@ -2051,12 +2076,14 @@ public class HRegionServer implements HR
   }
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public boolean closeRegion(HRegionInfo region)
   throws NotServingRegionException {
     return closeRegion(region, true);
   }
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public boolean closeRegion(HRegionInfo region, final boolean zk)
   throws NotServingRegionException {
     LOG.info("Received close region: " + region.getRegionNameAsString());
@@ -2097,6 +2124,7 @@ public class HRegionServer implements HR
   // Manual remote region administration RPCs
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public void flushRegion(HRegionInfo regionInfo)
       throws NotServingRegionException, IOException {
     LOG.info("Flushing " + regionInfo.getRegionNameAsString());
@@ -2105,6 +2133,7 @@ public class HRegionServer implements HR
   }
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public void splitRegion(HRegionInfo regionInfo)
       throws NotServingRegionException, IOException {
     HRegion region = getRegion(regionInfo.getRegionName());
@@ -2118,6 +2147,7 @@ public class HRegionServer implements HR
   }
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public void compactRegion(HRegionInfo regionInfo, boolean major)
       throws NotServingRegionException, IOException {
     HRegion region = getRegion(regionInfo.getRegionName());
@@ -2157,6 +2187,7 @@ public class HRegionServer implements HR
   }
 
   @Override
+  @QosPriority(priority=HIGH_QOS)
   public List<HRegionInfo> getOnlineRegions() {
     List<HRegionInfo> list = new ArrayList<HRegionInfo>();
     synchronized(this.onlineRegions) {
@@ -2357,6 +2388,8 @@ public class HRegionServer implements HR
     return regionsToCheck;
   }
 
+  @Override
+  @QosPriority(priority=HIGH_QOS)
   public long getProtocolVersion(final String protocol, final long clientVersion)
       throws IOException {
     if (protocol.equals(HRegionInterface.class.getName())) {
@@ -2470,6 +2503,8 @@ public class HRegionServer implements HR
   }
 
   /** {@inheritDoc} */
+  @Override
+  @QosPriority(priority=HIGH_QOS)
   public HServerInfo getHServerInfo() throws IOException {
     return serverInfo;
   }



Mime
View raw message