use of org.ow2.proactive.scheduler.smartproxy.common.AwaitedTask 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.smartproxy.common.AwaitedTask in project scheduling by ow2-proactive.
the class AbstractSmartProxy method submit.
/**
* Submits a job to the scheduler and handle data transfer via the SmartProxy
*
* @param job job to submit
* @param localInputFolderPath path to the local directory containing input files
* @param pushUrl url of the dataspace server used to push input files to
* @param localOutputFolderPath path to the local directory which will contain output files
* @param pullUrl url of the dataspace server used to pull output files from
* @param isolateTaskOutputs if set to true, output files from each tasks will be isolated from each other in the dataspace server (to prevent overlapping)
* @param automaticTransfer if set to true, output files will be automatically transferred from the dataspace server to the local machine as soon as the task is finished.
* If set to false, the files will not be automatically transferred and a call to pullData must be done to transfer files
* @return the new job id
* @throws Exception
* @throws SubmissionClosedException
* @throws JobCreationException
*/
public JobId submit(TaskFlowJob job, String localInputFolderPath, String pushUrl, String localOutputFolderPath, String pullUrl, boolean isolateTaskOutputs, boolean automaticTransfer) throws Exception, SubmissionClosedException, JobCreationException {
checkInitialized();
if (isNullOrEmpty(pushUrl)) {
pushUrl = getLocalUserSpace();
}
if (isNullOrEmpty(pullUrl)) {
pullUrl = getLocalUserSpace();
}
String newFolderName = createNewFolderName();
String pushUrlUpdate = prepareJobInput(job, localInputFolderPath, pushUrl, newFolderName);
String pullUrlUpdate = prepareJobOutput(job, localOutputFolderPath, pullUrl, newFolderName, isolateTaskOutputs);
uploadInputfiles(job, localInputFolderPath);
JobId id = null;
try {
id = submit(job);
} catch (Exception e) {
log.error("Error while submitting job", e);
try {
removeJobIO(job, pushUrl, pullUrl, newFolderName);
} catch (Exception e2) {
log.error("Error while removing job IO", e2);
}
propagateIfInstanceOf(e, NotConnectedException.class);
propagateIfInstanceOf(e, PermissionException.class);
propagateIfInstanceOf(e, SubmissionClosedException.class);
propagateIfInstanceOf(e, JobCreationException.class);
propagateIfInstanceOf(e, RuntimeException.class);
propagate(e);
}
HashMap<String, AwaitedTask> awaitedTaskMap = new HashMap<>();
for (Task t : job.getTasks()) {
awaitedTaskMap.put(t.getName(), new AwaitedTask(t.getName(), t.getOutputFilesList()));
}
AwaitedJob awaitedJob = new AwaitedJob(id.toString(), localInputFolderPath, job.getInputSpace(), pushUrlUpdate, localOutputFolderPath, job.getOutputSpace(), pullUrlUpdate, isolateTaskOutputs, automaticTransfer, awaitedTaskMap);
jobTracker.putAwaitedJob(id.toString(), awaitedJob);
return id;
}
Aggregations