commit a8c78f1845af01fe11d2687650f9a8be821768ce Author: Todd Lipcon Date: Thu Dec 30 13:35:28 2010 -0800 HBASE-3401. Region IPC operations should be high priority diff --git src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java index 867a059..9c37997 100644 --- src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java +++ src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java @@ -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) { diff --git src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java index 5da41be..826982f 100644 --- src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java +++ src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java @@ -49,6 +49,10 @@ import org.apache.hadoop.ipc.RemoteException; * number in HBaseRPCProtocolVersion */ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Abortable { + public static final int NORMAL_QOS = 0; + public static final int QOS_THRESHOLD = 10; // the line between low and high qos + public static final int HIGH_QOS = 100; + /** * Get metainfo about an HRegion * @@ -58,6 +62,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @throws ConnectException * @throws IOException This can manifest as an Hadoop ipc {@link RemoteException} */ + @QosPriority(priority=HIGH_QOS) public HRegionInfo getRegionInfo(final byte [] regionName) throws NotServingRegionException, ConnectException, IOException; @@ -71,6 +76,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @return map of values * @throws IOException e */ + @QosPriority(priority=HIGH_QOS) public Result getClosestRowBefore(final byte [] regionName, final byte [] row, final byte [] family) throws IOException; @@ -267,6 +273,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @param lockId the lock id returned by lockRow * @throws IOException e */ + @QosPriority(priority=HIGH_QOS) public void unlockRow(final byte [] regionName, final long lockId) throws IOException; @@ -275,6 +282,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @return All regions online on this region server * @throws IOException e */ + @QosPriority(priority=HIGH_QOS) public List getOnlineRegions(); /** @@ -282,6 +290,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @return The HSI * @throws IOException e */ + @QosPriority(priority=HIGH_QOS) public HServerInfo getHServerInfo() throws IOException; /** @@ -314,6 +323,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @param region region to open * @throws IOException */ + @QosPriority(priority=HIGH_QOS) public void openRegion(final HRegionInfo region) throws IOException; /** @@ -321,6 +331,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @param regions regions to open * @throws IOException */ + @QosPriority(priority=HIGH_QOS) public void openRegions(final List regions) throws IOException; /** @@ -329,6 +340,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @return true if closing region, false if not * @throws IOException */ + @QosPriority(priority=HIGH_QOS) public boolean closeRegion(final HRegionInfo region) throws IOException; @@ -340,6 +352,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @return true if closing region, false if not * @throws IOException */ + @QosPriority(priority=HIGH_QOS) public boolean closeRegion(final HRegionInfo region, final boolean zk) throws IOException; @@ -353,6 +366,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @throws NotServingRegionException * @throws IOException */ + @QosPriority(priority=HIGH_QOS) void flushRegion(HRegionInfo regionInfo) throws NotServingRegionException, IOException; @@ -366,6 +380,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @throws NotServingRegionException * @throws IOException */ + @QosPriority(priority=HIGH_QOS) void splitRegion(HRegionInfo regionInfo) throws NotServingRegionException, IOException; @@ -378,6 +393,7 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @throws NotServingRegionException * @throws IOException */ + @QosPriority(priority=HIGH_QOS) void compactRegion(HRegionInfo regionInfo, boolean major) throws NotServingRegionException, IOException; @@ -390,5 +406,6 @@ public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Ab * @param entries entries to replicate * @throws IOException */ + @QosPriority(priority=HIGH_QOS) public void replicateLogEntries(HLog.Entry[] entries) throws IOException; } diff --git src/main/java/org/apache/hadoop/hbase/ipc/QosPriority.java src/main/java/org/apache/hadoop/hbase/ipc/QosPriority.java new file mode 100644 index 0000000..05cb4d3 --- /dev/null +++ src/main/java/org/apache/hadoop/hbase/ipc/QosPriority.java @@ -0,0 +1,28 @@ +/** + * Copyright 2010 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.ipc; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface QosPriority { + int priority() default 0; +} diff --git src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index d7147b5..8361a06 100644 --- src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -24,6 +24,7 @@ import java.lang.Thread.UncaughtExceptionHandler; 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; @@ -101,6 +102,7 @@ import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion; import org.apache.hadoop.hbase.ipc.HBaseServer; import org.apache.hadoop.hbase.ipc.HMasterRegionInterface; import org.apache.hadoop.hbase.ipc.HRegionInterface; +import org.apache.hadoop.hbase.ipc.QosPriority; import org.apache.hadoop.hbase.ipc.ServerNotRunningException; import org.apache.hadoop.hbase.regionserver.Leases.LeaseStillHeldException; import org.apache.hadoop.hbase.regionserver.handler.CloseMetaHandler; @@ -340,11 +342,21 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, } } - private static final int NORMAL_QOS = 0; - private static final int QOS_THRESHOLD = 10; // the line between low and high qos - private static final int HIGH_QOS = 100; - 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 { @@ -361,6 +373,11 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, 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")) { @@ -382,12 +399,8 @@ 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); + } else if (methodName.equals("getProtocolVersion")) { + // Can't annotate this because it's in Hadoop IPC return HIGH_QOS; } else if (inv.getParameterClasses().length == 0) { // Just let it through. This is getOnlineRegions, etc.