Merge -c 1186554 from trunk to branch-0.23 to complete fix for MAPREDUCE-3188.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1186555 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Arun Murthy 2011-10-19 23:00:07 +00:00
parent 2115478185
commit ffccd70d7a
4 changed files with 20 additions and 9 deletions

View File

@ -1652,6 +1652,8 @@ Release 0.23.0 - Unreleased
MAPREDUCE-3179. Ensure failed tests exit with right error code. (Jonathan MAPREDUCE-3179. Ensure failed tests exit with right error code. (Jonathan
Eagles via acmurthy) Eagles via acmurthy)
MAPREDUCE-3188. Ensure correct shutdown in services. (todd via acmurthy)
Release 0.22.0 - Unreleased Release 0.22.0 - Unreleased
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -91,14 +91,16 @@ public void start() {
@Override @Override
public void stop() { public void stop() {
stopped = true; stopped = true;
eventHandlingThread.interrupt(); if (eventHandlingThread != null) {
try { eventHandlingThread.interrupt();
eventHandlingThread.join(); try {
} catch (InterruptedException ie) { eventHandlingThread.join();
LOG.debug("Interruped Exception while stopping", ie); } catch (InterruptedException ie) {
LOG.debug("Interrupted Exception while stopping", ie);
}
} }
//stop all the components // stop all the components
super.stop(); super.stop();
} }

View File

@ -63,8 +63,12 @@ public synchronized void start() {
@Override @Override
public synchronized void stop() { public synchronized void stop() {
if (state == STATE.STOPPED) { if (state == STATE.STOPPED ||
return;//already stopped state == STATE.INITED ||
state == STATE.NOTINITED) {
// already stopped, or else it was never
// started (eg another service failing canceled startup)
return;
} }
ensureCurrentState(STATE.STARTED); ensureCurrentState(STATE.STARTED);
changeState(STATE.STOPPED); changeState(STATE.STOPPED);

View File

@ -50,6 +50,7 @@ public AbstractLivelinessMonitor(String name, Clock clock) {
@Override @Override
public void start() { public void start() {
assert !stopped : "starting when already stopped";
checkerThread = new Thread(new PingChecker()); checkerThread = new Thread(new PingChecker());
checkerThread.setName("Ping Checker"); checkerThread.setName("Ping Checker");
checkerThread.start(); checkerThread.start();
@ -59,7 +60,9 @@ public void start() {
@Override @Override
public void stop() { public void stop() {
stopped = true; stopped = true;
checkerThread.interrupt(); if (checkerThread != null) {
checkerThread.interrupt();
}
super.stop(); super.stop();
} }