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();
				}
			}
		}
	}
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 ) { final boolean shutDownAtEnd ; if ( this . nephele == null ) { shutDownAtEnd = true ; start ( ) ; } else { 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.

@param plan The plan of the program to execute.
@return The net runtime of the program, in milliseconds.

@throws Exception Thrown, if either the startup of the local execution context, or the execution
caused an exception.