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:
parent
e88c89f01f
commit
0f558bb126
|
@ -1473,15 +1473,17 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public boolean balanceSwitch(final boolean b)
|
||||
public boolean setBalancerRunning(final boolean on, final boolean synchronous)
|
||||
throws MasterNotRunningException, ZooKeeperConnectionException {
|
||||
MasterKeepAliveConnection master = connection.getKeepAliveMaster();
|
||||
try {
|
||||
SetBalancerRunningRequest req = RequestConverter.buildLoadBalancerIsRequest(b, false);
|
||||
return master.loadBalancerIs(null, req).getPrevBalanceValue();
|
||||
SetBalancerRunningRequest req =
|
||||
RequestConverter.buildSetBalancerRunningRequest(on, synchronous);
|
||||
return master.setBalancerRunning(null, req).getPrevBalanceValue();
|
||||
} catch (ServiceException se) {
|
||||
IOException ioe = ProtobufUtil.getRemoteException(se);
|
||||
if (ioe instanceof MasterNotRunningException) {
|
||||
|
|
|
@ -287,8 +287,8 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||
* - prevBalanceValue: Previous balancer value
|
||||
* @throws ServiceException
|
||||
*/
|
||||
public SetBalancerRunningResponse loadBalancerIs(RpcController controller, SetBalancerRunningRequest req)
|
||||
throws ServiceException;
|
||||
public SetBalancerRunningResponse setBalancerRunning(
|
||||
RpcController controller, SetBalancerRunningRequest req) throws ServiceException;
|
||||
|
||||
/**
|
||||
* Get list of TableDescriptors for requested tables.
|
||||
|
|
|
@ -1267,8 +1267,8 @@ Server {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SetBalancerRunningResponse loadBalancerIs(RpcController controller, SetBalancerRunningRequest req)
|
||||
throws ServiceException {
|
||||
public SetBalancerRunningResponse setBalancerRunning(
|
||||
RpcController controller, SetBalancerRunningRequest req) throws ServiceException {
|
||||
boolean prevValue = (req.getSynchronous())?
|
||||
synchronousBalanceSwitch(req.getOn()):balanceSwitch(req.getOn());
|
||||
return SetBalancerRunningResponse.newBuilder().setPrevBalanceValue(prevValue).build();
|
||||
|
|
|
@ -1099,7 +1099,7 @@ public final class RequestConverter {
|
|||
* @param synchronous
|
||||
* @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();
|
||||
}
|
||||
|
||||
|
|
|
@ -389,12 +389,12 @@ public class HBaseFsck {
|
|||
offlineHdfsIntegrityRepair();
|
||||
|
||||
// turn the balancer off
|
||||
boolean oldBalancer = admin.balanceSwitch(false);
|
||||
boolean oldBalancer = admin.setBalancerRunning(false, true);
|
||||
try {
|
||||
onlineConsistencyRepair();
|
||||
}
|
||||
finally {
|
||||
admin.balanceSwitch(oldBalancer);
|
||||
admin.setBalancerRunning(oldBalancer, false);
|
||||
}
|
||||
|
||||
// Print table summary
|
||||
|
|
|
@ -88,7 +88,8 @@ module Hbase
|
|||
# Enable/disable balancer
|
||||
# Returns previous balancer switch setting.
|
||||
def balance_switch(enableDisable)
|
||||
@admin.balanceSwitch(java.lang.Boolean::valueOf(enableDisable))
|
||||
@admin.setBalancerRunning(
|
||||
java.lang.Boolean::valueOf(enableDisable), java.lang.Boolean::valueOf(false))
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -188,7 +188,7 @@ public class TestDrainingServer {
|
|||
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
|
||||
|
||||
// Ensure a stable env
|
||||
TEST_UTIL.getHBaseAdmin().balanceSwitch(false);
|
||||
TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, false);
|
||||
waitForAllRegionsOnline();
|
||||
|
||||
final long regionCount = TEST_UTIL.getMiniHBaseCluster().countServedRegions();
|
||||
|
|
|
@ -163,7 +163,7 @@ public class TestHCM {
|
|||
}
|
||||
|
||||
// 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);
|
||||
byte[] regionName = toMove.getRegionInfo().getRegionName();
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public class TestSplitTransactionOnCluster {
|
|||
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
|
||||
|
||||
// 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.
|
||||
cluster.getMaster().setCatalogJanitorEnabled(false);
|
||||
try {
|
||||
|
@ -172,7 +172,7 @@ public class TestSplitTransactionOnCluster {
|
|||
} finally {
|
||||
// Set this flag back.
|
||||
SplitRegionHandler.TEST_SKIP = false;
|
||||
admin.balanceSwitch(true);
|
||||
admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class TestSplitTransactionOnCluster {
|
|||
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
|
||||
|
||||
// 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.
|
||||
cluster.getMaster().setCatalogJanitorEnabled(false);
|
||||
try {
|
||||
|
@ -224,7 +224,7 @@ public class TestSplitTransactionOnCluster {
|
|||
assertTrue(daughters.size() >= 2);
|
||||
// OK, so split happened after we cleared the blocking node.
|
||||
} finally {
|
||||
admin.balanceSwitch(true);
|
||||
admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ public class TestSplitTransactionOnCluster {
|
|||
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
|
||||
|
||||
// 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.
|
||||
cluster.getMaster().setCatalogJanitorEnabled(false);
|
||||
try {
|
||||
|
@ -282,7 +282,7 @@ public class TestSplitTransactionOnCluster {
|
|||
assertTrue(daughters.contains(r));
|
||||
}
|
||||
} finally {
|
||||
admin.balanceSwitch(true);
|
||||
admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ public class TestSplitTransactionOnCluster {
|
|||
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
|
||||
|
||||
// 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.
|
||||
cluster.getMaster().setCatalogJanitorEnabled(false);
|
||||
try {
|
||||
|
@ -360,7 +360,7 @@ public class TestSplitTransactionOnCluster {
|
|||
assertTrue(daughters.contains(r));
|
||||
}
|
||||
} finally {
|
||||
admin.balanceSwitch(true);
|
||||
admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ public class TestSplitTransactionOnCluster {
|
|||
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
|
||||
|
||||
// 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.
|
||||
cluster.getMaster().setCatalogJanitorEnabled(false);
|
||||
try {
|
||||
|
@ -442,7 +442,7 @@ public class TestSplitTransactionOnCluster {
|
|||
} finally {
|
||||
// Set this flag back.
|
||||
SplitRegionHandler.TEST_SKIP = false;
|
||||
admin.balanceSwitch(true);
|
||||
admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ public class TestSplitTransactionOnCluster {
|
|||
int tableRegionIndex = ensureTableRegionNotOnSameServerAsMeta(admin, hri);
|
||||
|
||||
// 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.
|
||||
cluster.getMaster().setCatalogJanitorEnabled(false);
|
||||
try {
|
||||
|
@ -520,7 +520,7 @@ public class TestSplitTransactionOnCluster {
|
|||
} finally {
|
||||
// Set this flag back.
|
||||
SplitRegionHandler.TEST_SKIP = false;
|
||||
this.admin.balanceSwitch(true);
|
||||
this.admin.setBalancerRunning(true, false);
|
||||
cluster.getMaster().setCatalogJanitorEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue