Skip to content

Commit

Permalink
Avoid blocking the jmx broadcasting thread, offload work to a separat…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsembwever committed May 11, 2018
1 parent c44b196 commit 29cfa53
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/server/src/main/java/io/cassandrareaper/jmx/JmxProxyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -849,18 +849,26 @@ public Map<String, String> 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);
}
});
}

/**
Expand Down

0 comments on commit 29cfa53

Please sign in to comment.