|
@@ -107,6 +107,8 @@ import org.apache.hadoop.yarn.service.CompositeService;
|
|
|
import org.apache.hadoop.yarn.service.Service;
|
|
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
|
|
|
|
|
+import com.google.common.annotations.VisibleForTesting;
|
|
|
+
|
|
|
/**
|
|
|
* The Map-Reduce Application Master.
|
|
|
* The state machine is encapsulated in the implementation of Job interface.
|
|
@@ -398,52 +400,65 @@ public class MRAppMaster extends CompositeService {
|
|
|
protected void sysexit() {
|
|
|
System.exit(0);
|
|
|
}
|
|
|
-
|
|
|
- private class JobFinishEventHandler implements EventHandler<JobFinishEvent> {
|
|
|
- @Override
|
|
|
- public void handle(JobFinishEvent event) {
|
|
|
- // job has finished
|
|
|
- // this is the only job, so shut down the Appmaster
|
|
|
- // note in a workflow scenario, this may lead to creation of a new
|
|
|
- // job (FIXME?)
|
|
|
- // Send job-end notification
|
|
|
- if (getConfig().get(MRJobConfig.MR_JOB_END_NOTIFICATION_URL) != null) {
|
|
|
- try {
|
|
|
- LOG.info("Job end notification started for jobID : "
|
|
|
- + job.getReport().getJobId());
|
|
|
- JobEndNotifier notifier = new JobEndNotifier();
|
|
|
- notifier.setConf(getConfig());
|
|
|
- notifier.notify(job.getReport());
|
|
|
- } catch (InterruptedException ie) {
|
|
|
- LOG.warn("Job end notification interrupted for jobID : "
|
|
|
- + job.getReport().getJobId(), ie);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // TODO:currently just wait for some time so clients can know the
|
|
|
- // final states. Will be removed once RM come on.
|
|
|
+ @VisibleForTesting
|
|
|
+ public void shutDownJob() {
|
|
|
+ // job has finished
|
|
|
+ // this is the only job, so shut down the Appmaster
|
|
|
+ // note in a workflow scenario, this may lead to creation of a new
|
|
|
+ // job (FIXME?)
|
|
|
+ // Send job-end notification
|
|
|
+ if (getConfig().get(MRJobConfig.MR_JOB_END_NOTIFICATION_URL) != null) {
|
|
|
try {
|
|
|
- Thread.sleep(5000);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ LOG.info("Job end notification started for jobID : "
|
|
|
+ + job.getReport().getJobId());
|
|
|
+ JobEndNotifier notifier = new JobEndNotifier();
|
|
|
+ notifier.setConf(getConfig());
|
|
|
+ notifier.notify(job.getReport());
|
|
|
+ } catch (InterruptedException ie) {
|
|
|
+ LOG.warn("Job end notification interrupted for jobID : "
|
|
|
+ + job.getReport().getJobId(), ie);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- try {
|
|
|
- //We are finishing cleanly so this is the last retry
|
|
|
- isLastAMRetry = true;
|
|
|
- // Stop all services
|
|
|
- // This will also send the final report to the ResourceManager
|
|
|
- LOG.info("Calling stop for all the services");
|
|
|
- stop();
|
|
|
-
|
|
|
- } catch (Throwable t) {
|
|
|
- LOG.warn("Graceful stop failed ", t);
|
|
|
- }
|
|
|
+ // TODO:currently just wait for some time so clients can know the
|
|
|
+ // final states. Will be removed once RM come on.
|
|
|
+ try {
|
|
|
+ Thread.sleep(5000);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ //We are finishing cleanly so this is the last retry
|
|
|
+ isLastAMRetry = true;
|
|
|
+ // Stop all services
|
|
|
+ // This will also send the final report to the ResourceManager
|
|
|
+ LOG.info("Calling stop for all the services");
|
|
|
+ MRAppMaster.this.stop();
|
|
|
+
|
|
|
+ } catch (Throwable t) {
|
|
|
+ LOG.warn("Graceful stop failed ", t);
|
|
|
+ }
|
|
|
|
|
|
- //Bring the process down by force.
|
|
|
- //Not needed after HADOOP-7140
|
|
|
- LOG.info("Exiting MR AppMaster..GoodBye!");
|
|
|
- sysexit();
|
|
|
+ //Bring the process down by force.
|
|
|
+ //Not needed after HADOOP-7140
|
|
|
+ LOG.info("Exiting MR AppMaster..GoodBye!");
|
|
|
+ sysexit();
|
|
|
+ }
|
|
|
+
|
|
|
+ private class JobFinishEventHandler implements EventHandler<JobFinishEvent> {
|
|
|
+ @Override
|
|
|
+ public void handle(JobFinishEvent event) {
|
|
|
+ // Create a new thread to shutdown the AM. We should not do it in-line
|
|
|
+ // to avoid blocking the dispatcher itself.
|
|
|
+ new Thread() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ shutDownJob();
|
|
|
+ }
|
|
|
+ }.start();
|
|
|
}
|
|
|
}
|
|
|
|