kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-5976; Improve trace logging in RequestChannel.sendResponse
Date Thu, 28 Sep 2017 10:18:43 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk e846daa89 -> 983280c45


KAFKA-5976; Improve trace logging in RequestChannel.sendResponse

It now records the correct size for `Send` and does more appropriate
logging if the connection is being closed or if no response is being
sent.

Author: huxihx <huxi_2b@hotmail.com>

Reviewers: Denis Bolshakov, Ismael Juma <ismael@juma.me.uk>

Closes #3961 from huxihx/KAFKA-5976


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/983280c4
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/983280c4
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/983280c4

Branch: refs/heads/trunk
Commit: 983280c454eb1ec4aa8c5c9a1b6bf49ea581ee5b
Parents: e846daa
Author: huxihx <huxi_2b@hotmail.com>
Authored: Thu Sep 28 11:09:38 2017 +0100
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Thu Sep 28 11:18:08 2017 +0100

----------------------------------------------------------------------
 .../main/scala/kafka/network/RequestChannel.scala   | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/983280c4/core/src/main/scala/kafka/network/RequestChannel.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/network/RequestChannel.scala b/core/src/main/scala/kafka/network/RequestChannel.scala
index e71a06b..b2ef615 100644
--- a/core/src/main/scala/kafka/network/RequestChannel.scala
+++ b/core/src/main/scala/kafka/network/RequestChannel.scala
@@ -23,8 +23,7 @@ import java.util.concurrent._
 
 import com.yammer.metrics.core.Gauge
 import kafka.metrics.KafkaMetricsGroup
-import kafka.network.RequestChannel.{ShutdownRequest, BaseRequest}
-import kafka.server.QuotaId
+import kafka.network.RequestChannel.{BaseRequest, SendAction, ShutdownRequest, NoOpAction,
CloseConnectionAction}
 import kafka.utils.{Logging, NotNothing}
 import org.apache.kafka.common.memory.MemoryPool
 import org.apache.kafka.common.metrics.Sanitizer
@@ -204,7 +203,7 @@ object RequestChannel extends Logging {
       s"Response(request=$request, responseSend=$responseSend, responseAction=$responseAction),
responseAsString=$responseAsString"
   }
 
-  trait ResponseAction
+  sealed trait ResponseAction
   case object SendAction extends ResponseAction
   case object NoOpAction extends ResponseAction
   case object CloseConnectionAction extends ResponseAction
@@ -246,8 +245,15 @@ class RequestChannel(val numProcessors: Int, val queueSize: Int) extends
KafkaMe
   def sendResponse(response: RequestChannel.Response) {
     if (isTraceEnabled) {
       val requestHeader = response.request.header
-      trace(s"Sending ${requestHeader.apiKey} response to client ${requestHeader.clientId}
of " +
-        s"${response.responseSend.size} bytes.")
+      val message = response.responseAction match {
+        case SendAction =>
+          s"Sending ${requestHeader.apiKey} response to client ${requestHeader.clientId}
of ${response.responseSend.get.size} bytes."
+        case NoOpAction =>
+          s"Not sending ${requestHeader.apiKey} response to client ${requestHeader.clientId}
as it's not required."
+        case CloseConnectionAction =>
+          s"Closing connection for client ${requestHeader.clientId} due to error during ${requestHeader.apiKey}."
+      }
+      trace(message)
     }
 
     responseQueues(response.processor).put(response)


Mime
View raw message