use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class AbstractSmartProxy method updateTask.
/**
* Check if the task concerned by this notification is awaited. Retrieve
* corresponding data if needed
*
* @param notification
*/
protected void updateTask(NotificationData<TaskInfo> notification) {
// am I interested in this task?
TaskInfo taskInfoData = notification.getData();
JobId id = taskInfoData.getJobId();
TaskId tid = taskInfoData.getTaskId();
String tname = tid.getReadableName();
TaskStatus status = taskInfoData.getStatus();
AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
if (aj == null)
return;
AwaitedTask at = aj.getAwaitedTask(tname);
if (at == null)
return;
at.setTaskId(tid.toString());
jobTracker.putAwaitedJob(id.toString(), aj);
switch(status) {
case ABORTED:
case NOT_RESTARTED:
case NOT_STARTED:
case SKIPPED:
{
log.debug("The task " + tname + " from job " + id + " couldn't start. No data will be transfered");
jobTracker.removeAwaitedTask(id.toString(), tname);
break;
}
case FINISHED:
{
log.debug("The task " + tname + " from job " + id + " is finished.");
if (aj.isAutomaticTransfer()) {
log.debug("Transferring data for finished task " + tname + " from job " + id);
try {
downloadTaskOutputFiles(aj, id.toString(), tname, aj.getLocalOutputFolder());
} catch (Throwable t) {
log.error("Error while handling data for finished task " + tname + " for job " + id + ", task will be removed");
jobTracker.removeAwaitedTask(id.toString(), tname);
}
}
break;
}
case FAILED:
case FAULTY:
{
log.debug("The task " + tname + " from job " + id + " is faulty.");
jobTracker.removeAwaitedTask(id.toString(), tname);
break;
}
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class AbstractSmartProxy method updateJob.
// ********* Awaited Jobs methods ******************************* //
/**
* @return a new HashSet with the awaited jobs. Modifying the result of this
* method will not affect the source HashSet (the awaited jobs)
*/
/**
* Check if the job concerned by this notification is awaited. Retrieve
* corresponding data if needed
*
* @param notification
*/
protected void updateJob(NotificationData<?> notification) {
// am I interested in this job?
JobId id = ((NotificationData<JobInfo>) notification).getData().getJobId();
AwaitedJob aj = jobTracker.getAwaitedJob(id.toString());
if (aj == null)
return;
JobStatus status = ((NotificationData<JobInfo>) notification).getData().getStatus();
switch(status) {
case KILLED:
{
log.debug("The job " + id + "has been killed.");
jobTracker.removeAwaitedJob(id.toString());
break;
}
case FINISHED:
{
log.debug("The job " + id + " is finished.");
// removeAwaitedJob(id.toString());
break;
}
case CANCELED:
{
log.debug("The job " + id + " is canceled.");
jobTracker.removeAwaitedJob(id.toString());
break;
}
case FAILED:
{
log.debug("The job " + id + " is failed.");
// removeAwaitedJob(id.toString());
break;
}
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class JobTrackerImpl method removeAwaitedTask.
/**
* Removes from the proxy knowledge all info related with the given task.
* If all tasks of a job have been removed this way, the job itself will be removed.
*
* @param id jobID
* @param taskName task name
*/
public void removeAwaitedTask(String id, String taskName) {
AwaitedJob awaitedJob = jobDatabase.getAwaitedJob(id);
if (awaitedJob == null) {
logger.warn("Job " + id + " not in the awaited list");
return;
}
AwaitedTask awaitedTask = awaitedJob.getAwaitedTask(taskName);
if (awaitedTask == null) {
logger.warn("Task " + taskName + " from Job " + id + " not in the awaited list");
return;
}
logger.debug("Removing knowledge of task " + taskName + " from job " + id);
if (awaitedJob.isIsolateTaskOutputs() && awaitedTask.getTaskId() != null) {
// If the output data as been isolated in a dedicated folder we can delete it.
String pullUrl = awaitedJob.getPullURL();
pullUrl = pullUrl.replace(SchedulerConstants.TASKID_DIR_DEFAULT_NAME, SchedulerConstants.TASKID_DIR_DEFAULT_NAME + "/" + awaitedTask.getTaskId());
FileObject remotePullFolder = null;
try {
remotePullFolder = resolveFile(pullUrl);
logger.debug("Deleting directory " + remotePullFolder);
remotePullFolder.delete(Selectors.SELECT_ALL);
remotePullFolder.delete();
} catch (Exception e) {
logger.warn("Could not remove data for task " + taskName + " of job " + id, e);
}
}
awaitedJob.removeAwaitedTask(taskName);
if (awaitedJob.getAwaitedTasks().isEmpty()) {
removeAwaitedJob(id);
return;
} else {
// this is done to ensure persistence of the operation
jobDatabase.putAwaitedJob(id, awaitedJob);
}
try {
jobDatabase.commit();
} catch (IOException e) {
logger.error("Could not save status file after removing task Task " + taskName + " from Job" + id, e);
}
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class SchedulingServiceTest4 method startTask.
private JobDescriptor startTask() throws Exception {
Map<JobId, JobDescriptor> jobsMap;
JobDescriptor jobDesc;
jobsMap = service.lockJobsToSchedule();
assertEquals(1, jobsMap.size());
jobDesc = jobsMap.values().iterator().next();
Assert.assertEquals(1, jobDesc.getEligibleTasks().size());
for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
}
service.unlockJobsToSchedule(jobsMap.values());
return jobDesc;
}
use of org.ow2.proactive.scheduler.common.job.JobId in project scheduling by ow2-proactive.
the class SchedulingServiceTest5 method testJobKill.
@Test
public void testJobKill() throws Exception {
service.submitJob(createJob(createTestJob()));
listener.assertEvents(SchedulerEvent.JOB_SUBMITTED);
Map<JobId, JobDescriptor> jobsMap;
JobDescriptor jobDesc;
jobsMap = service.lockJobsToSchedule();
assertEquals(1, jobsMap.size());
jobDesc = jobsMap.values().iterator().next();
Assert.assertEquals(2, jobDesc.getEligibleTasks().size());
for (TaskDescriptor taskDesc : jobDesc.getEligibleTasks()) {
taskStarted(jobDesc, (EligibleTaskDescriptor) taskDesc);
}
service.unlockJobsToSchedule(jobsMap.values());
Assert.assertTrue(service.killJob(jobDesc.getJobId()));
listener.assertEvents(SchedulerEvent.JOB_PENDING_TO_RUNNING, SchedulerEvent.JOB_UPDATED, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_PENDING_TO_RUNNING, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.TASK_RUNNING_TO_FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED, SchedulerEvent.JOB_UPDATED);
infrastructure.assertRequests(2);
Assert.assertFalse(service.killJob(jobDesc.getJobId()));
}
Aggregations