|
65 | 65 | * distributed frequencies
|
66 | 66 | */
|
67 | 67 | abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> extends SearchPhase {
|
68 |
| - private static final float DEFAULT_INDEX_BOOST = 1.0f; |
| 68 | + protected static final float DEFAULT_INDEX_BOOST = 1.0f; |
69 | 69 | private final Logger logger;
|
70 | 70 | private final NamedWriteableRegistry namedWriteableRegistry;
|
71 |
| - private final SearchTransportService searchTransportService; |
| 71 | + protected final SearchTransportService searchTransportService; |
72 | 72 | private final Executor executor;
|
73 | 73 | private final ActionListener<SearchResponse> listener;
|
74 |
| - private final SearchRequest request; |
| 74 | + protected final SearchRequest request; |
75 | 75 |
|
76 | 76 | /**
|
77 | 77 | * Used by subclasses to resolve node ids to DiscoveryNodes.
|
78 | 78 | **/
|
79 | 79 | private final BiFunction<String, String, Transport.Connection> nodeIdToConnection;
|
80 |
| - private final SearchTask task; |
| 80 | + protected final SearchTask task; |
81 | 81 | protected final SearchPhaseResults<Result> results;
|
82 | 82 | private final long clusterStateVersion;
|
83 | 83 | private final TransportVersion minTransportVersion;
|
84 |
| - private final Map<String, AliasFilter> aliasFilter; |
85 |
| - private final Map<String, Float> concreteIndexBoosts; |
| 84 | + protected final Map<String, AliasFilter> aliasFilter; |
| 85 | + protected final Map<String, Float> concreteIndexBoosts; |
86 | 86 | private final SetOnce<AtomicArray<ShardSearchFailure>> shardFailures = new SetOnce<>();
|
87 | 87 | private final Object shardFailuresMutex = new Object();
|
88 | 88 | private final AtomicBoolean hasShardResponse = new AtomicBoolean(false);
|
89 | 89 | private final AtomicInteger successfulOps;
|
90 |
| - private final SearchTimeProvider timeProvider; |
| 90 | + protected final SearchTimeProvider timeProvider; |
91 | 91 | private final SearchResponse.Clusters clusters;
|
92 | 92 |
|
93 | 93 | protected final List<SearchShardIterator> shardsIts;
|
94 |
| - private final SearchShardIterator[] shardIterators; |
| 94 | + protected final SearchShardIterator[] shardIterators; |
95 | 95 | private final AtomicInteger outstandingShards;
|
96 | 96 | private final int maxConcurrentRequestsPerNode;
|
97 | 97 | private final Map<String, PendingExecutions> pendingExecutionsPerNode = new ConcurrentHashMap<>();
|
@@ -231,10 +231,17 @@ protected final void run() {
|
231 | 231 | onPhaseDone();
|
232 | 232 | return;
|
233 | 233 | }
|
| 234 | + if (shardsIts.isEmpty()) { |
| 235 | + return; |
| 236 | + } |
234 | 237 | final Map<SearchShardIterator, Integer> shardIndexMap = Maps.newHashMapWithExpectedSize(shardIterators.length);
|
235 | 238 | for (int i = 0; i < shardIterators.length; i++) {
|
236 | 239 | shardIndexMap.put(shardIterators[i], i);
|
237 | 240 | }
|
| 241 | + doRun(shardIndexMap); |
| 242 | + } |
| 243 | + |
| 244 | + protected void doRun(Map<SearchShardIterator, Integer> shardIndexMap) { |
238 | 245 | doCheckNoMissingShards(getName(), request, shardsIts);
|
239 | 246 | Version version = request.minCompatibleShardNode();
|
240 | 247 | if (version != null && Version.CURRENT.minimumCompatibilityVersion().equals(version) == false) {
|
@@ -275,7 +282,7 @@ private boolean checkMinimumVersion(List<SearchShardIterator> shardsIts) {
|
275 | 282 | return true;
|
276 | 283 | }
|
277 | 284 |
|
278 |
| - private void performPhaseOnShard(final int shardIndex, final SearchShardIterator shardIt, final SearchShardTarget shard) { |
| 285 | + protected final void performPhaseOnShard(final int shardIndex, final SearchShardIterator shardIt, final SearchShardTarget shard) { |
279 | 286 | if (throttleConcurrentRequests) {
|
280 | 287 | var pendingExecutions = pendingExecutionsPerNode.computeIfAbsent(
|
281 | 288 | shard.getNodeId(),
|
@@ -315,7 +322,7 @@ public void onFailure(Exception e) {
|
315 | 322 | executePhaseOnShard(shardIt, connection, shardListener);
|
316 | 323 | }
|
317 | 324 |
|
318 |
| - private void failOnUnavailable(int shardIndex, SearchShardIterator shardIt) { |
| 325 | + protected final void failOnUnavailable(int shardIndex, SearchShardIterator shardIt) { |
319 | 326 | SearchShardTarget unassignedShard = new SearchShardTarget(null, shardIt.shardId(), shardIt.getClusterAlias());
|
320 | 327 | onShardFailure(shardIndex, unassignedShard, shardIt, new NoShardAvailableActionException(shardIt.shardId()));
|
321 | 328 | }
|
@@ -422,7 +429,7 @@ private ShardSearchFailure[] buildShardFailures() {
|
422 | 429 | return failures;
|
423 | 430 | }
|
424 | 431 |
|
425 |
| - private void onShardFailure(final int shardIndex, SearchShardTarget shard, final SearchShardIterator shardIt, Exception e) { |
| 432 | + protected final void onShardFailure(final int shardIndex, SearchShardTarget shard, final SearchShardIterator shardIt, Exception e) { |
426 | 433 | // we always add the shard failure for a specific shard instance
|
427 | 434 | // we do make sure to clean it on a successful response from a shard
|
428 | 435 | onShardFailure(shardIndex, shard, e);
|
|
0 commit comments