query/src/main/java/org/infinispan/query/affinity/FixedShardsDistribution.java
/**
    * Allocates shards in a round robin fashion for the servers, ignoring those without segments.
    *
    * @return int[] with the number of shards per server
    */
Allocates shards in a round robin fashion for the servers, ignoring those without segments.
@return int[] with the number of shards per server
Allocates shards in a round robin fashion for the servers ignoring those without segments . @return int [] with the number of shards per server
private static int[] allocateShardsToNodes(int numShards, int numNodes, List<Set<Integer>> weightPerServer) {
      int[] shardsPerServer = new int[numNodes];
      Iterator<Integer> cyclicNodeIterator = Stream.iterate(0, i -> (i + 1) % numNodes).iterator();
      while (numShards > 0) {
         int slot = cyclicNodeIterator.next();
         if (!weightPerServer.get(slot).isEmpty()) {
            shardsPerServer[slot]++;
            numShards--;
         }
      }
      return shardsPerServer;
   }
private static int [ ] allocateShardsToNodes ( int numShards , int numNodes , List < Set < Integer > > weightPerServer ) { int [ ] shardsPerServer = new int [ numNodes ] ; Iterator < Integer > cyclicNodeIterator = Stream . iterate ( 0 , i -> ( i + 1 ) % numNodes ) . iterator ( ) ; while ( numShards > 0 ) { int slot = cyclicNodeIterator . next ( ) ; if ( ! weightPerServer . get ( slot ) . isEmpty ( ) ) { shardsPerServer [ slot ] ++ ; numShards -- ; } } return shardsPerServer ; }
Allocates shards in a round robin fashion for the servers, ignoring those without segments.
Allocates shards in a round robin fashion for the servers ignoring those without segments .