mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
Remove GroupShardsIterator and replace it with plain List (#116891)
There is no point in having `GroupShardsIterator`, it's mostly an unnecessary layer of indirection as it has no state and a single field only. It's only value could be seen in it hiding the ability to mutate the list it wraps, but that hardly justifies the overhead on the search path and extra code complexity. Moreover, the list it references is not copied/immutable in any way, so the value of hiding is limited also.
This commit is contained in:
parent
c1deef4467
commit
229d89d343
40 changed files with 159 additions and 436 deletions
|
@ -17,7 +17,6 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
|
@ -35,6 +34,7 @@ import org.elasticsearch.xpack.core.downsample.DownsampleShardTask;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
/**
|
||||
|
@ -79,17 +79,12 @@ public class TransportDownsampleIndexerAction extends TransportBroadcastAction<
|
|||
}
|
||||
|
||||
@Override
|
||||
protected GroupShardsIterator<ShardIterator> shards(
|
||||
ClusterState clusterState,
|
||||
DownsampleIndexerAction.Request request,
|
||||
String[] concreteIndices
|
||||
) {
|
||||
protected List<ShardIterator> shards(ClusterState clusterState, DownsampleIndexerAction.Request request, String[] concreteIndices) {
|
||||
if (concreteIndices.length > 1) {
|
||||
throw new IllegalArgumentException("multiple indices: " + Arrays.toString(concreteIndices));
|
||||
}
|
||||
|
||||
final GroupShardsIterator<ShardIterator> groups = clusterService.operationRouting()
|
||||
.searchShards(clusterState, concreteIndices, null, null);
|
||||
final List<ShardIterator> groups = clusterService.operationRouting().searchShards(clusterState, concreteIndices, null, null);
|
||||
for (ShardIterator group : groups) {
|
||||
// fails fast if any non-active groups
|
||||
if (group.size() == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue