Fix IndexShardRoutingTable's shard randomization to not throw out-of-bounds exceptions.

I initially wanted to make the diff minimal but this ended up being quite complicated
so I finally refactored a bit the way shards are randomized. Yet, it uses the same logic:
 - rotations to shuffle shards,
 - an AtomicInteger to generate the distances to use for the rotations.

Close #5559