Author: liyin Date: Thu May 16 19:20:10 2013 New Revision: 1483519 URL: http://svn.apache.org/r1483519 Log: [HBASE-8114][89-fb] Adding time spent before RPC interrupted logging
Author: adela Summary: When the client closes the connection, we stop the execution of the get RPC. We should also print how much time we spent executing before we interrupted. Test Plan: push on one machine on tsh25 Reviewers: liyintang, rshroff, manukranthk Reviewed By: rshroff CC: hbase-eng@ Differential Revision: https://phabricator.fb.com/D801065 Added: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/CallInterruptedException.java Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java Added: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/CallInterruptedException.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/CallInterruptedException.java?rev=1483519&view=auto ============================================================================== --- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/CallInterruptedException.java (added) +++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/CallInterruptedException.java Thu May 16 19:20:10 2013 @@ -0,0 +1,36 @@ +/** + * Copyright 2013 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.io.IOException; + +/** + * This exception should be thrown in a situation when the client has closed the + * connection to the server, and the execution of the RPC has been interrupted + * + */ +public class CallInterruptedException extends IOException { + + private static final long serialVersionUID = 7379917857089798358L; + + public CallInterruptedException(String msg) { + super(msg); + } +} Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java?rev=1483519&r1=1483518&r2=1483519&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java (original) +++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java Thu May 16 19:20:10 2013 @@ -557,8 +557,11 @@ public class HBaseRPC { @Override public Writable call(Writable param, long receivedTime, MonitoredRPCHandler status) throws IOException { + long startTime = 0L; + Invocation call = null; + int qTime = -1; try { - Invocation call = (Invocation)param; + call = (Invocation)param; if(call.getMethodName() == null) { throw new IOException("Could not find requested method, the usual " + "cause is a version mismatch between client and server."); @@ -574,10 +577,10 @@ public class HBaseRPC { status.setRPC(call.getMethodName(), call.getParameters(), receivedTime, method); status.setRPCPacket(param); status.resume("Servicing call"); - long startTime = System.currentTimeMillis(); + startTime = System.currentTimeMillis(); + qTime = (int) (startTime - receivedTime); Object value = method.invoke(instance, call.getParameters()); int processingTime = (int) (System.currentTimeMillis() - startTime); - int qTime = (int) (startTime - receivedTime); if (LOG.isTraceEnabled()) { LOG.trace("Served: " + call.getMethodName() + " queueTime= " + qTime + @@ -632,6 +635,11 @@ public class HBaseRPC { } catch (InvocationTargetException e) { Throwable target = e.getTargetException(); if (target instanceof IOException) { + if (target instanceof CallInterruptedException) { + int processingTime = (int) (System.currentTimeMillis() - startTime); + // put -1 for response size since we are not going to return a response + logResponse(call, "INTERRUPTED", status.getClient(), startTime, processingTime, qTime, -1); + } throw (IOException) target; } IOException ioe = new IOException(target.toString()); Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java?rev=1483519&r1=1483518&r2=1483519&view=diff ============================================================================== --- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java (original) +++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/RegionScanner.java Thu May 16 19:20:10 2013 @@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.client.Re import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.filter.Filter; import org.apache.hadoop.hbase.filter.IncompatibleFilterException; +import org.apache.hadoop.hbase.ipc.CallInterruptedException; import org.apache.hadoop.hbase.util.Bytes; /** @@ -357,7 +358,7 @@ public class RegionScanner implements In if (!prefetch && HRegionServer.isCurrentConnectionClosed()) { HRegion.incrNumericMetric(HConstants.SERVER_INTERRUPTED_CALLS_KEY, 1); LOG.error(HConstants.CLIENT_SOCKED_CLOSED_EXC_MSG); - throw new IOException(HConstants.CLIENT_SOCKED_CLOSED_EXC_MSG); + throw new CallInterruptedException(HConstants.CLIENT_SOCKED_CLOSED_EXC_MSG); } byte [] currentRow = peekRow(); if (isStopRow(currentRow)) { @@ -379,7 +380,7 @@ public class RegionScanner implements In HRegion.incrNumericMetric(HConstants.SERVER_INTERRUPTED_CALLS_KEY, 1); LOG.error(HConstants.CLIENT_SOCKED_CLOSED_EXC_MSG); - throw new IOException(HConstants.CLIENT_SOCKED_CLOSED_EXC_MSG); + throw new CallInterruptedException(HConstants.CLIENT_SOCKED_CLOSED_EXC_MSG); } this.storeHeap.next(results, limit - results.size(), metric, kvContext); if (limit > 0 && results.size() == limit) {
