Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.UnassignedInfo;
Expand Down Expand Up @@ -531,9 +531,9 @@ public void testResolvePath() throws Exception {
nodeNameToNodeId.put(cursor.getValue().getName(), cursor.getKey());
}

final GroupShardsIterator<ShardIterator> shardIterators = state.getRoutingTable()
final GroupShardsIterator<PlainShardIterator> shardIterators = state.getRoutingTable()
.activePrimaryShardsGrouped(new String[] { indexName }, false);
final List<ShardIterator> iterators = iterableAsArrayList(shardIterators);
final List<PlainShardIterator> iterators = iterableAsArrayList(shardIterators);
final ShardRouting shardRouting = iterators.iterator().next().nextOrNull();
assertThat(shardRouting, notNullValue());
final ShardId shardId = shardRouting.shardId();
Expand Down Expand Up @@ -571,10 +571,10 @@ public void testResolvePath() throws Exception {

private Path getPathToShardData(String indexName, String dirSuffix) {
ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator<ShardIterator> shardIterators = state.getRoutingTable()
GroupShardsIterator<PlainShardIterator> shardIterators = state.getRoutingTable()
.activePrimaryShardsGrouped(new String[] { indexName }, false);
List<ShardIterator> iterators = iterableAsArrayList(shardIterators);
ShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators);
List<PlainShardIterator> iterators = iterableAsArrayList(shardIterators);
PlainShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators);
ShardRouting shardRouting = shardIterator.nextOrNull();
assertNotNull(shardRouting);
assertTrue(shardRouting.primary());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
Expand Down Expand Up @@ -311,9 +311,9 @@ public void testCorruptPrimaryNoReplica() throws ExecutionException, Interrupted
}
assertThat(response.getStatus(), is(ClusterHealthStatus.RED));
ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator<ShardIterator> shardIterators = state.getRoutingTable()
GroupShardsIterator<PlainShardIterator> shardIterators = state.getRoutingTable()
.activePrimaryShardsGrouped(new String[] { "test" }, false);
for (ShardIterator iterator : shardIterators) {
for (PlainShardIterator iterator : shardIterators) {
ShardRouting routing;
while ((routing = iterator.nextOrNull()) != null) {
if (routing.getId() == shardRouting.getId()) {
Expand Down Expand Up @@ -695,10 +695,10 @@ private ShardRouting corruptRandomPrimaryFile() throws IOException {
private ShardRouting corruptRandomPrimaryFile(final boolean includePerCommitFiles) throws IOException {
ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
Index test = state.metadata().index("test").getIndex();
GroupShardsIterator<ShardIterator> shardIterators = state.getRoutingTable()
GroupShardsIterator<PlainShardIterator> shardIterators = state.getRoutingTable()
.activePrimaryShardsGrouped(new String[] { "test" }, false);
List<ShardIterator> iterators = iterableAsArrayList(shardIterators);
ShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators);
List<PlainShardIterator> iterators = iterableAsArrayList(shardIterators);
PlainShardIterator shardIterator = RandomPicks.randomFrom(random(), iterators);
ShardRouting shardRouting = shardIterator.nextOrNull();
assertNotNull(shardRouting);
assertTrue(shardRouting.primary());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.index.search.stats.SearchStats;
import org.elasticsearch.search.suggest.SuggestBuilder;
Expand Down Expand Up @@ -146,9 +146,9 @@ private SearchRequestBuilder addSuggestions(SearchRequestBuilder request, int i)

private Set<String> nodeIdsWithIndex(String... indices) {
ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator<ShardIterator> allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
GroupShardsIterator<PlainShardIterator> allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
Set<String> nodes = new HashSet<>();
for (ShardIterator shardIterator : allAssignedShardsGrouped) {
for (PlainShardIterator shardIterator : allAssignedShardsGrouped) {
for (ShardRouting routing : shardIterator) {
if (routing.active()) {
nodes.add(routing.currentNodeId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue;
Expand Down Expand Up @@ -165,9 +165,9 @@ public void testSimpleStats() throws Exception {

private Set<String> nodeIdsWithIndex(String... indices) {
ClusterState state = clusterAdmin().prepareState(TEST_REQUEST_TIMEOUT).get().getState();
GroupShardsIterator<ShardIterator> allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
GroupShardsIterator<PlainShardIterator> allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true);
Set<String> nodes = new HashSet<>();
for (ShardIterator shardIterator : allAssignedShardsGrouped) {
for (PlainShardIterator shardIterator : allAssignedShardsGrouped) {
for (ShardRouting routing : shardIterator) {
if (routing.active()) {
nodes.add(routing.currentNodeId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.ResolvedExpression;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.core.Predicates;
Expand Down Expand Up @@ -100,12 +100,12 @@ protected void masterOperation(
}

Set<String> nodeIds = new HashSet<>();
GroupShardsIterator<ShardIterator> groupShardsIterator = clusterService.operationRouting()
GroupShardsIterator<PlainShardIterator> groupShardsIterator = clusterService.operationRouting()
.searchShards(clusterState, concreteIndices, routingMap, request.preference());
ShardRouting shard;
ClusterSearchShardsGroup[] groupResponses = new ClusterSearchShardsGroup[groupShardsIterator.size()];
int currentGroup = 0;
for (ShardIterator shardIt : groupShardsIterator) {
for (PlainShardIterator shardIt : groupShardsIterator) {
ShardId shardId = shardIt.shardId();
ShardRouting[] shardRoutings = new ShardRouting[shardIt.size()];
int currentShard = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -214,14 +214,14 @@ protected AnalyzeIndexDiskUsageResponse newResponse(
}

@Override
protected GroupShardsIterator<ShardIterator> shards(
protected GroupShardsIterator<PlainShardIterator> shards(
ClusterState clusterState,
AnalyzeIndexDiskUsageRequest request,
String[] concreteIndices
) {
final GroupShardsIterator<ShardIterator> groups = clusterService.operationRouting()
final GroupShardsIterator<PlainShardIterator> groups = clusterService.operationRouting()
.searchShards(clusterState, concreteIndices, null, null);
for (ShardIterator group : groups) {
for (PlainShardIterator group : groups) {
// fails fast if any non-active groups
if (group.size() == 0) {
throw new NoShardAvailableActionException(group.shardId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.ResolvedExpression;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.ParsingException;
Expand Down Expand Up @@ -145,7 +145,11 @@ protected ShardValidateQueryResponse readShardResponse(StreamInput in) throws IO
}

@Override
protected GroupShardsIterator<ShardIterator> shards(ClusterState clusterState, ValidateQueryRequest request, String[] concreteIndices) {
protected GroupShardsIterator<PlainShardIterator> shards(
ClusterState clusterState,
ValidateQueryRequest request,
String[] concreteIndices
) {
final String routing;
if (request.allShards()) {
routing = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.ResolvedExpression;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.Releasables;
Expand Down Expand Up @@ -172,7 +172,7 @@ protected Writeable.Reader<ExplainResponse> getResponseReader() {
}

@Override
protected ShardIterator shards(ClusterState state, InternalRequest request) {
protected PlainShardIterator shards(ClusterState state, InternalRequest request) {
return clusterService.operationRouting()
.getShards(
clusterService.state(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
Expand Down Expand Up @@ -93,7 +93,7 @@ final class RequestDispatcher {
this.onComplete = new RunOnce(onComplete);
this.indexSelectors = ConcurrentCollections.newConcurrentMap();
for (String index : indices) {
final GroupShardsIterator<ShardIterator> shardIts;
final GroupShardsIterator<PlainShardIterator> shardIts;
try {
shardIts = clusterService.operationRouting().searchShards(clusterState, new String[] { index }, null, null, null, null);
} catch (Exception e) {
Expand Down Expand Up @@ -250,8 +250,8 @@ private static class IndexSelector {
private final Set<ShardId> unmatchedShardIds = new HashSet<>();
private final Map<ShardId, Exception> failures = new HashMap<>();

IndexSelector(GroupShardsIterator<ShardIterator> shardIts) {
for (ShardIterator shardIt : shardIts) {
IndexSelector(GroupShardsIterator<PlainShardIterator> shardIts) {
for (PlainShardIterator shardIt : shardIts) {
for (ShardRouting shard : shardIt) {
nodeToShards.computeIfAbsent(shard.currentNodeId(), node -> new ArrayList<>()).add(shard);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -97,8 +96,8 @@ protected boolean resolveIndex(GetRequest request) {
}

@Override
protected ShardIterator shards(ClusterState state, InternalRequest request) {
ShardIterator iterator = clusterService.operationRouting()
protected PlainShardIterator shards(ClusterState state, InternalRequest request) {
PlainShardIterator iterator = clusterService.operationRouting()
.getShards(
clusterService.state(),
request.concreteIndex(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -107,8 +106,8 @@ protected boolean resolveIndex(MultiGetShardRequest request) {
}

@Override
protected ShardIterator shards(ClusterState state, InternalRequest request) {
ShardIterator iterator = clusterService.operationRouting()
protected PlainShardIterator shards(ClusterState state, InternalRequest request) {
PlainShardIterator iterator = clusterService.operationRouting()
.getShards(state, request.request().index(), request.request().shardId(), request.request().preference());
if (iterator == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.GroupShardsIterator;
import org.elasticsearch.cluster.routing.OperationRouting;
import org.elasticsearch.cluster.routing.ShardIterator;
import org.elasticsearch.cluster.routing.PlainShardIterator;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -1800,7 +1800,7 @@ static List<SearchShardIterator> getLocalShardsIteratorFromPointInTime(
// Otherwise, we add the shard iterator without a target node, allowing a partial search failure to
// be thrown when a search phase attempts to access it.
try {
final ShardIterator shards = OperationRouting.getShards(clusterState, shardId);
final PlainShardIterator shards = OperationRouting.getShards(clusterState, shardId);
// Prefer executing shard requests on nodes that are part of PIT first.
if (clusterState.nodes().nodeExists(perNode.getNode())) {
targetNodes.add(perNode.getNode());
Expand Down Expand Up @@ -1851,7 +1851,7 @@ List<SearchShardIterator> getLocalShardsIterator(
String[] concreteIndices
) {
var routingMap = indexNameExpressionResolver.resolveSearchRouting(clusterState, searchRequest.routing(), searchRequest.indices());
GroupShardsIterator<ShardIterator> shardRoutings = clusterService.operationRouting()
GroupShardsIterator<PlainShardIterator> shardRoutings = clusterService.operationRouting()
.searchShards(
clusterState,
concreteIndices,
Expand All @@ -1868,7 +1868,7 @@ List<SearchShardIterator> getLocalShardsIterator(
);
SearchShardIterator[] list = new SearchShardIterator[shardRoutings.size()];
int i = 0;
for (ShardIterator shardRouting : shardRoutings) {
for (PlainShardIterator shardRouting : shardRoutings) {
final ShardId shardId = shardRouting.shardId();
OriginalIndices finalIndices = originalIndices.get(shardId.getIndex().getName());
assert finalIndices != null;
Expand Down
Loading