diff --git a/CHANGES.txt b/CHANGES.txt index 0e5079b4695..12d4e26b28c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -821,6 +821,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 diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java index 2ab7ae7fc57..e40f4d1c545 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java @@ -532,7 +532,7 @@ public abstract class HBaseServer implements RpcServer { } 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) { diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 21f80708d00..2f340d4d3c8 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -21,9 +21,12 @@ package org.apache.hadoop.hbase.regionserver; 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; @@ -348,7 +351,26 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, 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 { + private final Map annotatedQos; + + public QosFunction() { + Map qosMap = new HashMap(); + 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 { @@ -365,6 +387,11 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, Invocation inv = (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")) { @@ -386,13 +413,6 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, 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) { @@ -1575,6 +1595,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } @Override + @QosPriority(priority=HIGH_QOS) public HRegionInfo getRegionInfo(final byte[] regionName) throws NotServingRegionException { requestCount.incrementAndGet(); @@ -2016,6 +2037,8 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, return rl; } + @Override + @QosPriority(priority=HIGH_QOS) public void unlockRow(byte[] regionName, long lockId) throws IOException { checkOpen(); NullPointerException npe = null; @@ -2080,6 +2103,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, // Region open/close direct RPCs @Override + @QosPriority(priority=HIGH_QOS) public void openRegion(HRegionInfo region) throws RegionServerStoppedException { LOG.info("Received request to open region: " + @@ -2095,6 +2119,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } @Override + @QosPriority(priority=HIGH_QOS) public void openRegions(List regions) throws RegionServerStoppedException { LOG.info("Received request to open " + regions.size() + " region(s)"); @@ -2102,12 +2127,14 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } @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()); @@ -2148,6 +2175,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, // Manual remote region administration RPCs @Override + @QosPriority(priority=HIGH_QOS) public void flushRegion(HRegionInfo regionInfo) throws NotServingRegionException, IOException { LOG.info("Flushing " + regionInfo.getRegionNameAsString()); @@ -2156,6 +2184,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } @Override + @QosPriority(priority=HIGH_QOS) public void splitRegion(HRegionInfo regionInfo) throws NotServingRegionException, IOException { splitRegion(regionInfo, null); @@ -2175,6 +2204,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } @Override + @QosPriority(priority=HIGH_QOS) public void compactRegion(HRegionInfo regionInfo, boolean major) throws NotServingRegionException, IOException { HRegion region = getRegion(regionInfo.getRegionName()); @@ -2214,6 +2244,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } @Override + @QosPriority(priority=HIGH_QOS) public List getOnlineRegions() { List list = new ArrayList(); synchronized(this.onlineRegions) { @@ -2414,6 +2445,8 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, return regionsToCheck; } + @Override + @QosPriority(priority=HIGH_QOS) public long getProtocolVersion(final String protocol, final long clientVersion) throws IOException { if (protocol.equals(HRegionInterface.class.getName())) { @@ -2549,6 +2582,8 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } /** {@inheritDoc} */ + @Override + @QosPriority(priority=HIGH_QOS) public HServerInfo getHServerInfo() throws IOException { return serverInfo; }