public static long sizeOfRelocatingShards(RoutingNode node,ClusterInfo clusterInfo,boolean subtractShardsMovingAway,String dataPath){
  long totalSize=0;
  for (  ShardRouting routing : node.shardsWithState(ShardRoutingState.RELOCATING,ShardRoutingState.INITIALIZING)) {
    String actualPath=clusterInfo.getDataPath(routing);
    if (dataPath.equals(actualPath)) {
      if (routing.initializing() && routing.relocatingNodeId() != null) {
        totalSize+=getShardSize(routing,clusterInfo);
      }
 else       if (subtractShardsMovingAway && routing.relocating()) {
        totalSize-=getShardSize(routing,clusterInfo);
      }
    }
  }
  return totalSize;
}

public static long sizeOfRelocatingShards ( RoutingNode node , ClusterInfo clusterInfo , boolean subtractShardsMovingAway , String dataPath ) { long totalSize = 0 ; for ( ShardRouting routing : node . shardsWithState ( ShardRoutingState . RELOCATING , ShardRoutingState . INITIALIZING ) ) { String actualPath = clusterInfo . getDataPath ( routing ) ; if ( dataPath . equals ( actualPath ) ) { if ( routing . initializing ( ) && routing . relocatingNodeId ( ) != null ) { totalSize += getShardSize ( routing , clusterInfo ) ; } else if ( subtractShardsMovingAway && routing . relocating ( ) ) { totalSize -= getShardSize ( routing , clusterInfo ) ; } } } return totalSize ; }
returns the size of all shards that are currently being relocated to the node , but may not be finished transfering yet . if subtractshardsmovingaway is set then the size of shards moving away is subtracted from the total size of all shards
