kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject [kafka] branch trunk updated: MINOR: log which signals are handled on startup (#6620)
Date Mon, 22 Apr 2019 20:08:39 GMT
This is an automated email from the ASF dual-hosted git repository.

cmccabe 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 c2bee98  MINOR: log which signals are handled on startup (#6620)
c2bee98 is described below

commit c2bee988faa3c338fdc275aac9f638bb652b38a0
Author: Colin Patrick McCabe <colin@cmccabe.xyz>
AuthorDate: Mon Apr 22 13:08:27 2019 -0700

    MINOR: log which signals are handled on startup (#6620)
    
    Reviewers: Gwen Shapira <cshapi@gmail.com>
---
 .../org/apache/kafka/common/utils/LoggingSignalHandler.java  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/clients/src/main/java/org/apache/kafka/common/utils/LoggingSignalHandler.java
b/clients/src/main/java/org/apache/kafka/common/utils/LoggingSignalHandler.java
index fbe6736..112d7fd 100644
--- a/clients/src/main/java/org/apache/kafka/common/utils/LoggingSignalHandler.java
+++ b/clients/src/main/java/org/apache/kafka/common/utils/LoggingSignalHandler.java
@@ -23,6 +23,8 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -30,6 +32,8 @@ public class LoggingSignalHandler {
 
     private static final Logger log = LoggerFactory.getLogger(LoggingSignalHandler.class);
 
+    private static final List<String> SIGNALS = Arrays.asList("TERM", "INT", "HUP");
+
     private final Constructor<?> signalConstructor;
     private final Class<?> signalHandlerClass;
     private final Class<?> signalClass;
@@ -61,9 +65,11 @@ public class LoggingSignalHandler {
      */
     public void register() throws ReflectiveOperationException {
         Map<String, Object> jvmSignalHandlers = new ConcurrentHashMap<>();
-        register("TERM", jvmSignalHandlers);
-        register("INT", jvmSignalHandlers);
-        register("HUP", jvmSignalHandlers);
+
+        for (String signal : SIGNALS) {
+            register(signal, jvmSignalHandlers);
+        }
+        log.info("Registered signal handlers for " + String.join(", ", SIGNALS));
     }
 
     private Object createSignalHandler(final Map<String, Object> jvmSignalHandlers)
{


Mime
View raw message