HBASE-4429 Provide synchronous balanceSwitch()
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1172718 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e2884211ed
commit
e1244033bf
|
@ -536,6 +536,7 @@ Release 0.91.0 - Unreleased
|
|||
HBASE-4296 Deprecate HTable[Interface].getRowOrBefore(...) (Lars Hofhansl)
|
||||
HBASE-2195 Support cyclic replication (Lars Hofhansl)
|
||||
HBASE-2196 Support more than one slave cluster (Lars Hofhansl)
|
||||
HBASE-4429 Provide synchronous balanceSwitch()
|
||||
|
||||
NEW FEATURES
|
||||
HBASE-2001 Coprocessors: Colocate user code with regions (Mingjie Lai via
|
||||
|
|
|
@ -230,6 +230,14 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||
*/
|
||||
public boolean balanceSwitch(final boolean b);
|
||||
|
||||
/**
|
||||
* Turn the load balancer on or off.
|
||||
* It waits until current balance() call, if outstanding, to return.
|
||||
* @param b If true, enable balancer. If false, disable balancer.
|
||||
* @return Previous balancer value
|
||||
*/
|
||||
public boolean synchronousBalanceSwitch(final boolean b);
|
||||
|
||||
/**
|
||||
* Get array of all HTDs.
|
||||
* @return array of HTableDescriptor
|
||||
|
|
|
@ -876,23 +876,48 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
|
|||
return balancerRan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean balanceSwitch(final boolean b) {
|
||||
enum BalanceSwitchMode {
|
||||
SYNC,
|
||||
ASYNC
|
||||
}
|
||||
/**
|
||||
* Assigns balancer switch according to BalanceSwitchMode
|
||||
* @param b new balancer switch
|
||||
* @param mode BalanceSwitchMode
|
||||
* @return old balancer switch
|
||||
*/
|
||||
public boolean switchBalancer(final boolean b, BalanceSwitchMode mode) {
|
||||
boolean oldValue = this.balanceSwitch;
|
||||
boolean newValue = b;
|
||||
try {
|
||||
if (this.cpHost != null) {
|
||||
newValue = this.cpHost.preBalanceSwitch(newValue);
|
||||
}
|
||||
this.balanceSwitch = newValue;
|
||||
LOG.info("Balance=" + newValue);
|
||||
if (mode == BalanceSwitchMode.SYNC) {
|
||||
synchronized (this.balancer) {
|
||||
this.balanceSwitch = newValue;
|
||||
}
|
||||
} else {
|
||||
this.balanceSwitch = newValue;
|
||||
}
|
||||
LOG.info("BalanceSwitch=" + newValue);
|
||||
if (this.cpHost != null) {
|
||||
this.cpHost.postBalanceSwitch(oldValue, newValue);
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
LOG.warn("Error flipping balance switch", ioe);
|
||||
}
|
||||
return oldValue;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean synchronousBalanceSwitch(final boolean b) {
|
||||
return switchBalancer(b, BalanceSwitchMode.SYNC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean balanceSwitch(final boolean b) {
|
||||
return switchBalancer(b, BalanceSwitchMode.ASYNC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue