HBASE-9191 Update Loadbalancer method to throw HBaseIOException
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1514155 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef0a055787
commit
7170a40dec
|
@ -45,6 +45,7 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.Chore;
|
||||
import org.apache.hadoop.hbase.HBaseIOException;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.exceptions.DeserializationException;
|
||||
|
@ -950,8 +951,12 @@ public class AssignmentManager extends ZooKeeperListener {
|
|||
if (regionState != null) {
|
||||
// When there are more than one region server a new RS is selected as the
|
||||
// destination and the same is updated in the regionplan. (HBASE-5546)
|
||||
getRegionPlan(regionState.getRegion(), sn, true);
|
||||
new ClosedRegionHandler(server, this, regionState.getRegion()).process();
|
||||
try {
|
||||
getRegionPlan(regionState.getRegion(), sn, true);
|
||||
new ClosedRegionHandler(server, this, regionState.getRegion()).process();
|
||||
} catch (HBaseIOException e) {
|
||||
LOG.warn("Failed to get region plan", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1824,7 +1829,11 @@ public class AssignmentManager extends ZooKeeperListener {
|
|||
RegionOpeningState regionOpenState;
|
||||
for (int i = 1; i <= maximumAttempts && !server.isStopped(); i++) {
|
||||
if (plan == null) { // Get a server for the region at first
|
||||
plan = getRegionPlan(region, forceNewPlan);
|
||||
try {
|
||||
plan = getRegionPlan(region, forceNewPlan);
|
||||
} catch (HBaseIOException e) {
|
||||
LOG.warn("Failed to get region plan", e);
|
||||
}
|
||||
}
|
||||
if (plan == null) {
|
||||
LOG.warn("Unable to determine a plan to assign " + region);
|
||||
|
@ -1989,8 +1998,12 @@ public class AssignmentManager extends ZooKeeperListener {
|
|||
// The new plan could be the same as the existing plan since we don't
|
||||
// exclude the server of the original plan, which should not be
|
||||
// excluded since it could be the only server up now.
|
||||
RegionPlan newPlan = getRegionPlan(region, true);
|
||||
|
||||
RegionPlan newPlan = null;
|
||||
try {
|
||||
newPlan = getRegionPlan(region, true);
|
||||
} catch (HBaseIOException e) {
|
||||
LOG.warn("Failed to get region plan", e);
|
||||
}
|
||||
if (newPlan == null) {
|
||||
if (tomActivated) {
|
||||
this.timeoutMonitor.setAllRegionServersOffline(true);
|
||||
|
@ -2091,7 +2104,7 @@ public class AssignmentManager extends ZooKeeperListener {
|
|||
* if no servers to assign, it returns null).
|
||||
*/
|
||||
private RegionPlan getRegionPlan(final HRegionInfo region,
|
||||
final boolean forceNewPlan) {
|
||||
final boolean forceNewPlan) throws HBaseIOException {
|
||||
return getRegionPlan(region, null, forceNewPlan);
|
||||
}
|
||||
|
||||
|
@ -2105,7 +2118,7 @@ public class AssignmentManager extends ZooKeeperListener {
|
|||
* if no servers to assign, it returns null).
|
||||
*/
|
||||
private RegionPlan getRegionPlan(final HRegionInfo region,
|
||||
final ServerName serverToExclude, final boolean forceNewPlan) {
|
||||
final ServerName serverToExclude, final boolean forceNewPlan) throws HBaseIOException {
|
||||
// Pickup existing plan or make a new one
|
||||
final String encodedName = region.getEncodedName();
|
||||
final List<ServerName> destServers =
|
||||
|
|
|
@ -1479,7 +1479,7 @@ MasterServices, Server {
|
|||
return balancerCutoffTime;
|
||||
}
|
||||
|
||||
public boolean balance() {
|
||||
public boolean balance() throws HBaseIOException {
|
||||
// if master not initialized, don't run balancer.
|
||||
if (!this.initialized) {
|
||||
LOG.debug("Master has not been initialized, don't run balancer.");
|
||||
|
@ -1564,7 +1564,11 @@ MasterServices, Server {
|
|||
|
||||
@Override
|
||||
public BalanceResponse balance(RpcController c, BalanceRequest request) throws ServiceException {
|
||||
return BalanceResponse.newBuilder().setBalancerRan(balance()).build();
|
||||
try {
|
||||
return BalanceResponse.newBuilder().setBalancerRan(balance()).build();
|
||||
} catch (HBaseIOException ex) {
|
||||
throw new ServiceException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
enum BalanceSwitchMode {
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
|||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.conf.Configurable;
|
||||
import org.apache.hadoop.hbase.ClusterStatus;
|
||||
import org.apache.hadoop.hbase.HBaseIOException;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
|
||||
|
@ -64,7 +65,8 @@ public interface LoadBalancer extends Configurable {
|
|||
* @param clusterState
|
||||
* @return List of plans
|
||||
*/
|
||||
List<RegionPlan> balanceCluster(Map<ServerName, List<HRegionInfo>> clusterState);
|
||||
List<RegionPlan> balanceCluster(Map<ServerName,
|
||||
List<HRegionInfo>> clusterState) throws HBaseIOException;
|
||||
|
||||
/**
|
||||
* Perform a Round Robin assignment of regions.
|
||||
|
@ -75,7 +77,7 @@ public interface LoadBalancer extends Configurable {
|
|||
Map<ServerName, List<HRegionInfo>> roundRobinAssignment(
|
||||
List<HRegionInfo> regions,
|
||||
List<ServerName> servers
|
||||
);
|
||||
) throws HBaseIOException;
|
||||
|
||||
/**
|
||||
* Assign regions to the previously hosting region server
|
||||
|
@ -86,7 +88,7 @@ public interface LoadBalancer extends Configurable {
|
|||
Map<ServerName, List<HRegionInfo>> retainAssignment(
|
||||
Map<HRegionInfo, ServerName> regions,
|
||||
List<ServerName> servers
|
||||
);
|
||||
) throws HBaseIOException;
|
||||
|
||||
/**
|
||||
* Sync assign a region
|
||||
|
@ -97,7 +99,7 @@ public interface LoadBalancer extends Configurable {
|
|||
Map<HRegionInfo, ServerName> immediateAssignment(
|
||||
List<HRegionInfo> regions,
|
||||
List<ServerName> servers
|
||||
);
|
||||
) throws HBaseIOException;
|
||||
|
||||
/**
|
||||
* Get a random region server from the list
|
||||
|
@ -107,5 +109,5 @@ public interface LoadBalancer extends Configurable {
|
|||
*/
|
||||
ServerName randomAssignment(
|
||||
HRegionInfo regionInfo, List<ServerName> servers
|
||||
);
|
||||
) throws HBaseIOException;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
|
||||
package org.apache.hadoop.hbase.master.balancer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.Chore;
|
||||
import org.apache.hadoop.hbase.HBaseIOException;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
|
||||
/**
|
||||
|
@ -28,6 +31,7 @@ import org.apache.hadoop.hbase.master.HMaster;
|
|||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class BalancerChore extends Chore {
|
||||
private static final Log LOG = LogFactory.getLog(BalancerChore.class);
|
||||
|
||||
private final HMaster master;
|
||||
|
||||
|
@ -40,6 +44,10 @@ public class BalancerChore extends Chore {
|
|||
|
||||
@Override
|
||||
protected void chore() {
|
||||
master.balance();
|
||||
try {
|
||||
master.balance();
|
||||
} catch (HBaseIOException e) {
|
||||
LOG.error("Failed to balance.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseIOException;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
|
@ -93,7 +94,7 @@ public class TestRegionPlacement {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFavoredNodesPresentForRoundRobinAssignment() {
|
||||
public void testFavoredNodesPresentForRoundRobinAssignment() throws HBaseIOException {
|
||||
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(TEST_UTIL.getConfiguration());
|
||||
balancer.setMasterServices(TEST_UTIL.getMiniHBaseCluster().getMaster());
|
||||
List<ServerName> servers = new ArrayList<ServerName>();
|
||||
|
@ -153,7 +154,7 @@ public class TestRegionPlacement {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFavoredNodesPresentForRandomAssignment() {
|
||||
public void testFavoredNodesPresentForRandomAssignment() throws HBaseIOException {
|
||||
LoadBalancer balancer = LoadBalancerFactory.getLoadBalancer(TEST_UTIL.getConfiguration());
|
||||
balancer.setMasterServices(TEST_UTIL.getMiniHBaseCluster().getMaster());
|
||||
List<ServerName> servers = new ArrayList<ServerName>();
|
||||
|
|
Loading…
Reference in New Issue