use of co.cask.cdap.api.ProgramState in project cdap by caskdata.
the class MapReduceRuntimeService method doInitialize.
private void doInitialize(Job job) throws Exception {
context.setState(new ProgramState(ProgramStatus.INITIALIZING, null));
ClassLoader oldClassLoader = ClassLoaders.setContextClassLoader(job.getConfiguration().getClassLoader());
try {
if (mapReduce instanceof ProgramLifecycle) {
//noinspection unchecked
((ProgramLifecycle) mapReduce).initialize(context);
} else {
mapReduce.beforeSubmit(context);
}
} finally {
ClassLoaders.setContextClassLoader(oldClassLoader);
}
// once the initialize method is executed, set the status of the MapReduce to RUNNING
context.setState(new ProgramState(ProgramStatus.RUNNING, null));
}
use of co.cask.cdap.api.ProgramState in project cdap by caskdata.
the class SparkRuntimeService method shutDown.
@Override
protected void shutDown() throws Exception {
// Try to get from the submission future to see if the job completed successfully.
ListenableFuture<RunId> jobCompletion = completion.get();
ProgramState state = new ProgramState(ProgramStatus.COMPLETED, null);
try {
jobCompletion.get();
} catch (Exception e) {
if (jobCompletion.isCancelled()) {
state = new ProgramState(ProgramStatus.KILLED, null);
} else {
state = new ProgramState(ProgramStatus.FAILED, Throwables.getRootCause(e).getMessage());
}
}
try {
destroy(state);
} finally {
cleanupTask.run();
LOG.debug("Spark program completed: {}", runtimeContext);
}
}
Aggregations