Browse Source

MINOR: log which signals are handled on startup (#6620)

Reviewers: Gwen Shapira <cshapi@gmail.com>
pull/3900/merge
Colin Patrick McCabe 6 years ago committed by GitHub
parent
commit
c2bee988fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      clients/src/main/java/org/apache/kafka/common/utils/LoggingSignalHandler.java

12
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.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -30,6 +32,8 @@ public class LoggingSignalHandler {
private static final Logger log = LoggerFactory.getLogger(LoggingSignalHandler.class); 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 Constructor<?> signalConstructor;
private final Class<?> signalHandlerClass; private final Class<?> signalHandlerClass;
private final Class<?> signalClass; private final Class<?> signalClass;
@ -61,9 +65,11 @@ public class LoggingSignalHandler {
*/ */
public void register() throws ReflectiveOperationException { public void register() throws ReflectiveOperationException {
Map<String, Object> jvmSignalHandlers = new ConcurrentHashMap<>(); Map<String, Object> jvmSignalHandlers = new ConcurrentHashMap<>();
register("TERM", jvmSignalHandlers);
register("INT", jvmSignalHandlers); for (String signal : SIGNALS) {
register("HUP", jvmSignalHandlers); register(signal, jvmSignalHandlers);
}
log.info("Registered signal handlers for " + String.join(", ", SIGNALS));
} }
private Object createSignalHandler(final Map<String, Object> jvmSignalHandlers) { private Object createSignalHandler(final Map<String, Object> jvmSignalHandlers) {

Loading…
Cancel
Save