@Override public void jobRemoved(JobInProgress job) { LOG.info("Removed job " + job.getJobID()); }
public void jobRemoved(JobInProgress job) { LOG.info("Job " + job.getJobID().toString() + " removed"); wjobs.remove(job); rjobs.remove(job); }
public boolean contains (JobID id, boolean waiting) { if (!wjobsAdded.contains(id)) { throw new RuntimeException("Job " + id + " not seen in waiting queue"); } if (!waiting) { if (!rjobsAdded.contains(id)) { throw new RuntimeException("Job " + id + " not seen in run queue"); } } List<JobInProgress> queue = waiting ? wjobs : rjobs; for (JobInProgress job : queue) { if (job.getJobID().equals(id)) { return true; } } return false; }
public JobRecoveryListener(JobInProgress jip) { this.jip = jip; this.job = new JobHistory.JobInfo(jip.getJobID().toString()); }
/** * Wait till noOfTasksToFinish number of tasks of type specified by isMap * are finished. This currently uses a jip object and directly uses its api to * determine the number of tasks finished. * * <p> * * TODO: It should eventually use a JobID and then get the information from * the JT to check the number of finished tasks. * * @param jip * @param isMap * @param noOfTasksToFinish * @throws InterruptedException */ static void waitTillNTotalTasksFinish(JobInProgress jip, boolean isMap, int noOfTasksToFinish) throws InterruptedException { int noOfTasksAlreadyFinished = 0; while (noOfTasksAlreadyFinished < noOfTasksToFinish) { Thread.sleep(1000); noOfTasksAlreadyFinished = (isMap ? jip.finishedMaps() : jip.finishedReduces()); LOG.info("Waiting till " + noOfTasksToFinish + (isMap ? " map" : " reduce") + " tasks of the job " + jip.getJobID() + " finish. " + noOfTasksAlreadyFinished + " tasks already got finished."); } }
private void checkAndInit() throws IOException { String jobStatus = this.job.get(Keys.JOB_STATUS); if (Values.PREP.name().equals(jobStatus)) { hasUpdates = true; LOG.info("Calling init from RM for job " + jip.getJobID().toString()); jip.initTasks(); } }
private void decrementSpeculativeCount(boolean wasSpeculating, TaskInProgress tip) { if (wasSpeculating) { if (tip.isMapTask()) { speculativeMapTasks--; if (LOG.isDebugEnabled()) { LOG.debug("Decremented count for " + tip.getTIPId()+"/"+tip.getJob().getJobID() + ". Current speculativeMap task count: " + speculativeMapTasks); } } else { speculativeReduceTasks--; if (LOG.isDebugEnabled()) { LOG.debug("Decremented count for " + tip.getTIPId()+"/"+tip.getJob().getJobID() + ". Current speculativeReduce task count: " + speculativeReduceTasks); } } } }
/** * Wait till noOfTasksToBeRunning number of tasks of type specified by isMap * started running. This currently uses a jip object and directly uses its api * to determine the number of tasks running. * * <p> * * TODO: It should eventually use a JobID and then get the information from * the JT to check the number of running tasks. * * @param jip * @param isMap * @param noOfTasksToBeRunning */ static void waitTillNTasksStartRunning(JobInProgress jip, boolean isMap, int noOfTasksToBeRunning) throws InterruptedException { int numTasks = 0; while (numTasks != noOfTasksToBeRunning) { Thread.sleep(1000); numTasks = isMap ? jip.runningMaps() : jip.runningReduces(); LOG.info("Waiting till " + noOfTasksToBeRunning + (isMap ? " map" : " reduce") + " tasks of the job " + jip.getJobID() + " start running. " + numTasks + " tasks already started running."); } }
public void jobUpdated(JobChangeEvent event) { LOG.info("Job " + event.getJobInProgress().getJobID().toString() + " updated"); // remove the job is the event is for a completed job if (event instanceof JobStatusChangeEvent) { JobStatusChangeEvent statusEvent = (JobStatusChangeEvent)event; if (statusEvent.getEventType() == EventType.RUN_STATE_CHANGED) { // check if the state changes from // RUNNING->COMPLETE(SUCCESS/KILLED/FAILED) JobInProgress jip = event.getJobInProgress(); String jobId = jip.getJobID().toString(); if (jip.isComplete()) { LOG.info("Job " + jobId + " deleted from the running queue"); if (statusEvent.getOldStatus().getRunState() == JobStatus.PREP) { wjobs.remove(jip); } else { rjobs.remove(jip); } } else { // PREP->RUNNING LOG.info("Job " + jobId + " deleted from the waiting queue"); wjobs.remove(jip); rjobs.add(jip); rjobsAdded.add(jip.getJobID()); } } } } }
/** * Fail a job and inform the listeners. Other components in the framework * should use this to fail a job. */ public synchronized void failJob(JobInProgress job) { if (null == job) { LOG.info("Fail on null job is not valid"); return; } JobStatus prevStatus = (JobStatus)job.getStatus().clone(); LOG.info("Failing job " + job.getJobID()); job.fail(); // Inform the listeners if the job state has changed JobStatus newStatus = (JobStatus)job.getStatus().clone(); if (prevStatus.getRunState() != newStatus.getRunState()) { JobStatusChangeEvent event = new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED, prevStatus, newStatus); updateJobInProgressListeners(event); } }
/** * Adds a job to the jobtracker. Make sure that the checks are inplace before * adding a job. This is the core job submission logic * @param jobId The id for the job submitted which needs to be added */ synchronized JobStatus addJob(JobID jobId, JobInProgress job) { totalSubmissions++; synchronized (jobs) { synchronized (taskScheduler) { jobs.put(job.getProfile().getJobID(), job); for (JobInProgressListener listener : jobInProgressListeners) { try { listener.jobAdded(job); } catch (IOException ioe) { LOG.warn("Failed to add and so skipping the job : " + job.getJobID() + ". Exception : " + ioe); } } } } myInstrumentation.submitJob(job.getJobConf(), jobId); LOG.info("Job " + jobId + " added successfully for user '" + job.getJobConf().getUser() + "' to queue '" + job.getJobConf().getQueueName() + "'"); return job.getStatus(); }
/** * Fail a job and inform the listeners. Other components in the framework * should use this to fail a job. */ public synchronized void failJob(JobInProgress job) { if (null == job) { LOG.info("Fail on null job is not valid"); return; } JobStatus prevStatus = (JobStatus)job.getStatus().clone(); LOG.info("Failing job " + job.getJobID()); job.fail(); // Inform the listeners if the job state has changed JobStatus newStatus = (JobStatus)job.getStatus().clone(); if (prevStatus.getRunState() != newStatus.getRunState()) { JobStatusChangeEvent event = new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED, prevStatus, newStatus); updateJobInProgressListeners(event); } }
/** * Check the ACLs for a user doing the passed operation. * <ul> * <li>If ACLs are disabled, allow all users.</li> * <li>Otherwise, if the operation is not a job operation(for eg. * submit-job-to-queue), then allow only (a) clusterOwner(who started the * cluster), (b) cluster administrators and (c) members of * queue-submit-job-acl for the queue.</li> * <li>If the operation is a job operation, then allow only (a) jobOwner, * (b) clusterOwner(who started the cluster), (c) cluster administrators, * (d) members of queue admins acl for the queue and (e) members of job * acl for the job operation</li> * </ul> * * @param job the job on which operation is requested * @param callerUGI the user who is requesting the operation * @param operation the operation for which authorization is needed * @throws AccessControlException */ void checkAccess(JobInProgress job, UserGroupInformation callerUGI, Operation operation) throws AccessControlException { String queue = job.getProfile().getQueueName(); String jobId = job.getJobID().toString(); JobStatus jobStatus = job.getStatus(); String jobOwner = jobStatus.getUsername(); AccessControlList jobAcl = jobStatus.getJobACLs().get(operation.jobACLNeeded); checkAccess(jobId, callerUGI, queue, operation, jobOwner, jobAcl); }
private TaskInProgress createAndAddTIP(JobTracker jobtracker, JobInProgress jip, TaskType type) { JobConf conf = jip.getJobConf(); JobID id = jip.getJobID(); // now create a fake tip for this fake job TaskInProgress tip = null; if (type == TaskType.MAP) { tip = new TaskInProgress(id, "dummy", JobSplit.EMPTY_TASK_SPLIT, jobtracker, conf, jip, 0, 1); jip.maps = new TaskInProgress[] {tip}; } else if (type == TaskType.REDUCE) { tip = new TaskInProgress(id, "dummy", jip.desiredMaps(), 0, jobtracker, conf, jip, 1); jip.reduces = new TaskInProgress[] {tip}; } else if (type == TaskType.JOB_SETUP) { tip = new TaskInProgress(id, "dummy", JobSplit.EMPTY_TASK_SPLIT, jobtracker, conf, jip, 0, 1); jip.setup = new TaskInProgress[] {tip}; } else if (type == TaskType.JOB_CLEANUP) { tip = new TaskInProgress(id, "dummy", JobSplit.EMPTY_TASK_SPLIT, jobtracker, conf, jip, 0, 1); jip.cleanup = new TaskInProgress[] {tip}; } return tip; }
private synchronized void killJob(JobInProgress job) { LOG.info("Killing job " + job.getJobID()); JobStatus prevStatus = (JobStatus)job.getStatus().clone(); job.kill(); // Inform the listeners if the job is killed // Note : // If the job is killed in the PREP state then the listeners will be // invoked // If the job is killed in the RUNNING state then cleanup tasks will be // launched and the updateTaskStatuses() will take care of it JobStatus newStatus = (JobStatus)job.getStatus().clone(); if (prevStatus.getRunState() != newStatus.getRunState() && newStatus.getRunState() == JobStatus.KILLED) { JobStatusChangeEvent event = new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED, prevStatus, newStatus); updateJobInProgressListeners(event); } }
private synchronized void killJob(JobInProgress job) { LOG.info("Killing job " + job.getJobID()); JobStatus prevStatus = (JobStatus)job.getStatus().clone(); job.kill(); // Inform the listeners if the job is killed // Note : // If the job is killed in the PREP state then the listeners will be // invoked // If the job is killed in the RUNNING state then cleanup tasks will be // launched and the updateTaskStatuses() will take care of it JobStatus newStatus = (JobStatus)job.getStatus().clone(); if (prevStatus.getRunState() != newStatus.getRunState() && newStatus.getRunState() == JobStatus.KILLED) { JobStatusChangeEvent event = new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED, prevStatus, newStatus); updateJobInProgressListeners(event); } }
private JobStatusChangeEvent updateJob(JobInProgress jip, JobHistory.JobInfo job) { // Change the job priority String jobpriority = job.get(Keys.JOB_PRIORITY); JobPriority priority = JobPriority.valueOf(jobpriority); // It's important to update this via the jobtracker's api as it will // take care of updating the event listeners too setJobPriority(jip.getJobID(), priority); // Save the previous job status JobStatus oldStatus = (JobStatus)jip.getStatus().clone(); // Set the start/launch time only if there are recovered tasks // Increment the job's restart count jip.updateJobInfo(job.getLong(JobHistory.Keys.SUBMIT_TIME), job.getLong(JobHistory.Keys.LAUNCH_TIME), job.getInt(Keys.RESTART_COUNT) + 1); // Save the new job status JobStatus newStatus = (JobStatus)jip.getStatus().clone(); return new JobStatusChangeEvent(jip, EventType.START_TIME_CHANGED, oldStatus, newStatus); }
public void initJob(JobInProgress job) { try { JobStatus prevStatus = (JobStatus)job.getStatus().clone(); job.initTasks(); if (job.isJobEmpty()) { completeEmptyJob(job); } else if (!job.isSetupCleanupRequired()) { job.completeSetup(); } JobStatus newStatus = (JobStatus)job.getStatus().clone(); if (prevStatus.getRunState() != newStatus.getRunState()) { JobStatusChangeEvent event = new JobStatusChangeEvent(job, EventType.RUN_STATE_CHANGED, prevStatus, newStatus); for (JobInProgressListener listener : listeners) { listener.jobUpdated(event); } } } catch (KillInterruptedException kie) { killJob(job.getJobID()); } catch (IOException ioe) { failJob(job); } }