List of usage examples for org.apache.hadoop.mapred RunningJob getJobName
public String getJobName();
From source file:org.sleuthkit.web.sampleapp.server.SampleServiceImpl.java
License:Open Source License
/** * get job data (one row per job) from hadoop * @return array of jobs (one row per job). Each row is an array of strings (one per column), matching columns[]. * @throws Exception/*from w w w . j a va 2s .c om*/ */ public String[][] getData() throws IllegalArgumentException { List<String[]> result = new ArrayList<String[]>(); //first we add "ghost jobs" based on image ids we have - update these if we have real jobs addGhostJobs(result); Configuration conf = new Configuration(); JobClient jobClient; try { jobClient = new JobClient(new InetSocketAddress("localhost", 8021), conf); jobClient.setConf(conf); // Bug in constructor, doesn't set conf. for (JobStatus js : jobClient.getAllJobs()) { RunningJob rj = jobClient.getJob(js.getJobID()); if (rj == null) continue; String jobName = rj.getJobName(); if (jobName == null) continue; //extract TP$imageHash$imageId$step from jobName - we filter on image hash if (jobName.startsWith("TP") && !jobName.contains("_TEST")) { String[] names = jobName.split("\\$"); if (names.length != 4) { System.err.println("Invalid job name of TP job " + jobName); } processJob(result, names, js, rj); } } //sort descending by time Collections.sort(result, new Comparator<String[]>() { public int compare(String[] a1, String[] a2) { return a2[TIME_START].compareTo(a1[TIME_START]); } }); return result.toArray(new String[0][0]); } catch (IOException e) { e.printStackTrace(); return null; } }