protected SearchScrollAsyncAction(ParsedScrollId scrollId, Logger logger, DiscoveryNodes nodes, ActionListener<SearchResponse> listener, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTransportService searchTransportService) { this.startTime = System.currentTimeMillis(); this.scrollId = scrollId; this.successfulOps = new AtomicInteger(scrollId.getContext().length); this.logger = logger; this.listener = listener; this.nodes = nodes; this.searchPhaseController = searchPhaseController; this.request = request; this.searchTransportService = searchTransportService; }
SearchScrollQueryThenFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request, searchTransportService); this.task = task; this.fetchResults = new AtomicArray<>(scrollId.getContext().length); this.queryResults = new AtomicArray<>(scrollId.getContext().length); }
SearchScrollQueryAndFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request, searchTransportService); this.task = task; this.queryFetchResults = new AtomicArray<>(scrollId.getContext().length); }
public final void run() { final ScrollIdForNode[] context = scrollId.getContext(); if (context.length == 0) { listener.onFailure(new SearchPhaseExecutionException("query", "no nodes to search on", ShardSearchFailure.EMPTY_ARRAY)); } else { collectNodesAndRun(Arrays.asList(context), nodes, searchTransportService, ActionListener.wrap(lookup -> run(lookup, context), listener::onFailure)); } }
ClearScrollController(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener, DiscoveryNodes nodes, Logger logger, SearchTransportService searchTransportService) { this.nodes = nodes; this.logger = logger; this.searchTransportService = searchTransportService; this.listener = listener; List<String> scrollIds = request.getScrollIds(); final int expectedOps; if (scrollIds.size() == 1 && "_all".equals(scrollIds.get(0))) { expectedOps = nodes.getSize(); runner = this::cleanAllScrolls; } else { List<ScrollIdForNode> parsedScrollIds = new ArrayList<>(); for (String parsedScrollId : request.getScrollIds()) { ScrollIdForNode[] context = parseScrollId(parsedScrollId).getContext(); for (ScrollIdForNode id : context) { parsedScrollIds.add(id); } } if (parsedScrollIds.isEmpty()) { expectedOps = 0; runner = () -> listener.onResponse(new ClearScrollResponse(true, 0)); } else { expectedOps = parsedScrollIds.size(); runner = () -> cleanScrollIds(parsedScrollIds); } } this.expectedOps = new CountDown(expectedOps); }
protected final void sendResponse(SearchPhaseController.ReducedQueryPhase queryPhase, final AtomicArray<? extends SearchPhaseResult> fetchResults) { try { final InternalSearchResponse internalResponse = searchPhaseController.merge(true, queryPhase, fetchResults.asList(), fetchResults::get); // the scroll ID never changes we always return the same ID. This ID contains all the shards and their context ids // such that we can talk to them abgain in the next roundtrip. String scrollId = null; if (request.scroll() != null) { scrollId = request.scrollId(); } listener.onResponse(new SearchResponse(internalResponse, scrollId, this.scrollId.getContext().length, successfulOps.get(), 0, buildTookInMillis(), buildShardFailures(), SearchResponse.Clusters.EMPTY)); } catch (Exception e) { listener.onFailure(new ReduceSearchPhaseException("fetch", "inner finish failed", e, buildShardFailures())); } }
private void run(BiFunction<String, String, DiscoveryNode> clusterNodeLookup, final ScrollIdForNode[] context) { final CountDown counter = new CountDown(scrollId.getContext().length); for (int i = 0; i < context.length; i++) { ScrollIdForNode target = context[i];
protected SearchScrollAsyncAction(ParsedScrollId scrollId, Logger logger, DiscoveryNodes nodes, ActionListener<SearchResponse> listener, SearchPhaseController searchPhaseController, SearchScrollRequest request) { this.startTime = System.currentTimeMillis(); this.scrollId = scrollId; this.successfulOps = new AtomicInteger(scrollId.getContext().length); this.logger = logger; this.listener = listener; this.nodes = nodes; this.searchPhaseController = searchPhaseController; this.request = request; }
protected final void addShardFailure(final int shardIndex, ShardSearchFailure failure) { if (shardFailures == null) { shardFailures = new AtomicArray<>(scrollId.getContext().length); } shardFailures.set(shardIndex, failure); }
SearchScrollQueryThenFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request, searchTransportService); this.task = task; this.fetchResults = new AtomicArray<>(scrollId.getContext().length); this.queryResults = new AtomicArray<>(scrollId.getContext().length); }
SearchScrollQueryThenFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request); this.searchTransportService = searchTransportService; this.task = task; this.fetchResults = new AtomicArray<>(scrollId.getContext().length); this.queryResults = new AtomicArray<>(scrollId.getContext().length); }
protected final void addShardFailure(final int shardIndex, ShardSearchFailure failure) { if (shardFailures == null) { shardFailures = new AtomicArray<>(scrollId.getContext().length); } shardFailures.set(shardIndex, failure); }
protected final void addShardFailure(final int shardIndex, ShardSearchFailure failure) { if (shardFailures == null) { shardFailures = new AtomicArray<>(scrollId.getContext().length); } shardFailures.set(shardIndex, failure); }
SearchScrollQueryThenFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request, searchTransportService); this.task = task; this.fetchResults = new AtomicArray<>(scrollId.getContext().length); this.queryResults = new AtomicArray<>(scrollId.getContext().length); }
SearchScrollQueryAndFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request, searchTransportService); this.task = task; this.queryFetchResults = new AtomicArray<>(scrollId.getContext().length); }
SearchScrollQueryAndFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request); this.task = task; this.searchTransportService = searchTransportService; this.queryFetchResults = new AtomicArray<>(scrollId.getContext().length); }
SearchScrollQueryAndFetchAsyncAction(Logger logger, ClusterService clusterService, SearchTransportService searchTransportService, SearchPhaseController searchPhaseController, SearchScrollRequest request, SearchTask task, ParsedScrollId scrollId, ActionListener<SearchResponse> listener) { super(scrollId, logger, clusterService.state().nodes(), listener, searchPhaseController, request, searchTransportService); this.task = task; this.queryFetchResults = new AtomicArray<>(scrollId.getContext().length); }
public final void run() { final ScrollIdForNode[] context = scrollId.getContext(); if (context.length == 0) { listener.onFailure(new SearchPhaseExecutionException("query", "no nodes to search on", ShardSearchFailure.EMPTY_ARRAY)); } else { collectNodesAndRun(Arrays.asList(context), nodes, searchTransportService, ActionListener.wrap(lookup -> run(lookup, context), listener::onFailure)); } }
public final void run() { final ScrollIdForNode[] context = scrollId.getContext(); if (context.length == 0) { listener.onFailure(new SearchPhaseExecutionException("query", "no nodes to search on", ShardSearchFailure.EMPTY_ARRAY)); } else { collectNodesAndRun(Arrays.asList(context), nodes, searchTransportService, ActionListener.wrap(lookup -> run(lookup, context), listener::onFailure)); } }
private void innerFinishHim() { InternalSearchResponse internalResponse = searchPhaseController.merge(sortedShardList, queryResults, fetchResults, request); String scrollId = null; if (request.scroll() != null) { scrollId = request.scrollId(); } listener.onResponse(new SearchResponse(internalResponse, scrollId, this.scrollId.getContext().length, successfulOps.get(), buildTookInMillis(), buildShardFailures())); } }