int pickRandomRegion(BalancerClusterState cluster, int server, double chanceOfNoSwap) {
    // Check to see if this is just a move.
    if (
      cluster.regionsPerServer[server].length == 0
        || ThreadLocalRandom.current().nextFloat() < chanceOfNoSwap
    ) {
      // signal a move only.
      return -1;
    }
    int rand = ThreadLocalRandom.current().nextInt(cluster.regionsPerServer[server].length);
    return cluster.regionsPerServer[server][rand];
  }
From a list of regions pick a random one. Null can be returned which
{@link StochasticLoadBalancer#balanceCluster(Map)} recognize as signal to try a region move
rather than swap.
@param cluster        The state of the cluster
@param server         index of the server
@param chanceOfNoSwap Chance that this will decide to try a move rather than a swap.
@return a random {@link RegionInfo} or null if an asymmetrical move is suggested.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CandidateGenerator.java