protected BalanceAction getAction(int fromServer, int fromRegion, int toServer, int toRegion) {
    if (fromServer < 0 || toServer < 0) {
      return BalanceAction.NULL_ACTION;
    }
    if (fromRegion >= 0 && toRegion >= 0) {
      return new SwapRegionsAction(fromServer, fromRegion, toServer, toRegion);
    } else if (fromRegion >= 0) {
      return new MoveRegionAction(fromRegion, fromServer, toServer);
    } else if (toRegion >= 0) {
      return new MoveRegionAction(toRegion, toServer, fromServer);
    } else {
      return BalanceAction.NULL_ACTION;
    }
  }
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