public synchronized void close ( ) throws IOException { // // Kill running tasks. Do this in a 2nd vector, called 'tasksToClose', // because calling jobHasFinished() may result in an edit to 'tasks'. // TreeMap < TaskAttemptID , TaskInProgress > tasksToClose = new TreeMap < TaskAttemptID , TaskInProgress > ( ) ; tasksToClose . putAll ( tasks ) ; for ( TaskInProgress tip : tasksToClose . values ( ) ) { tip . jobHasFinished ( false ) ; } this . running = false ; if ( pulseChecker != null ) { pulseChecker . shutdown ( ) ; } if ( versionBeanName != null ) { MBeanUtil . unregisterMBean ( versionBeanName ) ; } // Clear local storage if ( asyncDiskService != null ) { // Clear local storage asyncDiskService . cleanupAllVolumes ( ) ; // Shutdown all async deletion threads with up to 10 seconds of delay asyncDiskService . shutdown ( ) ; try { if ( ! asyncDiskService . awaitTermination ( 10000 ) ) { asyncDiskService . shutdownNow ( ) ; asyncDiskService = null ; } } catch ( InterruptedException e ) { asyncDiskService . shutdownNow ( ) ; asyncDiskService = null ; } } // Shutdown the fetcher thread if ( this . mapEventsFetcher != null ) { this . mapEventsFetcher . interrupt ( ) ; } // Stop the launchers this . mapLauncher . interrupt ( ) ; this . reduceLauncher . interrupt ( ) ; if ( this . heartbeatMonitor != null ) { this . heartbeatMonitor . interrupt ( ) ; } // Stop memory manager thread if ( this . taskMemoryManager != null ) { this . taskMemoryManager . shutdown ( ) ; } // Stop cgroup memory watcher this . cgroupMemoryWatcher . shutdown ( ) ; // All tasks are killed. So, they are removed from TaskLog monitoring also. // Interrupt the monitor. getTaskLogsMonitor ( ) . interrupt ( ) ; jvmManager . stop ( ) ; // shutdown RPC connections RPC . stopProxy ( jobClient ) ; // wait for the fetcher thread to exit for ( boolean done = false ; ! done ; ) { try { if ( this . mapEventsFetcher != null ) { this . mapEventsFetcher . join ( ) ; } done = true ; } catch ( InterruptedException e ) { } } if ( taskReportServer != null ) { taskReportServer . stop ( ) ; taskReportServer = null ; } if ( healthChecker != null ) { //stop node health checker service healthChecker . stop ( ) ; healthChecker = null ; } if ( this . server != null ) { try { LOG . info ( "Shutting down StatusHttpServer" ) ; this . server . stop ( ) ; LOG . info ( "Shutting down Netty MapOutput Server" ) ; if ( this . nettyMapOutputServer != null ) { this . nettyMapOutputServer . stop ( ) ; } } catch ( Exception e ) { LOG . warn ( "Exception shutting down TaskTracker" , e ) ; } } }
Close down the TaskTracker and all its components . We must also shutdown any running tasks or threads and cleanup disk space . A new TaskTracker within the same process space might be restarted so everything must be clean .