Skip to content

Commit

Permalink
Fix PPL request concurrency handling issue (#207)
Browse files Browse the repository at this point in the history
* Downscope request to local method

Signed-off-by: Chen Dai <[email protected]>

* Fix checkstyle

Signed-off-by: Chen Dai <[email protected]>
  • Loading branch information
dai-chen authored Sep 16, 2021
1 parent 74d9fa0 commit 7cda06b
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ public class RestPPLQueryAction extends BaseRestHandler {

private final Supplier<Boolean> pplEnabled;

private PPLQueryRequest pplRequest;

/**
* Constructor of RestPPLQueryAction.
*/
Expand Down Expand Up @@ -155,12 +153,12 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient nod
}

PPLService pplService = createPPLService(nodeClient);
pplRequest = PPLQueryRequestFactory.getPPLRequest(request);
PPLQueryRequest pplRequest = PPLQueryRequestFactory.getPPLRequest(request);

if (pplRequest.isExplainRequest()) {
return channel -> pplService.explain(pplRequest, createExplainResponseListener(channel));
}
return channel -> pplService.execute(pplRequest, createListener(channel));
return channel -> pplService.execute(pplRequest, createListener(channel, pplRequest));
}

/**
Expand Down Expand Up @@ -215,7 +213,8 @@ public void onFailure(Exception e) {
};
}

private ResponseListener<QueryResponse> createListener(RestChannel channel) {
private ResponseListener<QueryResponse> createListener(RestChannel channel,
PPLQueryRequest pplRequest) {
Format format = pplRequest.format();
ResponseFormatter<QueryResult> formatter;
if (format.equals(Format.CSV)) {
Expand Down

0 comments on commit 7cda06b

Please sign in to comment.