读取job的历史记录

1、java类

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.JobID;
import org.apache.hadoop.mapred.JobStatus;
import org.apache.hadoop.mapred.TaskReport;
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
import org.apache.hadoop.mapreduce.v2.app.job.Job;
import org.apache.hadoop.mapreduce.v2.hs.JobHistory;


public class jobRecord{
  
public static void main(String[] args) throws Exception{
JobClient jobClient = null;
JobStatus[] jobs;
jobClient = new JobClient(new JobConf());
Configuration conf = new Configuration();  
JobHistory his = new JobHistory();  
his.init(conf);  
Map jobHis = his.getAllJobs();
jobs = jobClient.getAllJobs();
   for (Entry entry : jobHis.entrySet()) { }

}

}

2、pom.xml


	4.0.0

	Yarn
	Yarn
	0.0.1-SNAPSHOT
	jar

	Yarn
	http://maven.apache.org

	
		UTF-8
	

	
		
			junit
			junit
			3.8.1
			test
		
		
		
			org.apache.hadoop
			hadoop-mapreduce-client-core
			2.3.0
		

		
		
			org.apache.hadoop
			hadoop-mapreduce-client-jobclient
			2.3.0
		
		
		
			org.apache.hadoop
			hadoop-mapreduce-client-common
			2.3.0
		
		
		
			org.apache.hadoop
			hadoop-mapreduce-client-app
			2.3.0
		
		
		
			org.apache.hadoop
			hadoop-mapreduce-client-hs
			2.3.0
		

		
			org.apache.hadoop
			hadoop-hdfs
			2.3.0
		
		
			org.apache.hadoop
			hadoop-common
			2.3.0
		
		
			jdk.tools
			jdk.tools
			1.6
			system
			C:/Program Files/Java/jdk1.8.0_73/lib/tools.jar
				
	
	
	
		
			
				maven-assembly-plugin
				
					false
					
						jar-with-dependencies
					
					
						
							Yarn.Yarn.YarnAppManager
						
					
				
				
					
						make-assembly
						package
						
							single
						
					
				
			
		
	



你可能感兴趣的:(mapreduce,hadoop)