MAPREDUCE-3188. Ensure correct shutdown in services. Contributed by Todd Lipcon.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1186554 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fc362b1caf
commit
aeae1ba497
@ -1706,6 +1706,8 @@ Release 0.23.0 - Unreleased
|
||||
MAPREDUCE-3179. Ensure failed tests exit with right error code. (Jonathan
|
||||
Eagles via acmurthy)
|
||||
|
||||
MAPREDUCE-3188. Ensure correct shutdown in services. (todd via acmurthy)
|
||||
|
||||
Release 0.22.0 - Unreleased
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
@ -91,14 +91,16 @@ public void start() {
|
||||
@Override
|
||||
public void stop() {
|
||||
stopped = true;
|
||||
eventHandlingThread.interrupt();
|
||||
try {
|
||||
eventHandlingThread.join();
|
||||
} catch (InterruptedException ie) {
|
||||
LOG.debug("Interruped Exception while stopping", ie);
|
||||
if (eventHandlingThread != null) {
|
||||
eventHandlingThread.interrupt();
|
||||
try {
|
||||
eventHandlingThread.join();
|
||||
} catch (InterruptedException ie) {
|
||||
LOG.debug("Interrupted Exception while stopping", ie);
|
||||
}
|
||||
}
|
||||
|
||||
//stop all the components
|
||||
// stop all the components
|
||||
super.stop();
|
||||
}
|
||||
|
||||
|
@ -63,8 +63,12 @@ public synchronized void start() {
|
||||
|
||||
@Override
|
||||
public synchronized void stop() {
|
||||
if (state == STATE.STOPPED) {
|
||||
return;//already stopped
|
||||
if (state == STATE.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);
|
||||
changeState(STATE.STOPPED);
|
||||
|
@ -50,6 +50,7 @@ public AbstractLivelinessMonitor(String name, Clock clock) {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
assert !stopped : "starting when already stopped";
|
||||
checkerThread = new Thread(new PingChecker());
|
||||
checkerThread.setName("Ping Checker");
|
||||
checkerThread.start();
|
||||
@ -59,7 +60,9 @@ public void start() {
|
||||
@Override
|
||||
public void stop() {
|
||||
stopped = true;
|
||||
checkerThread.interrupt();
|
||||
if (checkerThread != null) {
|
||||
checkerThread.interrupt();
|
||||
}
|
||||
super.stop();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user