From 3f319bef8d53bb0c50639c87f57be221696b9129 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sat, 23 Jun 2018 19:22:33 -0700 Subject: [PATCH] HBASE-20780 ServerRpcConnection logging cleanup Get rid of one of the logging lines in ServerRpcConnection by amalgamating all into one new-style log line. --- .../hadoop/hbase/ipc/ServerRpcConnection.java | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java index 17bb362b493..cff917f89f5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java @@ -342,10 +342,8 @@ abstract class ServerRpcConnection implements Closeable { public void saslReadAndProcess(ByteBuff saslToken) throws IOException, InterruptedException { if (saslContextEstablished) { - if (RpcServer.LOG.isTraceEnabled()) - RpcServer.LOG.trace("Have read input token of size " + saslToken.limit() - + " for processing by saslServer.unwrap()"); - + RpcServer.LOG.trace("Read input token of size={} for processing by saslServer.unwrap()", + saslToken.limit()); if (!useWrap) { processOneRpc(saslToken); } else { @@ -365,17 +363,13 @@ abstract class ServerRpcConnection implements Closeable { if (saslServer == null) { saslServer = new HBaseSaslRpcServer(authMethod, rpcServer.saslProps, rpcServer.secretManager); - if (RpcServer.LOG.isDebugEnabled()) { - RpcServer.LOG - .debug("Created SASL server with mechanism = " + authMethod.getMechanismName()); - } + RpcServer.LOG.debug("Created SASL server with mechanism={}", + authMethod.getMechanismName()); } - if (RpcServer.LOG.isDebugEnabled()) { - RpcServer.LOG.debug("Have read input token of size " + saslToken.limit() - + " for processing by saslServer.evaluateResponse()"); - } - replyToken = saslServer - .evaluateResponse(saslToken.hasArray() ? saslToken.array() : saslToken.toBytes()); + RpcServer.LOG.debug("Read input token of size={} for processing by saslServer." + + "evaluateResponse()", saslToken.limit()); + replyToken = saslServer.evaluateResponse(saslToken.hasArray()? + saslToken.array() : saslToken.toBytes()); } catch (IOException e) { IOException sendToClient = e; Throwable cause = e; @@ -500,8 +494,8 @@ abstract class ServerRpcConnection implements Closeable { if (buf.hasArray()) { this.connectionHeader = ConnectionHeader.parseFrom(buf.array()); } else { - CodedInputStream cis = UnsafeByteOperations - .unsafeWrap(new ByteBuffByteInput(buf, 0, buf.limit()), 0, buf.limit()).newCodedInput(); + CodedInputStream cis = UnsafeByteOperations.unsafeWrap( + new ByteBuffByteInput(buf, 0, buf.limit()), 0, buf.limit()).newCodedInput(); cis.enableAliasing(true); this.connectionHeader = ConnectionHeader.parseFrom(cis); } @@ -522,10 +516,9 @@ abstract class ServerRpcConnection implements Closeable { } // audit logging for SASL authenticated users happens in saslReadAndProcess() if (authenticatedWithFallback) { - RpcServer.LOG.warn("Allowed fallback to SIMPLE auth for " + ugi - + " connecting from " + getHostAddress()); + RpcServer.LOG.warn("Allowed fallback to SIMPLE auth for {} connecting from {}", + ugi, getHostAddress()); } - RpcServer.AUDITLOG.info(RpcServer.AUTH_SUCCESSFUL_FOR + ugi); } else { // user is authenticated ugi.setAuthenticationMethod(authMethod.authenticationMethod); @@ -551,17 +544,17 @@ abstract class ServerRpcConnection implements Closeable { } } } - if (connectionHeader.hasVersionInfo()) { + String version; + if (this.connectionHeader.hasVersionInfo()) { // see if this connection will support RetryImmediatelyException - retryImmediatelySupported = VersionInfoUtil.hasMinimumVersion(getVersionInfo(), 1, 2); - - RpcServer.AUDITLOG.info("Connection from " + this.hostAddress + " port: " + this.remotePort - + " with version info: " - + TextFormat.shortDebugString(connectionHeader.getVersionInfo())); + this.retryImmediatelySupported = + VersionInfoUtil.hasMinimumVersion(getVersionInfo(), 1, 2); + version = this.connectionHeader.getVersionInfo().getVersion(); } else { - RpcServer.AUDITLOG.info("Connection from " + this.hostAddress + " port: " + this.remotePort - + " with unknown version info"); + version = "UNKNOWN"; } + RpcServer.AUDITLOG.info("Connection from {}:{}, version={}, sasl={}, ugi={}, service={}", + this.hostAddress, this.remotePort, version, this.useSasl, this.ugi, serviceName); } /**