Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -71,6 +71,9 @@ public void testClusterStateRestCancellation() throws Exception {
final Request clusterStateRequest = new Request(HttpGet.METHOD_NAME, "/_cluster/state");
clusterStateRequest.addParameter("wait_for_metadata_version", Long.toString(Long.MAX_VALUE));
clusterStateRequest.addParameter("wait_for_timeout", "1h");
if (randomBoolean()) {
clusterStateRequest.addParameter("local", "true");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

final PlainActionFuture<Void> future = new PlainActionFuture<>();
logger.info("--> sending cluster state request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ protected void masterOperation(Task task, final ClusterStateRequest request, fin

final Predicate<ClusterState> acceptableClusterStateOrFailedPredicate = request.local()
? acceptableClusterStatePredicate
: acceptableClusterStatePredicate.or(clusterState ->
cancellableTask.isCancelled() || clusterState.nodes().isLocalNodeElectedMaster() == false);
: acceptableClusterStatePredicate.or(clusterState -> clusterState.nodes().isLocalNodeElectedMaster() == false);

if (acceptableClusterStatePredicate.test(state)) {
if (acceptableClusterStatePredicate.test(state) && cancellableTask.isCancelled() == false) {
ActionListener.completeWith(listener, () -> buildResponse(request, state));
} else {
assert acceptableClusterStateOrFailedPredicate.test(state) == false;
Expand Down Expand Up @@ -112,7 +111,7 @@ public void onTimeout(TimeValue timeout) {
listener.onFailure(e);
}
}
}, acceptableClusterStateOrFailedPredicate);
}, clusterState -> cancellableTask.isCancelled() || acceptableClusterStateOrFailedPredicate.test(clusterState));
}
}

Expand Down