HBASE-3401. Region IPC operations should be high priority

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1056041 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2011-01-06 19:49:28 +00:00
parent 857d41472f
commit 7a678034af
3 changed files with 44 additions and 8 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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<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 {
@ -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<HRegionInfo> 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<HRegionInfo> getOnlineRegions() {
List<HRegionInfo> list = new ArrayList<HRegionInfo>();
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;
}