From 7ead8ee93bf185fbf43947b95b93252489f12f63 Mon Sep 17 00:00:00 2001 From: Phil Yang Date: Mon, 10 Oct 2016 18:38:50 +0800 Subject: [PATCH] HBASE-16505 Pass deadline to HRegion operations --- .../src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java | 6 +++++- .../src/main/java/org/apache/hadoop/hbase/ipc/RpcCallContext.java | 7 +++++++ .../src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java index 5e91beb..c1dbf8e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; +import org.apache.hadoop.hbase.exceptions.TimeoutIOException; import org.apache.hadoop.hbase.ipc.RpcServer.Call; import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler; import org.apache.hadoop.hbase.util.Pair; @@ -121,7 +122,10 @@ public class CallRunner { } // make the call resultPair = this.rpcServer.call(call.service, call.md, call.param, call.cellScanner, - call.timestamp, this.status, call.startTime, call.timeout); + call.timestamp, this.status, call.startTime, call.timeout); + } catch (TimeoutIOException e){ + RpcServer.LOG.info("Can not complete this request in time, drop it: " + call); + return; } catch (Throwable e) { RpcServer.LOG.debug(Thread.currentThread().getName() + ": " + call.toShortString(), e); errorThrowable = e; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCallContext.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCallContext.java index b08afc2..508b1e8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCallContext.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCallContext.java @@ -85,4 +85,11 @@ public interface RpcCallContext { long getResponseBlockSize(); void incrementResponseBlockSize(long blockSize); + + /** + * Return the deadline of this call. If we can not complete this call in time, we can throw a + * TimeoutIOException and RPCServer will drop it. + * @return The system timestamp of deadline. + */ + long getDeadline(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java index f7cc85f..2c127ad 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java @@ -407,7 +407,8 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { return "callId: " + this.id + " service: " + serviceName + " methodName: " + ((this.md != null) ? this.md.getName() : "n/a") + " size: " + StringUtils.TraditionalBinaryPrefix.long2String(this.size, "", 1) + - " connection: " + connection.toString(); + " connection: " + connection.toString() + + " deadline: " + deadline; } String toTraceString() { @@ -573,6 +574,11 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { responseBlockSize += blockSize; } + @Override + public long getDeadline() { + return deadline; + } + public synchronized void sendResponseIfReady() throws IOException { // set param null to reduce memory pressure this.param = null; -- 2.8.4 (Apple Git-73)