@ Override public void stopScheduling ( ) { LOG . debug ( "Stopping compute engine" ) ; // Requesting all workers to stop for ( ChainingCallback chainingCallback : chainingCallbacks ) { chainingCallback . stop ( false ) ; } // Workers have 40s to gracefully stop processing tasks long until = System . currentTimeMillis ( ) + gracefulStopTimeoutInMs ; LOG . info ( "Waiting for workers to finish in-progress tasks" ) ; while ( System . currentTimeMillis ( ) < until && ceWorkerController . hasAtLeastOneProcessingWorker ( ) ) { try { Thread . sleep ( 200L ) ; } catch ( InterruptedException e ) { LOG . debug ( "Graceful stop period has been interrupted: {}" , e ) ; Thread . currentThread ( ) . interrupt ( ) ; break ; } } if ( ceWorkerController . hasAtLeastOneProcessingWorker ( ) ) { LOG . info ( "Some in-progress tasks did not finish in due time. Tasks will be stopped." ) ; } // Interrupting the tasks for ( ChainingCallback chainingCallback : chainingCallbacks ) { chainingCallback . stop ( true ) ; } }
This method is stopping all the workers giving them a delay before killing them .