HBASE-8800 Return non-zero exit codes when a region server aborts

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1496559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2013-06-25 17:46:51 +00:00
parent 6f54a1d4b3
commit 9a151d2e73
2 changed files with 33 additions and 23 deletions

View File

@ -84,7 +84,7 @@ public class HMasterCommandLine extends ServerCommandLine {
} catch (ParseException e) {
LOG.error("Could not parse: ", e);
usage(null);
return -1;
return 1;
}
@ -125,7 +125,7 @@ public class HMasterCommandLine extends ServerCommandLine {
List<String> remainingArgs = cmd.getArgList();
if (remainingArgs.size() != 1) {
usage(null);
return -1;
return 1;
}
String command = remainingArgs.get(0);
@ -135,10 +135,10 @@ public class HMasterCommandLine extends ServerCommandLine {
} else if ("stop".equals(command)) {
return stopMaster();
} else if ("clear".equals(command)) {
return (ZNodeClearer.clear(getConf()) ? 0 : -1);
return (ZNodeClearer.clear(getConf()) ? 0 : 1);
} else {
usage("Invalid command: " + command);
return -1;
return 1;
}
}
@ -183,7 +183,7 @@ public class HMasterCommandLine extends ServerCommandLine {
HMaster master = HMaster.constructMaster(masterClass, conf);
if (master.isStopped()) {
LOG.info("Won't bring the Master up as a shutdown is requested");
return -1;
return 1;
}
master.start();
master.join();
@ -191,8 +191,8 @@ public class HMasterCommandLine extends ServerCommandLine {
throw new RuntimeException("HMaster Aborted");
}
} catch (Throwable t) {
LOG.error("Failed to start master", t);
return -1;
LOG.error("Master exiting", t);
return 1;
}
return 0;
}
@ -206,19 +206,19 @@ public class HMasterCommandLine extends ServerCommandLine {
adm = new HBaseAdmin(getConf());
} catch (MasterNotRunningException e) {
LOG.error("Master not running");
return -1;
return 1;
} catch (ZooKeeperConnectionException e) {
LOG.error("ZooKeeper not available");
return -1;
return 1;
} catch (IOException e) {
LOG.error("Got IOException: " +e.getMessage(), e);
return -1;
return 1;
}
try {
adm.shutdown();
} catch (Throwable t) {
LOG.error("Failed to stop master", t);
return -1;
return 1;
}
return 0;
}

View File

@ -50,16 +50,26 @@ public class HRegionServerCommandLine extends ServerCommandLine {
private int start() throws Exception {
Configuration conf = getConf();
try {
// If 'local', don't start a region server here. Defer to
// LocalHBaseCluster. It manages 'local' clusters.
if (LocalHBaseCluster.isLocal(conf)) {
LOG.warn("Not starting a distinct region server because "
+ HConstants.CLUSTER_DISTRIBUTED + " is false");
} else {
logJVMInfo();
HRegionServer hrs = HRegionServer.constructRegionServer(regionServerClass, conf);
HRegionServer.startRegionServer(hrs);
Thread rsThread = HRegionServer.startRegionServer(hrs);
// If 'local', don't start a region server here. Defer to
// LocalHBaseCluster. It manages 'local' clusters.
if (LocalHBaseCluster.isLocal(conf)) {
LOG.warn("Not starting a distinct region server because "
+ HConstants.CLUSTER_DISTRIBUTED + " is false");
} else {
logJVMInfo();
HRegionServer hrs = HRegionServer.constructRegionServer(regionServerClass, conf);
HRegionServer.startRegionServer(hrs);
rsThread.join();
if (hrs.isAborted()) {
throw new RuntimeException("HRegionServer Aborted");
}
}
} catch (Throwable t) {
LOG.error("Region server exiting", t);
return 1;
}
return 0;
}
@ -67,7 +77,7 @@ public class HRegionServerCommandLine extends ServerCommandLine {
public int run(String args[]) throws Exception {
if (args.length != 1) {
usage(null);
return -1;
return 1;
}
String cmd = args[0];
@ -79,10 +89,10 @@ public class HRegionServerCommandLine extends ServerCommandLine {
"To shutdown the regionserver run " +
"bin/hbase-daemon.sh stop regionserver or send a kill signal to" +
"the regionserver pid");
return -1;
return 1;
} else {
usage("Unknown command: " + args[0]);
return -1;
return 1;
}
}
}