*
* @throws Exception if execution failed.
*/
private MapReduceContext runAndWait(Program program, ProgramOptions options) throws Exception {
ProgramController controller = programRunner.run(program, options);
final MapReduceContext context = (controller instanceof MapReduceProgramController)
? ((MapReduceProgramController) controller).getContext()
: null;
// Execute the program.
final SettableFuture<MapReduceContext> completion = SettableFuture.create();
controller.addListener(new AbstractListener() {