Skip to content

Commit 29cfa53

Browse files
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
1 parent c44b196 commit 29cfa53

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/server/src/main/java/io/cassandrareaper/jmx/JmxProxyImpl.java

+19-11
Original file line numberDiff line numberDiff line change
@@ -849,18 +849,26 @@ public Map<String, String> getSimpleStates() {
849849
* ordinal of AntiEntropyService.Status
850850
*/
851851
@Override
852-
public void handleNotification(Notification notification, Object handback) {
853-
Thread.currentThread().setName(clusterName);
854-
// we're interested in "repair"
855-
String type = notification.getType();
856-
LOG.debug("Received notification: {} with type {}", notification, type);
857-
if (("repair").equals(type)) {
858-
processOldApiNotification(notification);
859-
}
852+
public void handleNotification(final Notification notification, Object handback) {
853+
// pass off the work immediately to a separate thread
854+
EXECUTOR.submit(() -> {
855+
String threadName = Thread.currentThread().getName();
856+
try {
857+
Thread.currentThread().setName(clusterName);
858+
// we're interested in "repair"
859+
String type = notification.getType();
860+
LOG.debug("Received notification: {} with type {}", notification, type);
861+
if (("repair").equals(type)) {
862+
processOldApiNotification(notification);
863+
}
860864

861-
if (("progress").equals(type)) {
862-
processNewApiNotification(notification);
863-
}
865+
if (("progress").equals(type)) {
866+
processNewApiNotification(notification);
867+
}
868+
} finally {
869+
Thread.currentThread().setName(threadName);
870+
}
871+
});
864872
}
865873

866874
/**

0 commit comments

Comments
 (0)