* @throws IOException
*/
HMsg [] regionServerReport(final HServerInfo serverInfo,
final HMsg msgs[], final HRegionInfo[] mostLoadedRegions)
throws IOException {
HServerInfo info = new HServerInfo(serverInfo);
checkIsDead(info.getServerName(), "REPORT");
if (msgs.length > 0) {
if (msgs[0].isType(HMsg.Type.MSG_REPORT_EXITING)) {
processRegionServerExit(info, msgs);
return HMsg.EMPTY_HMSG_ARRAY;
} else if (msgs[0].isType(HMsg.Type.MSG_REPORT_QUIESCED)) {
LOG.info("Region server " + info.getServerName() + " quiesced");
this.quiescedServers.incrementAndGet();
}
}
if (this.master.getShutdownRequested().get()) {
if (quiescedServers.get() >= serversToServerInfo.size()) {
// If the only servers we know about are meta servers, then we can
// proceed with shutdown
LOG.info("All user tables quiesced. Proceeding with shutdown");
this.master.startShutdown();
}
if (!this.master.isClosed()) {
if (msgs.length > 0 &&
msgs[0].isType(HMsg.Type.MSG_REPORT_QUIESCED)) {
// Server is already quiesced, but we aren't ready to shut down
// return empty response
return HMsg.EMPTY_HMSG_ARRAY;
}
// Tell the server to stop serving any user regions
return new HMsg [] {HMsg.REGIONSERVER_QUIESCE};
}
}
if (this.master.isClosed()) {
// Tell server to shut down if we are shutting down. This should
// happen after check of MSG_REPORT_EXITING above, since region server
// will send us one of these messages after it gets MSG_REGIONSERVER_STOP
return new HMsg [] {HMsg.REGIONSERVER_STOP};
}
HServerInfo storedInfo = this.serversToServerInfo.get(info.getServerName());
if (storedInfo == null) {
LOG.warn("Received report from unknown server -- telling it " +
"to " + HMsg.REGIONSERVER_STOP + ": " + info.getServerName());
// The HBaseMaster may have been restarted.
// Tell the RegionServer to abort!
return new HMsg[] {HMsg.REGIONSERVER_STOP};
} else if (storedInfo.getStartCode() != info.getStartCode()) {
// This state is reachable if:
//
// 1) RegionServer A started
// 2) RegionServer B started on the same machine, then
// clobbered A in regionServerStartup.