Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,27 +229,41 @@ private void processNextItem() {
try {
nextItem.run();
} finally {
final var remaining = queueSize.decrementAndGet();
assert remaining >= 0;
if (remaining > 0) {
runProcessor();
var cleanupSuccess = false;
try {
final var remaining = queueSize.decrementAndGet();
assert remaining >= 0;
if (remaining > 0) {
runProcessor();
}
cleanupSuccess = true;
} finally {
assert cleanupSuccess;
}
}
}

private void onShutdown() {
// shutting down when enqueueing the next processor run which means there is no active processor so it's safe to clear out the
// cache ...
cacheClearer.run();

// ... and drain the queue
do {
final var nextItem = queue.poll();
assert nextItem != null;
if (nextItem != cacheClearer) {
nextItem.onFailure(new NodeClosedException(transportService.getLocalNode()));
}
} while (queueSize.decrementAndGet() > 0);
var success = false;

try {
// shutting down when enqueueing the next processor run which means there is no active processor so it's safe to clear out the
// cache ...
cacheClearer.run();

// ... and drain the queue
do {
final var nextItem = queue.poll();
assert nextItem != null;
if (nextItem != cacheClearer) {
nextItem.onFailure(new NodeClosedException(transportService.getLocalNode()));
}
} while (queueSize.decrementAndGet() > 0);

success = true;
} finally {
assert success;
}
}

private final AbstractRunnable cacheClearer = new AbstractRunnable() {
Expand Down