HBASE-7066 Some HMaster coprocessor exceptions are being swallowed in try catch blocks (Francis Liu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1404146 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-10-31 14:06:40 +00:00
parent fb983be9e3
commit 756840a814
4 changed files with 35 additions and 33 deletions

View File

@ -426,7 +426,7 @@ public class LocalHBaseCluster {
/**
* Shut down the mini HBase cluster
*/
public void shutdown() {
public void shutdown() throws IOException {
JVMClusterUtil.shutdown(this.masterThreads, this.regionThreads);
}

View File

@ -1256,7 +1256,7 @@ Server {
return balancerCutoffTime;
}
public boolean balance() {
public boolean balance() throws IOException {
// if master not initialized, don't run balancer.
if (!this.initialized) {
LOG.debug("Master has not been initialized, don't run balancer.");
@ -1285,15 +1285,10 @@ Server {
}
if (this.cpHost != null) {
try {
if (this.cpHost.preBalance()) {
LOG.debug("Coprocessor bypassing balancer request");
return false;
}
} catch (IOException ioe) {
LOG.error("Error invoking master coprocessor preBalance()", ioe);
return false;
}
}
Map<String, Map<ServerName, List<HRegionInfo>>> assignmentsByTable =
@ -1326,12 +1321,7 @@ Server {
}
}
if (this.cpHost != null) {
try {
this.cpHost.postBalance();
} catch (IOException ioe) {
// balancing already succeeded so don't change the result
LOG.error("Error invoking master coprocessor postBalance()", ioe);
}
}
}
return balancerRan;
@ -1339,7 +1329,11 @@ Server {
@Override
public BalanceResponse balance(RpcController c, BalanceRequest request) throws ServiceException {
try {
return BalanceResponse.newBuilder().setBalancerRan(balance()).build();
} catch (IOException e) {
throw new ServiceException(e);
}
}
enum BalanceSwitchMode {
@ -2005,14 +1999,10 @@ Server {
return rsFatals;
}
public void shutdown() {
public void shutdown() throws IOException {
spanReceiverHost.closeReceivers();
if (cpHost != null) {
try {
cpHost.preShutdown();
} catch (IOException ioe) {
LOG.error("Error call master coprocessor preShutdown()", ioe);
}
}
if (mxBean != null) {
MBeanUtil.unregisterMBean(mxBean);
@ -2032,17 +2022,17 @@ Server {
@Override
public ShutdownResponse shutdown(RpcController controller, ShutdownRequest request)
throws ServiceException {
try {
shutdown();
} catch (IOException e) {
throw new ServiceException(e);
}
return ShutdownResponse.newBuilder().build();
}
public void stopMaster() {
public void stopMaster() throws IOException {
if (cpHost != null) {
try {
cpHost.preStopMaster();
} catch (IOException ioe) {
LOG.error("Error call master coprocessor preStopMaster()", ioe);
}
}
stop("Stopped by " + Thread.currentThread().getName());
}
@ -2050,7 +2040,11 @@ Server {
@Override
public StopMasterResponse stopMaster(RpcController controller, StopMasterRequest request)
throws ServiceException {
try {
stopMaster();
} catch (IOException e) {
throw new ServiceException(e);
}
return StopMasterResponse.newBuilder().build();
}

View File

@ -18,17 +18,21 @@
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.master.HMaster;
import java.io.IOException;
/**
* Chore that will call HMaster.balance{@link org.apache.hadoop.hbase.master.HMaster#balance()} when
* needed.
*/
@InterfaceAudience.Private
public class BalancerChore extends Chore {
private static final Log LOG = LogFactory.getLog(BalancerChore.class);
private final HMaster master;
public BalancerChore(HMaster master) {
@ -40,6 +44,10 @@ public class BalancerChore extends Chore {
@Override
protected void chore() {
try {
master.balance();
} catch (IOException ioe) {
LOG.error("Error invoking balancer", ioe);
}
}
}

View File

@ -222,7 +222,7 @@ public class JVMClusterUtil {
* @param regionservers
*/
public static void shutdown(final List<MasterThread> masters,
final List<RegionServerThread> regionservers) {
final List<RegionServerThread> regionservers) throws IOException {
LOG.debug("Shutting down HBase Cluster");
if (masters != null) {
// Do backups first.