HBASE-16972 Log more details for Scan#next request when responseTooSlow

This commit is contained in:
Yu Li 2016-11-02 14:33:44 +08:00
parent 961b952171
commit 514add0086
3 changed files with 38 additions and 0 deletions

View File

@ -94,6 +94,7 @@ import org.apache.hadoop.hbase.io.BoundedByteBufferPool;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
import org.apache.hadoop.hbase.monitoring.TaskMonitor;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.VersionInfo;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.CellBlockMeta;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ConnectionHeader;
@ -102,6 +103,7 @@ import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RequestHeader;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.ResponseHeader;
import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.UserInformation;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
import org.apache.hadoop.hbase.security.AccessDeniedException;
import org.apache.hadoop.hbase.security.AuthMethod;
import org.apache.hadoop.hbase.security.HBasePolicyProvider;
@ -303,6 +305,12 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
private volatile boolean allowFallbackToSimpleAuth;
/**
* Used to get details for scan with a scanner_id<br/>
* TODO try to figure out a better way and remove reference from regionserver package later.
*/
private RSRpcServices rsRpcServices;
/**
* Datastructure that holds all necessary to a method invocation and then afterward, carries
* the result.
@ -2413,6 +2421,16 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
responseInfo.put("method", methodName);
responseInfo.put("call", call);
responseInfo.put("param", ProtobufUtil.getShortTextFormat(param));
if (param instanceof ClientProtos.ScanRequest && rsRpcServices != null) {
ClientProtos.ScanRequest request = ((ClientProtos.ScanRequest) param);
if (request.hasScannerId()) {
long scannerId = request.getScannerId();
String scanDetails = rsRpcServices.getScanDetailsWithId(scannerId);
if (scanDetails != null) {
responseInfo.put("scandetails", scanDetails);
}
}
}
LOG.warn("(response" + tag + "): " + MAPPER.writeValueAsString(responseInfo));
}
@ -2737,4 +2755,9 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver {
public RpcScheduler getScheduler() {
return scheduler;
}
@Override
public void setRsRpcServices(RSRpcServices rsRpcServices) {
this.rsRpcServices = rsRpcServices;
}
}

View File

@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.security.authorize.PolicyProvider;
@ -83,4 +84,6 @@ public interface RpcServerInterface {
void refreshAuthManager(PolicyProvider pp);
RpcScheduler getScheduler();
void setRsRpcServices(RSRpcServices rsRpcServices);
}

View File

@ -984,6 +984,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
bindAddress, // use final bindAddress for this server.
rs.conf,
rpcSchedulerFactory.create(rs.conf, this, rs));
rpcServer.setRsRpcServices(this);
} catch (BindException be) {
String configName = (this instanceof MasterRpcServices) ? HConstants.MASTER_PORT :
HConstants.REGIONSERVER_PORT;
@ -1049,6 +1050,17 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
return null;
}
public String getScanDetailsWithId(long scannerId) {
RegionScanner scanner = getScanner(scannerId);
if (scanner == null) {
return null;
}
StringBuilder builder = new StringBuilder();
builder.append("table: ").append(scanner.getRegionInfo().getTable().getNameAsString());
builder.append(" region: ").append(scanner.getRegionInfo().getRegionNameAsString());
return builder.toString();
}
/**
* Get the vtime associated with the scanner.
* Currently the vtime is the number of "next" calls.