data/raw/hbase/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
/**
   * Assigns balancer switch according to BalanceSwitchMode
   * @param b new balancer switch
   * @param mode BalanceSwitchMode
   * @return old balancer switch
   */
Assigns balancer switch according to BalanceSwitchMode
@param b new balancer switch
@param mode BalanceSwitchMode
@return old balancer switch
Assigns balancer switch according to BalanceSwitchMode @param b new balancer switch @param mode BalanceSwitchMode @return old balancer switch
boolean switchBalancer(final boolean b, BalanceSwitchMode mode) throws IOException {
    boolean oldValue = master.loadBalancerTracker.isBalancerOn();
    boolean newValue = b;
    try {
      if (master.cpHost != null) {
        master.cpHost.preBalanceSwitch(newValue);
      }
      try {
        if (mode == BalanceSwitchMode.SYNC) {
          synchronized (master.getLoadBalancer()) {
            master.loadBalancerTracker.setBalancerOn(newValue);
          }
        } else {
          master.loadBalancerTracker.setBalancerOn(newValue);
        }
      } catch (KeeperException ke) {
        throw new IOException(ke);
      }
      LOG.info(master.getClientIdAuditPrefix() + " set balanceSwitch=" + newValue);
      if (master.cpHost != null) {
        master.cpHost.postBalanceSwitch(oldValue, newValue);
      }
      master.getLoadBalancer().updateBalancerStatus(newValue);
    } catch (IOException ioe) {
      LOG.warn("Error flipping balance switch", ioe);
    }
    return oldValue;
  }
boolean switchBalancer ( final boolean b , BalanceSwitchMode mode ) throws IOException { boolean oldValue = master . loadBalancerTracker . isBalancerOn ( ) ; boolean newValue = b ; try { if ( master . cpHost != null ) { master . cpHost . preBalanceSwitch ( newValue ) ; } try { if ( mode == BalanceSwitchMode . SYNC ) { synchronized ( master . getLoadBalancer ( ) ) { master . loadBalancerTracker . setBalancerOn ( newValue ) ; } } else { master . loadBalancerTracker . setBalancerOn ( newValue ) ; } } catch ( KeeperException ke ) { throw new IOException ( ke ) ; } LOG . info ( master . getClientIdAuditPrefix ( ) + " set balanceSwitch=" + newValue ) ; if ( master . cpHost != null ) { master . cpHost . postBalanceSwitch ( oldValue , newValue ) ; } master . 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
Assigns balancer switch according to BalanceSwitchMode @param b new balancer switch @param mode BalanceSwitchMode @return old balancer switch