@ FFDCIgnore ( JobStoppingException . class ) private void executeAndWaitForCompletion ( PartitionPlanDescriptor currentPlan ) throws JobRestartException { if ( isStoppingStoppedOrFailed ( ) ) { logger . fine ( "Job already in " + runtimeWorkUnitExecution . getWorkUnitJobContext ( ) . getBatchStatus ( ) . toString ( ) + " state, exiting from executeAndWaitForCompletion() before beginning execution" ) ; return ; } List < Integer > partitionsToExecute = getPartitionNumbersToExecute ( currentPlan ) ; logger . fine ( "Partitions to execute in this run: " + partitionsToExecute + ". Total number of partitions in step: " + currentPlan . getNumPartitionsInPlan ( ) ) ; List < Integer > startedPartitions = new ArrayList < Integer > ( ) ; List < Integer > finishedPartitions = new ArrayList < Integer > ( ) ; List < Throwable > analyzerExceptions = new ArrayList < Throwable > ( ) ; // Keep looping until all partitions have finished. while ( finishedPartitions . size ( ) < partitionsToExecute . size ( ) ) { startPartitions ( partitionsToExecute , startedPartitions , finishedPartitions , currentPlan ) ; // Check that there are still un-finished partitions running. // If not, break out of the loop. if ( finishedPartitions . size ( ) >= partitionsToExecute . size ( ) ) { break ; } //Break this loop when nextPartitionFinished is -1 try { waitForNextPartitionToFinish ( analyzerExceptions , finishedPartitions ) ; } catch ( JobStoppingException e ) { // break the loop break ; } } if ( ! analyzerExceptions . isEmpty ( ) ) { rollbackPartitionedStep ( ) ; throw new BatchContainerRuntimeException ( "Exception previously thrown by Analyzer, rolling back step." , analyzerExceptions . get ( 0 ) ) ; } }
Spawn the partitions and wait for them to complete .