public ShardIterator onlyNodeSelectorActiveInitializingShardsIt(String nodeAttribute,DiscoveryNodes discoveryNodes){
  ArrayList<ShardRouting> ordered=new ArrayList<>(activeShards.size() + allInitializingShards.size());
  Set<String> selectedNodes=Sets.newHashSet(discoveryNodes.resolveNodesIds(nodeAttribute));
  for (  ShardRouting shardRouting : activeShards) {
    if (selectedNodes.contains(shardRouting.currentNodeId())) {
      ordered.add(shardRouting);
    }
  }
  for (  ShardRouting shardRouting : allInitializingShards) {
    if (selectedNodes.contains(shardRouting.currentNodeId())) {
      ordered.add(shardRouting);
    }
  }
  if (ordered.isEmpty()) {
    throw new IllegalArgumentException("No data node with critera [" + nodeAttribute + "] found");
  }
  return new PlainShardIterator(shardId,ordered);
}

public ShardIterator onlyNodeSelectorActiveInitializingShardsIt ( String nodeAttribute , DiscoveryNodes discoveryNodes ) { ArrayList < ShardRouting > ordered = new ArrayList < > ( activeShards . size ( ) + allInitializingShards . size ( ) ) ; Set < String > selectedNodes = Sets . newHashSet ( discoveryNodes . resolveNodesIds ( nodeAttribute ) ) ; for ( ShardRouting shardRouting : activeShards ) { if ( selectedNodes . contains ( shardRouting . currentNodeId ( ) ) ) { ordered . add ( shardRouting ) ; } } for ( ShardRouting shardRouting : allInitializingShards ) { if ( selectedNodes . contains ( shardRouting . currentNodeId ( ) ) ) { ordered . add ( shardRouting ) ; } } if ( ordered . isEmpty ( ) ) { throw new IllegalArgumentException ( "No data node with critera [" + nodeAttribute + "] found" ) ; } return new PlainShardIterator ( shardId , ordered ) ; }
returns shards based on nodeattributes given such as node name , node attribute , node ip supports node specifications in cluster api
