private void listTrackers ( ) throws IOException { ClusterStatus fullStatus = jobSubmitClient . getClusterStatus ( true ) ; Collection < TaskTrackerStatus > trackers = fullStatus . getTaskTrackersDetails ( ) ; Set < String > activeTrackers = new HashSet < String > ( fullStatus . getActiveTrackerNames ( ) ) ; List < Float > mapsProgress = new ArrayList < Float > ( ) ; List < Float > reducesProgress = new ArrayList < Float > ( ) ; int finishedMapsFromRunningJobs = 0 ; int finishedReducesFromRunningJobs = 0 ; System . out . println ( "Total Map Tasks in Running Jobs: " + fullStatus . getTotalMapTasks ( ) ) ; System . out . println ( "Total Reduce Tasks in Running Jobs: " + fullStatus . getTotalReduceTasks ( ) ) ; for ( TaskTrackerStatus tracker : trackers ) { System . out . println ( tracker . getTrackerName ( ) ) ; //List<TaskStatus> tasks = tracker.getTaskReports(); Collection < TaskStatus > tasks = fullStatus . getTaskTrackerTasksStatuses ( tracker . getTrackerName ( ) ) ; for ( TaskStatus task : tasks ) { TaskStatus . State state = task . getRunState ( ) ; if ( task . getIsMap ( ) && ( state == TaskStatus . State . RUNNING || state == TaskStatus . State . UNASSIGNED ) ) { mapsProgress . add ( task . getProgress ( ) ) ; } else if ( ! task . getIsMap ( ) && ( state == TaskStatus . State . RUNNING || state == TaskStatus . State . UNASSIGNED ) ) { reducesProgress . add ( task . getProgress ( ) ) ; } else if ( task . getIsMap ( ) && state == TaskStatus . State . SUCCEEDED ) { finishedMapsFromRunningJobs ++ ; } else if ( ! task . getIsMap ( ) && state == TaskStatus . State . SUCCEEDED ) { finishedReducesFromRunningJobs ++ ; } } if ( activeTrackers . contains ( tracker . getTrackerName ( ) ) ) { System . out . println ( "\tActive" ) ; } else { System . out . println ( "\tBlacklisted" ) ; } System . out . println ( "\tLast Seen: " + tracker . getLastSeen ( ) ) ; System . out . println ( "\tMap Tasks Running: " + tracker . countMapTasks ( ) + "/" + tracker . getMaxMapSlots ( ) ) ; System . out . println ( "\tMap Tasks Progress: " + mapsProgress . toString ( ) ) ; System . out . println ( "\tFinished Map Tasks From Running Jobs: " + finishedMapsFromRunningJobs ) ; System . out . println ( "\tReduce Tasks Running: " + tracker . countReduceTasks ( ) + "/" + tracker . getMaxReduceSlots ( ) ) ; System . out . println ( "\tReduce Tasks Progress: " + reducesProgress . toString ( ) ) ; System . out . println ( "\tTask Tracker Failures: " + tracker . getFailures ( ) ) ; mapsProgress . clear ( ) ; reducesProgress . clear ( ) ; } }
Display the stats of the cluster with per tracker details