public void stop ( ) { synchronized ( startStopLock ) { running = false ; taskStatusChecker . shutdownNow ( ) ; if ( numRunningTasks > 0 ) { final Iterator < MonitorEntry > iterator = runningTasks . values ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { final MonitorEntry entry = iterator . next ( ) ; iterator . remove ( ) ; final String taskId = entry . runningTask . getId ( ) ; log . info ( "Request to kill subtask[%s]" , taskId ) ; indexingServiceClient . killTask ( taskId ) ; numRunningTasks -- ; numKilledTasks ++ ; } if ( numRunningTasks > 0 ) { log . warn ( "Inconsistent state: numRunningTasks[%d] is still not zero after trying to kill all running tasks." , numRunningTasks ) ; } } log . info ( "Stopped taskMonitor" ) ; } }
Stop task monitoring and kill all running tasks .