HBASE-20826 Truncate really long RpcServer warnings unless TRACE is on

Signed-off-by: zhangduo <zhangduo@apache.org>
Signed-off-by: Ted Yu <tyu@apache.org>
Signed-off-by: Michael Stack <stack@apache.org>
This commit is contained in:
Josh Elser 2018-06-29 15:19:59 -04:00 committed by zhangduo
parent cfdabe9267
commit 13e4578be8
1 changed files with 8 additions and 1 deletions

View File

@ -496,7 +496,14 @@ public abstract class RpcServer implements RpcServerInterface,
responseInfo.put("class", server == null? "": server.getClass().getSimpleName());
responseInfo.put("method", methodName);
responseInfo.put("call", call);
responseInfo.put("param", ProtobufUtil.getShortTextFormat(param));
// The params could be really big, make sure they don't kill us at WARN
String stringifiedParam = ProtobufUtil.getShortTextFormat(param);
if (stringifiedParam.length() > 150) {
// Truncate to 1000 chars if TRACE is on, else to 150 chars
stringifiedParam = stringifiedParam.subSequence(
0, LOG.isTraceEnabled() ? 1000 : 150) + " <TRUNCATED>";
}
responseInfo.put("param", stringifiedParam);
if (param instanceof ClientProtos.ScanRequest && rsRpcServices != null) {
ClientProtos.ScanRequest request = ((ClientProtos.ScanRequest) param);
if (request.hasScannerId()) {