kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject [kafka] branch trunk updated: MINOR: Log successful/failed authentications with socket information (#5856)
Date Wed, 09 Jan 2019 17:32:23 GMT
This is an automated email from the ASF dual-hosted git repository.

ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 66a9416  MINOR: Log successful/failed authentications with socket information (#5856)
66a9416 is described below

commit 66a9416e384fa3d3388de65885d895335e707286
Author: Stanislav Kozlovski <stanislav_kozlovski@outlook.com>
AuthorDate: Wed Jan 9 19:32:02 2019 +0200

    MINOR: Log successful/failed authentications with socket information (#5856)
    
    Use `info` for failed authentications and `debug` for successful ones.
    
    Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>, Ismael Juma <ismael@juma.me.uk>
---
 .../org/apache/kafka/common/network/Selector.java  | 28 ++++++++++++++--------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/clients/src/main/java/org/apache/kafka/common/network/Selector.java b/clients/src/main/java/org/apache/kafka/common/network/Selector.java
index 8c46746..7a4dd1b 100644
--- a/clients/src/main/java/org/apache/kafka/common/network/Selector.java
+++ b/clients/src/main/java/org/apache/kafka/common/network/Selector.java
@@ -536,27 +536,35 @@ public class Selector implements Selectable, AutoCloseable {
                     try {
                         channel.prepare();
                     } catch (AuthenticationException e) {
-                        if (channel.successfulAuthentications() == 0)
-                            sensors.failedAuthentication.record();
-                        else
+                        boolean isReauthentication = channel.successfulAuthentications()
> 0;
+                        if (isReauthentication)
                             sensors.failedReauthentication.record();
+                        else
+                            sensors.failedAuthentication.record();
+                        log.info("Address {} failed {}authentication ({})",
+                            channel.socketDescription(),
+                            isReauthentication ? "re-" : "",
+                            e.getClass().getName());
                         throw e;
                     }
                     if (channel.ready()) {
                         long readyTimeMs = time.milliseconds();
-                        if (channel.successfulAuthentications() == 1) {
-                            sensors.successfulAuthentication.record(1.0, readyTimeMs);
-                            if (!channel.connectedClientSupportsReauthentication())
-                                sensors.successfulAuthenticationNoReauth.record(1.0, readyTimeMs);
-                        } else {
+                        boolean isReauthentication = channel.successfulAuthentications()
> 1;
+                        if (isReauthentication) {
                             sensors.successfulReauthentication.record(1.0, readyTimeMs);
                             if (channel.reauthenticationLatencyMs() == null)
                                 log.warn(
-                                        "Should never happen: re-authentication latency for
a re-authenticated channel was null; continuing...");
+                                    "Should never happen: re-authentication latency for a
re-authenticated channel was null; continuing...");
                             else
                                 sensors.reauthenticationLatency
-                                        .record(channel.reauthenticationLatencyMs().doubleValue(),
readyTimeMs);
+                                    .record(channel.reauthenticationLatencyMs().doubleValue(),
readyTimeMs);
+                        } else {
+                            sensors.successfulAuthentication.record(1.0, readyTimeMs);
+                            if (!channel.connectedClientSupportsReauthentication())
+                                sensors.successfulAuthenticationNoReauth.record(1.0, readyTimeMs);
                         }
+                        log.debug("Address {} successfully {}authenticated",
+                            channel.socketDescription(), isReauthentication ? "re-" : "");
                     }
                     List<NetworkReceive> responsesReceivedDuringReauthentication =
channel
                             .getAndClearResponsesReceivedDuringReauthentication();


Mime
View raw message