|
@@ -61,8 +61,14 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
|
|
|
|
static final Log LOG = LogFactory.getLog(HRegionServer.class);
|
|
static final Log LOG = LogFactory.getLog(HRegionServer.class);
|
|
|
|
|
|
|
|
+ // Set when a report to the master comes back with a message asking us to
|
|
|
|
+ // shutdown. Also set by call to stop when debugging or running unit tests
|
|
|
|
+ // of HRegionServer in isolation.
|
|
protected volatile boolean stopRequested;
|
|
protected volatile boolean stopRequested;
|
|
|
|
+
|
|
|
|
+ // Go down hard. Used debugging and in unit tests.
|
|
protected volatile boolean abortRequested;
|
|
protected volatile boolean abortRequested;
|
|
|
|
+
|
|
private final Path rootDir;
|
|
private final Path rootDir;
|
|
protected final HServerInfo serverInfo;
|
|
protected final HServerInfo serverInfo;
|
|
protected final Configuration conf;
|
|
protected final Configuration conf;
|
|
@@ -468,8 +474,9 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
/**
|
|
/**
|
|
* Sets a flag that will cause all the HRegionServer threads to shut down
|
|
* Sets a flag that will cause all the HRegionServer threads to shut down
|
|
* in an orderly fashion.
|
|
* in an orderly fashion.
|
|
|
|
+ * <p>FOR DEBUGGING ONLY
|
|
*/
|
|
*/
|
|
- public synchronized void stop() {
|
|
|
|
|
|
+ synchronized void stop() {
|
|
stopRequested = true;
|
|
stopRequested = true;
|
|
notifyAll(); // Wakes run() if it is sleeping
|
|
notifyAll(); // Wakes run() if it is sleeping
|
|
}
|
|
}
|
|
@@ -477,8 +484,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
/**
|
|
/**
|
|
* Cause the server to exit without closing the regions it is serving, the
|
|
* Cause the server to exit without closing the regions it is serving, the
|
|
* log it is using and without notifying the master.
|
|
* log it is using and without notifying the master.
|
|
- *
|
|
|
|
- * FOR DEBUGGING ONLY
|
|
|
|
|
|
+ * <p>FOR DEBUGGING ONLY
|
|
*/
|
|
*/
|
|
synchronized void abort() {
|
|
synchronized void abort() {
|
|
abortRequested = true;
|
|
abortRequested = true;
|
|
@@ -560,16 +566,13 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
if (LOG.isDebugEnabled()) {
|
|
if (LOG.isDebugEnabled()) {
|
|
LOG.debug("Telling master we are up");
|
|
LOG.debug("Telling master we are up");
|
|
}
|
|
}
|
|
-
|
|
|
|
hbaseMaster.regionServerStartup(serverInfo);
|
|
hbaseMaster.regionServerStartup(serverInfo);
|
|
-
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
if (LOG.isDebugEnabled()) {
|
|
LOG.debug("Done telling master we are up");
|
|
LOG.debug("Done telling master we are up");
|
|
}
|
|
}
|
|
} catch(IOException e) {
|
|
} catch(IOException e) {
|
|
waitTime = stopRequested ? 0
|
|
waitTime = stopRequested ? 0
|
|
: msgInterval - (System.currentTimeMillis() - lastMsg);
|
|
: msgInterval - (System.currentTimeMillis() - lastMsg);
|
|
-
|
|
|
|
if(waitTime > 0) {
|
|
if(waitTime > 0) {
|
|
synchronized (this) {
|
|
synchronized (this) {
|
|
try {
|
|
try {
|
|
@@ -585,7 +588,6 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
// Now ask master what it wants us to do and tell it what we have done.
|
|
// Now ask master what it wants us to do and tell it what we have done.
|
|
while (!stopRequested) {
|
|
while (!stopRequested) {
|
|
if ((System.currentTimeMillis() - lastMsg) >= msgInterval) {
|
|
if ((System.currentTimeMillis() - lastMsg) >= msgInterval) {
|
|
-
|
|
|
|
HMsg outboundArray[] = null;
|
|
HMsg outboundArray[] = null;
|
|
synchronized(outboundMsgs) {
|
|
synchronized(outboundMsgs) {
|
|
outboundArray = outboundMsgs.toArray(new HMsg[outboundMsgs.size()]);
|
|
outboundArray = outboundMsgs.toArray(new HMsg[outboundMsgs.size()]);
|
|
@@ -595,14 +597,12 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
try {
|
|
try {
|
|
HMsg msgs[] = hbaseMaster.regionServerReport(serverInfo, outboundArray);
|
|
HMsg msgs[] = hbaseMaster.regionServerReport(serverInfo, outboundArray);
|
|
lastMsg = System.currentTimeMillis();
|
|
lastMsg = System.currentTimeMillis();
|
|
-
|
|
|
|
// Queue up the HMaster's instruction stream for processing
|
|
// Queue up the HMaster's instruction stream for processing
|
|
-
|
|
|
|
synchronized(toDo) {
|
|
synchronized(toDo) {
|
|
boolean restart = false;
|
|
boolean restart = false;
|
|
for(int i = 0; i < msgs.length && !stopRequested && !restart; i++) {
|
|
for(int i = 0; i < msgs.length && !stopRequested && !restart; i++) {
|
|
switch(msgs[i].getMsg()) {
|
|
switch(msgs[i].getMsg()) {
|
|
-
|
|
|
|
|
|
+
|
|
case HMsg.MSG_CALL_SERVER_STARTUP:
|
|
case HMsg.MSG_CALL_SERVER_STARTUP:
|
|
if (LOG.isDebugEnabled()) {
|
|
if (LOG.isDebugEnabled()) {
|
|
LOG.debug("Got call server startup message");
|
|
LOG.debug("Got call server startup message");
|
|
@@ -657,9 +657,9 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ leases.closeAfterLeasesExpire();
|
|
this.worker.stop();
|
|
this.worker.stop();
|
|
this.server.stop();
|
|
this.server.stop();
|
|
- leases.close();
|
|
|
|
|
|
|
|
// Send interrupts to wake up threads if sleeping so they notice shutdown.
|
|
// Send interrupts to wake up threads if sleeping so they notice shutdown.
|
|
|
|
|
|
@@ -675,50 +675,43 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
this.splitOrCompactCheckerThread.interrupt();
|
|
this.splitOrCompactCheckerThread.interrupt();
|
|
}
|
|
}
|
|
|
|
|
|
- if(abortRequested) {
|
|
|
|
|
|
+ if (abortRequested) {
|
|
try {
|
|
try {
|
|
log.rollWriter();
|
|
log.rollWriter();
|
|
-
|
|
|
|
} catch(IOException e) {
|
|
} catch(IOException e) {
|
|
LOG.warn(e);
|
|
LOG.warn(e);
|
|
}
|
|
}
|
|
- LOG.info("aborting server at: " + serverInfo.getServerAddress().toString());
|
|
|
|
-
|
|
|
|
|
|
+ LOG.info("aborting server at: " +
|
|
|
|
+ serverInfo.getServerAddress().toString());
|
|
} else {
|
|
} else {
|
|
Vector<HRegion> closedRegions = closeAllRegions();
|
|
Vector<HRegion> closedRegions = closeAllRegions();
|
|
try {
|
|
try {
|
|
log.closeAndDelete();
|
|
log.closeAndDelete();
|
|
-
|
|
|
|
} catch(IOException e) {
|
|
} catch(IOException e) {
|
|
LOG.error(e);
|
|
LOG.error(e);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
HMsg[] exitMsg = new HMsg[closedRegions.size() + 1];
|
|
HMsg[] exitMsg = new HMsg[closedRegions.size() + 1];
|
|
exitMsg[0] = new HMsg(HMsg.MSG_REPORT_EXITING);
|
|
exitMsg[0] = new HMsg(HMsg.MSG_REPORT_EXITING);
|
|
-
|
|
|
|
// Tell the master what regions we are/were serving
|
|
// Tell the master what regions we are/were serving
|
|
-
|
|
|
|
int i = 1;
|
|
int i = 1;
|
|
for(HRegion region: closedRegions) {
|
|
for(HRegion region: closedRegions) {
|
|
- exitMsg[i++] = new HMsg(HMsg.MSG_REPORT_CLOSE, region.getRegionInfo());
|
|
|
|
|
|
+ exitMsg[i++] = new HMsg(HMsg.MSG_REPORT_CLOSE,
|
|
|
|
+ region.getRegionInfo());
|
|
}
|
|
}
|
|
|
|
|
|
LOG.info("telling master that region server is shutting down at: "
|
|
LOG.info("telling master that region server is shutting down at: "
|
|
+ serverInfo.getServerAddress().toString());
|
|
+ serverInfo.getServerAddress().toString());
|
|
-
|
|
|
|
hbaseMaster.regionServerReport(serverInfo, exitMsg);
|
|
hbaseMaster.regionServerReport(serverInfo, exitMsg);
|
|
-
|
|
|
|
} catch(IOException e) {
|
|
} catch(IOException e) {
|
|
LOG.warn(e);
|
|
LOG.warn(e);
|
|
}
|
|
}
|
|
- LOG.info("stopping server at: " + serverInfo.getServerAddress().toString());
|
|
|
|
|
|
+ LOG.info("stopping server at: " +
|
|
|
|
+ serverInfo.getServerAddress().toString());
|
|
}
|
|
}
|
|
|
|
|
|
- join();
|
|
|
|
-
|
|
|
|
- if(LOG.isDebugEnabled()) {
|
|
|
|
- LOG.debug("main thread exiting");
|
|
|
|
- }
|
|
|
|
|
|
+ join();
|
|
|
|
+ LOG.info("main thread exiting");
|
|
}
|
|
}
|
|
|
|
|
|
/** Add to the outbound message buffer */
|
|
/** Add to the outbound message buffer */
|
|
@@ -1024,7 +1017,6 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
|
public void leaseExpired() {
|
|
public void leaseExpired() {
|
|
try {
|
|
try {
|
|
localRegion.abort(localLockId);
|
|
localRegion.abort(localLockId);
|
|
-
|
|
|
|
} catch(IOException iex) {
|
|
} catch(IOException iex) {
|
|
LOG.error(iex);
|
|
LOG.error(iex);
|
|
}
|
|
}
|