Skip to content

Commit

Permalink
adding tests and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
bharath-techie committed May 11, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 480bdc2 commit 04532f4
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
public class DeletePitAction extends ActionType<DeletePitResponse> {

public static final DeletePitAction INSTANCE = new DeletePitAction();
public static final String NAME = "indices:admin/delete/pit";
public static final String NAME = "indices:admin/read/pit/delete";

private DeletePitAction() {
super(NAME, DeletePitResponse::new);
Original file line number Diff line number Diff line change
@@ -389,6 +389,9 @@ public ShardSearchContextId id() {

}

/**
* Request to free the PIT context based on id
*/
static class PitFreeContextRequest extends TransportRequest {
private ShardSearchContextId contextId;

Original file line number Diff line number Diff line change
@@ -60,6 +60,9 @@ public TransportDeletePitAction(
this.searchTransportService = searchTransportService;
}

/**
* Invoke delete all pits or delete list of pits workflow based on request
*/
@Override
protected void doExecute(Task task, DeletePitRequest request, ActionListener<DeletePitResponse> listener) {
List<SearchContextIdForNode> contexts = new ArrayList<>();
@@ -96,15 +99,17 @@ void deleteAllPits(ActionListener<DeletePitResponse> listener) {
new ActionListener<>() {
@Override
public void onResponse(final Collection<SearchTransportService.SearchFreeContextResponse> responses) {
final SetOnce<Boolean> succeeded = new SetOnce<>();
for (SearchTransportService.SearchFreeContextResponse response : responses) {
if (!response.isFreed()) {
succeeded.set(false);
break;
}
}
succeeded.trySet(true);
listener.onResponse(new DeletePitResponse(succeeded.get()));
//final SetOnce<Boolean> succeeded = new SetOnce<>();
boolean hasFailures = responses.stream().anyMatch(r-> !r.isFreed());
listener.onResponse(new DeletePitResponse(!hasFailures));
// for (SearchTransportService.SearchFreeContextResponse response : responses) {
// if (!response.isFreed()) {
// succeeded.set(false);
// break;
// }
// }
// succeeded.trySet(true);
// listener.onResponse(new DeletePitResponse(succeeded.get()));
}

@Override

0 comments on commit 04532f4

Please sign in to comment.