HBASE-5630 hbck should disable the balancer using synchronousBalanceSwitch (Gregory Chanan)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1353053 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-06-23 00:38:45 +00:00
parent e88c89f01f
commit 0f558bb126
9 changed files with 29 additions and 26 deletions

View File

@ -1473,15 +1473,17 @@ public class HBaseAdmin implements Abortable, Closeable {
/** /**
* Turn the load balancer on or off. * Turn the load balancer on or off.
* @param b If true, enable balancer. If false, disable balancer. * @param on If true, enable balancer. If false, disable balancer.
* @param synchronous If true, it waits until current balance() call, if outstanding, to return.
* @return Previous balancer value * @return Previous balancer value
*/ */
public boolean balanceSwitch(final boolean b) public boolean setBalancerRunning(final boolean on, final boolean synchronous)
throws MasterNotRunningException, ZooKeeperConnectionException { throws MasterNotRunningException, ZooKeeperConnectionException {
MasterKeepAliveConnection master = connection.getKeepAliveMaster(); MasterKeepAliveConnection master = connection.getKeepAliveMaster();
try { try {
SetBalancerRunningRequest req = RequestConverter.buildLoadBalancerIsRequest(b, false); SetBalancerRunningRequest req =
return master.loadBalancerIs(null, req).getPrevBalanceValue(); RequestConverter.buildSetBalancerRunningRequest(on, synchronous);
return master.setBalancerRunning(null, req).getPrevBalanceValue();
} catch (ServiceException se) { } catch (ServiceException se) {
IOException ioe = ProtobufUtil.getRemoteException(se); IOException ioe = ProtobufUtil.getRemoteException(se);
if (ioe instanceof MasterNotRunningException) { if (ioe instanceof MasterNotRunningException) {

View File

@ -287,8 +287,8 @@ public interface HMasterInterface extends VersionedProtocol {
* - prevBalanceValue: Previous balancer value * - prevBalanceValue: Previous balancer value
* @throws ServiceException * @throws ServiceException
*/ */
public SetBalancerRunningResponse loadBalancerIs(RpcController controller, SetBalancerRunningRequest req) public SetBalancerRunningResponse setBalancerRunning(
throws ServiceException; RpcController controller, SetBalancerRunningRequest req) throws ServiceException;
/** /**
* Get list of TableDescriptors for requested tables. * Get list of TableDescriptors for requested tables.

View File

@ -1267,8 +1267,8 @@ Server {
} }
@Override @Override
public SetBalancerRunningResponse loadBalancerIs(RpcController controller, SetBalancerRunningRequest req) public SetBalancerRunningResponse setBalancerRunning(
throws ServiceException { RpcController controller, SetBalancerRunningRequest req) throws ServiceException {
boolean prevValue = (req.getSynchronous())? boolean prevValue = (req.getSynchronous())?
synchronousBalanceSwitch(req.getOn()):balanceSwitch(req.getOn()); synchronousBalanceSwitch(req.getOn()):balanceSwitch(req.getOn());
return SetBalancerRunningResponse.newBuilder().setPrevBalanceValue(prevValue).build(); return SetBalancerRunningResponse.newBuilder().setPrevBalanceValue(prevValue).build();

View File

@ -1099,7 +1099,7 @@ public final class RequestConverter {
* @param synchronous * @param synchronous
* @return a SetBalancerRunningRequest * @return a SetBalancerRunningRequest
*/ */
public static SetBalancerRunningRequest buildLoadBalancerIsRequest(boolean on, boolean synchronous) { public static SetBalancerRunningRequest buildSetBalancerRunningRequest(boolean on, boolean synchronous) {
return SetBalancerRunningRequest.newBuilder().setOn(on).setSynchronous(synchronous).build(); return SetBalancerRunningRequest.newBuilder().setOn(on).setSynchronous(synchronous).build();
} }

View File

@ -389,12 +389,12 @@ public class HBaseFsck {
offlineHdfsIntegrityRepair(); offlineHdfsIntegrityRepair();
// turn the balancer off // turn the balancer off
boolean oldBalancer = admin.balanceSwitch(false); boolean oldBalancer = admin.setBalancerRunning(false, true);
try { try {
onlineConsistencyRepair(); onlineConsistencyRepair();
} }
finally { finally {
admin.balanceSwitch(oldBalancer); admin.setBalancerRunning(oldBalancer, false);
} }
// Print table summary // Print table summary

View File

@ -88,7 +88,8 @@ module Hbase
# Enable/disable balancer # Enable/disable balancer
# Returns previous balancer switch setting. # Returns previous balancer switch setting.
def balance_switch(enableDisable) def balance_switch(enableDisable)
@admin.balanceSwitch(java.lang.Boolean::valueOf(enableDisable)) @admin.setBalancerRunning(
java.lang.Boolean::valueOf(enableDisable), java.lang.Boolean::valueOf(false))
end end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------

View File

@ -188,7 +188,7 @@ public class TestDrainingServer {
HMaster master = TEST_UTIL.getHBaseCluster().getMaster(); HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
// Ensure a stable env // Ensure a stable env
TEST_UTIL.getHBaseAdmin().balanceSwitch(false); TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, false);
waitForAllRegionsOnline(); waitForAllRegionsOnline();
final long regionCount = TEST_UTIL.getMiniHBaseCluster().countServedRegions(); final long regionCount = TEST_UTIL.getMiniHBaseCluster().countServedRegions();

View File

@ -163,7 +163,7 @@ public class TestHCM {
} }
// Now moving the region to the second server // Now moving the region to the second server
TEST_UTIL.getHBaseAdmin().balanceSwitch(false); TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, false);
HRegionLocation toMove = conn.getCachedLocation(TABLE_NAME, ROW); HRegionLocation toMove = conn.getCachedLocation(TABLE_NAME, ROW);
byte[] regionName = toMove.getRegionInfo().getRegionName(); byte[] regionName = toMove.getRegionInfo().getRegionName();

View File

@ -121,7 +121,7 @@ public class TestSplitTransactionOnCluster {
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
// Turn off balancer so it doesn't cut in and mess up our placements. // Turn off balancer so it doesn't cut in and mess up our placements.
this.admin.balanceSwitch(false); this.admin.setBalancerRunning(false, true);
// Turn off the meta scanner so it don't remove parent on us. // Turn off the meta scanner so it don't remove parent on us.
cluster.getMaster().setCatalogJanitorEnabled(false); cluster.getMaster().setCatalogJanitorEnabled(false);
try { try {
@ -172,7 +172,7 @@ public class TestSplitTransactionOnCluster {
} finally { } finally {
// Set this flag back. // Set this flag back.
SplitRegionHandler.TEST_SKIP = false; SplitRegionHandler.TEST_SKIP = false;
admin.balanceSwitch(true); admin.setBalancerRunning(true, false);
cluster.getMaster().setCatalogJanitorEnabled(true); cluster.getMaster().setCatalogJanitorEnabled(true);
} }
} }
@ -191,7 +191,7 @@ public class TestSplitTransactionOnCluster {
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
// Turn off balancer so it doesn't cut in and mess up our placements. // Turn off balancer so it doesn't cut in and mess up our placements.
this.admin.balanceSwitch(false); this.admin.setBalancerRunning(false, true);
// Turn off the meta scanner so it don't remove parent on us. // Turn off the meta scanner so it don't remove parent on us.
cluster.getMaster().setCatalogJanitorEnabled(false); cluster.getMaster().setCatalogJanitorEnabled(false);
try { try {
@ -224,7 +224,7 @@ public class TestSplitTransactionOnCluster {
assertTrue(daughters.size() >= 2); assertTrue(daughters.size() >= 2);
// OK, so split happened after we cleared the blocking node. // OK, so split happened after we cleared the blocking node.
} finally { } finally {
admin.balanceSwitch(true); admin.setBalancerRunning(true, false);
cluster.getMaster().setCatalogJanitorEnabled(true); cluster.getMaster().setCatalogJanitorEnabled(true);
} }
} }
@ -250,7 +250,7 @@ public class TestSplitTransactionOnCluster {
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
// Turn off balancer so it doesn't cut in and mess up our placements. // Turn off balancer so it doesn't cut in and mess up our placements.
this.admin.balanceSwitch(false); this.admin.setBalancerRunning(false, true);
// Turn off the meta scanner so it don't remove parent on us. // Turn off the meta scanner so it don't remove parent on us.
cluster.getMaster().setCatalogJanitorEnabled(false); cluster.getMaster().setCatalogJanitorEnabled(false);
try { try {
@ -282,7 +282,7 @@ public class TestSplitTransactionOnCluster {
assertTrue(daughters.contains(r)); assertTrue(daughters.contains(r));
} }
} finally { } finally {
admin.balanceSwitch(true); admin.setBalancerRunning(true, false);
cluster.getMaster().setCatalogJanitorEnabled(true); cluster.getMaster().setCatalogJanitorEnabled(true);
} }
} }
@ -307,7 +307,7 @@ public class TestSplitTransactionOnCluster {
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
// Turn off balancer so it doesn't cut in and mess up our placements. // Turn off balancer so it doesn't cut in and mess up our placements.
this.admin.balanceSwitch(false); this.admin.setBalancerRunning(false, true);
// Turn off the meta scanner so it don't remove parent on us. // Turn off the meta scanner so it don't remove parent on us.
cluster.getMaster().setCatalogJanitorEnabled(false); cluster.getMaster().setCatalogJanitorEnabled(false);
try { try {
@ -360,7 +360,7 @@ public class TestSplitTransactionOnCluster {
assertTrue(daughters.contains(r)); assertTrue(daughters.contains(r));
} }
} finally { } finally {
admin.balanceSwitch(true); admin.setBalancerRunning(true, false);
cluster.getMaster().setCatalogJanitorEnabled(true); cluster.getMaster().setCatalogJanitorEnabled(true);
} }
} }
@ -390,7 +390,7 @@ public class TestSplitTransactionOnCluster {
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
// Turn off balancer so it doesn't cut in and mess up our placements. // Turn off balancer so it doesn't cut in and mess up our placements.
this.admin.balanceSwitch(false); this.admin.setBalancerRunning(false, true);
// Turn off the meta scanner so it don't remove parent on us. // Turn off the meta scanner so it don't remove parent on us.
cluster.getMaster().setCatalogJanitorEnabled(false); cluster.getMaster().setCatalogJanitorEnabled(false);
try { try {
@ -442,7 +442,7 @@ public class TestSplitTransactionOnCluster {
} finally { } finally {
// Set this flag back. // Set this flag back.
SplitRegionHandler.TEST_SKIP = false; SplitRegionHandler.TEST_SKIP = false;
admin.balanceSwitch(true); admin.setBalancerRunning(true, false);
cluster.getMaster().setCatalogJanitorEnabled(true); cluster.getMaster().setCatalogJanitorEnabled(true);
} }
} }
@ -470,7 +470,7 @@ public class TestSplitTransactionOnCluster {
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri); int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
// Turn off balancer so it doesn't cut in and mess up our placements. // Turn off balancer so it doesn't cut in and mess up our placements.
this.admin.balanceSwitch(false); this.admin.setBalancerRunning(false, true);
// Turn off the meta scanner so it don't remove parent on us. // Turn off the meta scanner so it don't remove parent on us.
cluster.getMaster().setCatalogJanitorEnabled(false); cluster.getMaster().setCatalogJanitorEnabled(false);
try { try {
@ -520,7 +520,7 @@ public class TestSplitTransactionOnCluster {
} finally { } finally {
// Set this flag back. // Set this flag back.
SplitRegionHandler.TEST_SKIP = false; SplitRegionHandler.TEST_SKIP = false;
this.admin.balanceSwitch(true); this.admin.setBalancerRunning(true, false);
cluster.getMaster().setCatalogJanitorEnabled(true); cluster.getMaster().setCatalogJanitorEnabled(true);
} }
} }