public static void printAllJobs ( List < JobExecutionInfo > jobExecutionInfos , int resultsLimit ) { if ( jobExecutionInfos == null ) { System . err . println ( "No jobs found." ) ; System . exit ( 1 ) ; } List < String > labels = Arrays . asList ( "Job Name" , "State" , "Last Run Started" , "Last Run Completed" , "Schedule" , "Last Run Records Processed" , "Last Run Records Failed" ) ; List < String > flags = Arrays . asList ( "-" , "-" , "-" , "-" , "-" , "" , "" ) ; List < List < String > > data = new ArrayList <> ( ) ; for ( JobExecutionInfo jobInfo : jobExecutionInfos ) { List < String > entry = new ArrayList <> ( ) ; entry . add ( jobInfo . getJobName ( ) ) ; entry . add ( jobInfo . getState ( ) . toString ( ) ) ; entry . add ( dateTimeFormatter . print ( jobInfo . getStartTime ( ) ) ) ; entry . add ( dateTimeFormatter . print ( jobInfo . getEndTime ( ) ) ) ; entry . add ( extractJobSchedule ( jobInfo ) ) ; // Add metrics MetricArray metrics = jobInfo . getMetrics ( ) ; Double recordsProcessed = null ; Double recordsFailed = null ; try { for ( Metric metric : metrics ) { if ( metric . getName ( ) . equals ( MetricNames . ExtractorMetrics . RECORDS_READ_METER ) ) { recordsProcessed = Double . parseDouble ( metric . getValue ( ) ) ; } else if ( metric . getName ( ) . equals ( MetricNames . ExtractorMetrics . RECORDS_FAILED_METER ) ) { recordsFailed = Double . parseDouble ( metric . getValue ( ) ) ; } } if ( recordsProcessed != null && recordsFailed != null ) { entry . add ( recordsProcessed . toString ( ) ) ; entry . add ( recordsFailed . toString ( ) ) ; } } catch ( NumberFormatException ex ) { System . err . println ( "Failed to process metrics" ) ; } if ( recordsProcessed == null || recordsFailed == null ) { entry . add ( "-" ) ; entry . add ( "-" ) ; } data . add ( entry ) ; } new CliTablePrinter . Builder ( ) . labels ( labels ) . data ( data ) . flags ( flags ) . delimiterWidth ( 2 ) . build ( ) . printTable ( ) ; if ( jobExecutionInfos . size ( ) == resultsLimit ) { System . out . println ( "\nWARNING: There may be more jobs (# of results is equal to the limit)" ) ; } }
Print summary information about a bunch of jobs in the system