|
23 | 23 | import org.elasticsearch.action.ActionListenerResponseHandler; |
24 | 24 | import org.elasticsearch.action.IndicesRequest; |
25 | 25 | import org.elasticsearch.action.OriginalIndices; |
26 | | -import org.elasticsearch.action.support.HandledTransportAction; |
| 26 | +import org.elasticsearch.action.support.HandledTransportAction.ChannelActionListener; |
27 | 27 | import org.elasticsearch.action.support.IndicesOptions; |
28 | 28 | import org.elasticsearch.cluster.node.DiscoveryNode; |
29 | 29 | import org.elasticsearch.common.component.AbstractComponent; |
@@ -112,9 +112,9 @@ public void sendFreeContext(Transport.Connection connection, long contextId, fin |
112 | 112 | } |
113 | 113 |
|
114 | 114 | public void sendCanMatch(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task, final |
115 | | - ActionListener<CanMatchResponse> listener) { |
| 115 | + ActionListener<SearchService.CanMatchResponse> listener) { |
116 | 116 | transportService.sendChildRequest(connection, QUERY_CAN_MATCH_NAME, request, task, |
117 | | - TransportRequestOptions.EMPTY, new ActionListenerResponseHandler<>(listener, CanMatchResponse::new)); |
| 117 | + TransportRequestOptions.EMPTY, new ActionListenerResponseHandler<>(listener, SearchService.CanMatchResponse::new)); |
118 | 118 | } |
119 | 119 |
|
120 | 120 | public void sendClearAllScrollContexts(Transport.Connection connection, final ActionListener<TransportResponse> listener) { |
@@ -349,83 +349,54 @@ public void onFailure(Exception e) { |
349 | 349 |
|
350 | 350 | transportService.registerRequestHandler(QUERY_ACTION_NAME, ThreadPool.Names.SAME, ShardSearchTransportRequest::new, |
351 | 351 | (request, channel, task) -> { |
352 | | - searchService.executeQueryPhase(request, (SearchTask) task, new HandledTransportAction.ChannelActionListener<>( |
| 352 | + searchService.executeQueryPhase(request, (SearchTask) task, new ChannelActionListener<>( |
353 | 353 | channel, QUERY_ACTION_NAME, request)); |
354 | 354 | }); |
355 | 355 | TransportActionProxy.registerProxyAction(transportService, QUERY_ACTION_NAME, |
356 | 356 | (request) -> ((ShardSearchRequest)request).numberOfShards() == 1 ? QueryFetchSearchResult::new : QuerySearchResult::new); |
357 | 357 |
|
358 | | - transportService.registerRequestHandler(QUERY_ID_ACTION_NAME, ThreadPool.Names.SEARCH, QuerySearchRequest::new, |
| 358 | + transportService.registerRequestHandler(QUERY_ID_ACTION_NAME, ThreadPool.Names.SAME, QuerySearchRequest::new, |
359 | 359 | (request, channel, task) -> { |
360 | | - QuerySearchResult result = searchService.executeQueryPhase(request, (SearchTask)task); |
361 | | - channel.sendResponse(result); |
| 360 | + searchService.executeQueryPhase(request, (SearchTask)task, new ChannelActionListener<>(channel, QUERY_ID_ACTION_NAME, |
| 361 | + request)); |
362 | 362 | }); |
363 | 363 | TransportActionProxy.registerProxyAction(transportService, QUERY_ID_ACTION_NAME, QuerySearchResult::new); |
364 | 364 |
|
365 | | - transportService.registerRequestHandler(QUERY_SCROLL_ACTION_NAME, ThreadPool.Names.SEARCH, InternalScrollSearchRequest::new, |
| 365 | + transportService.registerRequestHandler(QUERY_SCROLL_ACTION_NAME, ThreadPool.Names.SAME, InternalScrollSearchRequest::new, |
366 | 366 | (request, channel, task) -> { |
367 | | - ScrollQuerySearchResult result = searchService.executeQueryPhase(request, (SearchTask)task); |
368 | | - channel.sendResponse(result); |
| 367 | + searchService.executeQueryPhase(request, (SearchTask)task, new ChannelActionListener<>(channel, QUERY_SCROLL_ACTION_NAME, |
| 368 | + request)); |
369 | 369 | }); |
370 | 370 | TransportActionProxy.registerProxyAction(transportService, QUERY_SCROLL_ACTION_NAME, ScrollQuerySearchResult::new); |
371 | 371 |
|
372 | | - transportService.registerRequestHandler(QUERY_FETCH_SCROLL_ACTION_NAME, ThreadPool.Names.SEARCH, InternalScrollSearchRequest::new, |
| 372 | + transportService.registerRequestHandler(QUERY_FETCH_SCROLL_ACTION_NAME, ThreadPool.Names.SAME, InternalScrollSearchRequest::new, |
373 | 373 | (request, channel, task) -> { |
374 | | - ScrollQueryFetchSearchResult result = searchService.executeFetchPhase(request, (SearchTask)task); |
375 | | - channel.sendResponse(result); |
| 374 | + searchService.executeFetchPhase(request, (SearchTask)task, new ChannelActionListener<>(channel, |
| 375 | + QUERY_FETCH_SCROLL_ACTION_NAME, request)); |
376 | 376 | }); |
377 | 377 | TransportActionProxy.registerProxyAction(transportService, QUERY_FETCH_SCROLL_ACTION_NAME, ScrollQueryFetchSearchResult::new); |
378 | 378 |
|
379 | | - transportService.registerRequestHandler(FETCH_ID_SCROLL_ACTION_NAME, ThreadPool.Names.SEARCH, ShardFetchRequest::new, |
| 379 | + transportService.registerRequestHandler(FETCH_ID_SCROLL_ACTION_NAME, ThreadPool.Names.SAME, ShardFetchRequest::new, |
380 | 380 | (request, channel, task) -> { |
381 | | - FetchSearchResult result = searchService.executeFetchPhase(request, (SearchTask)task); |
382 | | - channel.sendResponse(result); |
| 381 | + searchService.executeFetchPhase(request, (SearchTask)task, new ChannelActionListener<>(channel, |
| 382 | + FETCH_ID_SCROLL_ACTION_NAME, request)); |
383 | 383 | }); |
384 | 384 | TransportActionProxy.registerProxyAction(transportService, FETCH_ID_SCROLL_ACTION_NAME, FetchSearchResult::new); |
385 | 385 |
|
386 | | - transportService.registerRequestHandler(FETCH_ID_ACTION_NAME, ThreadPool.Names.SEARCH, true, true, ShardFetchSearchRequest::new, |
| 386 | + transportService.registerRequestHandler(FETCH_ID_ACTION_NAME, ThreadPool.Names.SAME, true, true, ShardFetchSearchRequest::new, |
387 | 387 | (request, channel, task) -> { |
388 | | - FetchSearchResult result = searchService.executeFetchPhase(request, (SearchTask)task); |
389 | | - channel.sendResponse(result); |
| 388 | + searchService.executeFetchPhase(request, (SearchTask)task, new ChannelActionListener<>(channel, FETCH_ID_ACTION_NAME, |
| 389 | + request)); |
390 | 390 | }); |
391 | 391 | TransportActionProxy.registerProxyAction(transportService, FETCH_ID_ACTION_NAME, FetchSearchResult::new); |
392 | 392 |
|
393 | 393 | // this is cheap, it does not fetch during the rewrite phase, so we can let it quickly execute on a networking thread |
394 | 394 | transportService.registerRequestHandler(QUERY_CAN_MATCH_NAME, ThreadPool.Names.SAME, ShardSearchTransportRequest::new, |
395 | 395 | (request, channel, task) -> { |
396 | | - boolean canMatch = searchService.canMatch(request); |
397 | | - channel.sendResponse(new CanMatchResponse(canMatch)); |
| 396 | + searchService.canMatch(request, new ChannelActionListener<>(channel, QUERY_CAN_MATCH_NAME, request)); |
398 | 397 | }); |
399 | 398 | TransportActionProxy.registerProxyAction(transportService, QUERY_CAN_MATCH_NAME, |
400 | | - (Supplier<TransportResponse>) CanMatchResponse::new); |
401 | | - } |
402 | | - |
403 | | - public static final class CanMatchResponse extends SearchPhaseResult { |
404 | | - private boolean canMatch; |
405 | | - |
406 | | - public CanMatchResponse() { |
407 | | - } |
408 | | - |
409 | | - public CanMatchResponse(boolean canMatch) { |
410 | | - this.canMatch = canMatch; |
411 | | - } |
412 | | - |
413 | | - |
414 | | - @Override |
415 | | - public void readFrom(StreamInput in) throws IOException { |
416 | | - super.readFrom(in); |
417 | | - canMatch = in.readBoolean(); |
418 | | - } |
419 | | - |
420 | | - @Override |
421 | | - public void writeTo(StreamOutput out) throws IOException { |
422 | | - super.writeTo(out); |
423 | | - out.writeBoolean(canMatch); |
424 | | - } |
425 | | - |
426 | | - public boolean canMatch() { |
427 | | - return canMatch; |
428 | | - } |
| 399 | + (Supplier<TransportResponse>) SearchService.CanMatchResponse::new); |
429 | 400 | } |
430 | 401 |
|
431 | 402 |
|
|
0 commit comments