From 29cfa535981808296517193a004beb731e912506 Mon Sep 17 00:00:00 2001 From: mck Date: Tue, 1 May 2018 20:23:37 +1000 Subject: [PATCH] Avoid blocking the jmx broadcasting thread, offload work to a separate thread immediately. As is documented here: https://docs.oracle.com/cd/E28280_01/web.1111/e13728/notifications.htm#JMXCU214 --- .../io/cassandrareaper/jmx/JmxProxyImpl.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/server/src/main/java/io/cassandrareaper/jmx/JmxProxyImpl.java b/src/server/src/main/java/io/cassandrareaper/jmx/JmxProxyImpl.java index c9af8b60e..358c84011 100644 --- a/src/server/src/main/java/io/cassandrareaper/jmx/JmxProxyImpl.java +++ b/src/server/src/main/java/io/cassandrareaper/jmx/JmxProxyImpl.java @@ -849,18 +849,26 @@ public Map getSimpleStates() { * ordinal of AntiEntropyService.Status */ @Override - public void handleNotification(Notification notification, Object handback) { - Thread.currentThread().setName(clusterName); - // we're interested in "repair" - String type = notification.getType(); - LOG.debug("Received notification: {} with type {}", notification, type); - if (("repair").equals(type)) { - processOldApiNotification(notification); - } + public void handleNotification(final Notification notification, Object handback) { + // pass off the work immediately to a separate thread + EXECUTOR.submit(() -> { + String threadName = Thread.currentThread().getName(); + try { + Thread.currentThread().setName(clusterName); + // we're interested in "repair" + String type = notification.getType(); + LOG.debug("Received notification: {} with type {}", notification, type); + if (("repair").equals(type)) { + processOldApiNotification(notification); + } - if (("progress").equals(type)) { - processNewApiNotification(notification); - } + if (("progress").equals(type)) { + processNewApiNotification(notification); + } + } finally { + Thread.currentThread().setName(threadName); + } + }); } /**