public JobExecutionResult executePlan ( Plan plan ) throws Exception { if ( plan == null ) { throw new IllegalArgumentException ( "The plan may not be null." ) ; } ContextChecker checker = new ContextChecker ( ) ; checker . check ( plan ) ; synchronized ( this . lock ) { // check if we start a session dedicated for this execution final boolean shutDownAtEnd ; if ( this . nephele == null ) { // we start a session just for us now shutDownAtEnd = true ; start ( ) ; } else { // we use the existing session shutDownAtEnd = false ; } try { PactCompiler pc = new PactCompiler ( new DataStatistics ( ) ) ; OptimizedPlan op = pc . compile ( plan ) ; NepheleJobGraphGenerator jgg = new NepheleJobGraphGenerator ( ) ; JobGraph jobGraph = jgg . compileJobGraph ( op ) ; JobClient jobClient = this . nephele . getJobClient ( jobGraph ) ; JobExecutionResult result = jobClient . submitJobAndWait ( ) ; return result ; } finally { if ( shutDownAtEnd ) { stop ( ) ; } } } }
Execute the given plan on the local Nephele instance wait for the job to finish and return the runtime in milliseconds .