mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-01 08:29:09 +00:00
Don't iterate over shard routing if it's null
This commit is contained in:
parent
43d0d3e11f
commit
3b753ea4c9
@ -33,6 +33,7 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|||||||
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
import org.elasticsearch.cluster.routing.IndexRoutingTable;
|
||||||
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
||||||
import org.elasticsearch.cluster.routing.RestoreSource;
|
import org.elasticsearch.cluster.routing.RestoreSource;
|
||||||
|
import org.elasticsearch.cluster.routing.RoutingNode;
|
||||||
import org.elasticsearch.cluster.routing.RoutingNodes;
|
import org.elasticsearch.cluster.routing.RoutingNodes;
|
||||||
import org.elasticsearch.cluster.routing.RoutingTable;
|
import org.elasticsearch.cluster.routing.RoutingTable;
|
||||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||||
@ -313,9 +314,13 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Index> hasAllocations = new HashSet<>();
|
final Set<Index> hasAllocations = new HashSet<>();
|
||||||
for (ShardRouting routing : event.state().getRoutingNodes().node(event.state().nodes().localNodeId())) {
|
final RoutingNode node = event.state().getRoutingNodes().node(event.state().nodes().localNodeId());
|
||||||
hasAllocations.add(routing.index());
|
// if no shards are allocated ie. if this node is a master-only node it can return nul
|
||||||
|
if (node != null) {
|
||||||
|
for (ShardRouting routing : node) {
|
||||||
|
hasAllocations.add(routing.index());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (IndexService indexService : indicesService) {
|
for (IndexService indexService : indicesService) {
|
||||||
Index index = indexService.index();
|
Index index = indexService.index();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user