boolean switchBalancer(final boolean b, BalanceSwitchMode mode) throws IOException {
    boolean oldValue = server.loadBalancerStateStore.get();
    boolean newValue = b;
    try {
      if (server.cpHost != null) {
        server.cpHost.preBalanceSwitch(newValue);
      }
      if (mode == BalanceSwitchMode.SYNC) {
        synchronized (server.getLoadBalancer()) {
          server.loadBalancerStateStore.set(newValue);
        }
      } else {
        server.loadBalancerStateStore.set(newValue);
      }
      LOG.info(server.getClientIdAuditPrefix() + " set balanceSwitch=" + newValue);
      if (server.cpHost != null) {
        server.cpHost.postBalanceSwitch(oldValue, newValue);
      }
      server.getLoadBalancer().updateBalancerStatus(newValue);
    } catch (IOException ioe) {
      LOG.warn("Error flipping balance switch", ioe);
    }
    return oldValue;
  }
Assigns balancer switch according to BalanceSwitchMode
@param b    new balancer switch
@param mode BalanceSwitchMode
@return old balancer switch
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java