@ Override @ FFDCIgnore ( JobExecutionNotRunningException . class ) public void stop ( ) { StopLock stopLock = getStopLock ( ) ; // Store in local variable to facilitate Ctrl+Shift+G search in Eclipse synchronized ( stopLock ) { if ( isStepStartingOrStarted ( ) ) { updateStepBatchStatus ( BatchStatus . STOPPING ) ; // It's possible we may try to stop a partitioned step before any // sub steps have been started. // Note: in multi-jvm mode parallelBatchWorkUnits will be empty (sub-jobs may not be // running locally, so no easy way to stop them). // TODO: could queue stopPartition thru JMS i suppose...). for ( BatchPartitionWorkUnit subJob : parallelBatchWorkUnits ) { try { getBatchKernelService ( ) . stopWorkUnit ( subJob ) ; } catch ( JobExecutionNotRunningException e ) { logger . fine ( "Caught exception trying to stop work unit: " + subJob + ", which was not running." ) ; // We want to stop all running sub steps. // We do not want to throw an exception if a sub step has already been completed. } catch ( Exception e ) { // Blow up if it happens to force the issue. throw new IllegalStateException ( e ) ; } } } else { // Might not be set up yet to have a state. logger . fine ( "Ignoring stop, since step not in a state which has a valid status (might not be far enough along to have a state yet)" ) ; } } }
The body of this method is synchronized with startPartition to close timing windows so that a new partition doesn t get started after this method has gone thru and stopped all currently running partitions .