List of usage examples for org.apache.hadoop.mapreduce Job getJobFile
public String getJobFile()
From source file:fr.ens.biologie.genomique.eoulsan.util.hadoop.MapReduceUtils.java
License:LGPL
/** * Wait the completion of a job./*www. j ava 2 s . co m*/ * @param job the job to submit * @param jobDescription the description of the job * @param waitTimeInMillis waiting time between 2 checks of the completion of * jobs * @param status step status * @param counterGroup group of the counter to log * @throws EoulsanException if the job fail or if an exception occurs while * submitting or waiting the end of the job */ public static void submitAndWaitForJob(final Job job, final String jobDescription, final int waitTimeInMillis, final TaskStatus status, final String counterGroup) throws EoulsanException { if (job == null) { throw new NullPointerException("The job is null"); } if (jobDescription == null) { throw new NullPointerException("The jobDescription is null"); } try { // Set the description of the context status.setDescription(job.getJobName()); // Submit the job job.submit(); // Add the Hadoop job to the list of job to kill if workflow fails HadoopJobEmergencyStopTask.addHadoopJobEmergencyStopTask(job); // Job the completion of the job (non verbose mode) job.waitForCompletion(false); // Remove the Hadoop job to the list of job to kill if workflow fails HadoopJobEmergencyStopTask.removeHadoopJobEmergencyStopTask(job); // Check if the job has been successfully executed if (!job.isSuccessful()) { status.setProgressMessage("FAILED"); throw new EoulsanException("Fail of the Hadoop job: " + job.getJobFile()); } // Set the counters status.setCounters(new HadoopReporter(job.getCounters()), counterGroup); } catch (ClassNotFoundException | InterruptedException | IOException e) { throw new EoulsanException(e); } }
From source file:org.huahinframework.manager.rest.service.JobService.java
License:Apache License
/** * @param jobId// w w w . jav a2 s . com * @return {@link JSONObject} * @throws JSONException */ @Path("/detail/{" + JOBID + "}") @GET @Produces(MediaType.APPLICATION_JSON) public JSONObject detail(@PathParam(JOBID) String jobId) throws JSONException { JSONObject jsonObject = null; JobConf conf = getJobConf(); try { final Map<String, Object> job = getStatus(jobId); if (job != null) { Cluster cluster = new Cluster(conf); Job j = cluster.getJob(JobID.forName(jobId)); if (j != null) { String jobFile = j.getJobFile(); job.put(Response.JOB_FILE, jobFile); job.put(Response.TRACKING_URL, j.getTrackingURL()); Map<String, String> jobConf = JobUtils.getJobConfiguration(jobFile, conf); if (jobConf != null) { job.put(Response.CONFIGURATION, jobConf); } } jsonObject = new JSONObject(job); } } catch (Exception e) { e.printStackTrace(); log.error(e); Map<String, String> status = new HashMap<String, String>(); status.put(Response.STATUS, e.getMessage()); jsonObject = new JSONObject(status); } if (jsonObject == null) { Map<String, String> status = new HashMap<String, String>(); status.put(Response.STATUS, "Could not find job " + jobId); jsonObject = new JSONObject(status); } return jsonObject; }