use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class SchedulerStateRestJobLogsTest method job_full_logs_sorted.
@Test
public void job_full_logs_sorted() throws Exception {
InternalTaskFlowJob jobState = new InternalTaskFlowJob();
addTask(jobState, 1, 10);
addTask(jobState, 10, 2);
addTask(jobState, 3, 3);
File logFolder = tempFolder.newFolder("123");
File logFile = new File(logFolder, "TaskLogs-123-10.log");
FileUtils.write(logFile, "10");
logFile = new File(logFolder, "TaskLogs-123-2.log");
FileUtils.write(logFile, "2");
logFile = new File(logFolder, "TaskLogs-123-3.log");
FileUtils.write(logFile, "3");
when(mockScheduler.getJobState("123")).thenReturn(jobState);
when(mockScheduler.getUserSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
when(mockScheduler.getGlobalSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
InputStream fullLogs = (InputStream) restScheduler.jobFullLogs(validSessionId, "123", validSessionId, null).getEntity();
assertEquals("1032", IOUtils.toString(fullLogs));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class SchedulerStateRestJobLogsTest method addTask.
private static void addTask(InternalTaskFlowJob jobState, long finishedTime, long id) {
InternalScriptTask task = new InternalScriptTask(jobState);
task.setPreciousLogs(true);
task.setFinishedTime(finishedTime);
jobState.addTask(task);
task.setId(TaskIdImpl.createTaskId(new JobIdImpl(123, "job"), "task", id));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class SchedulerStateRestJobLogsTest method job_full_logs_finished.
@Test
public void job_full_logs_finished() throws Exception {
InternalTaskFlowJob jobState = new InternalTaskFlowJob();
InternalScriptTask task = new InternalScriptTask(jobState);
task.setPreciousLogs(true);
jobState.addTask(task);
File logFolder = tempFolder.newFolder("0");
File logFile = new File(logFolder, "TaskLogs-0-0.log");
FileUtils.write(logFile, "logs", Charset.defaultCharset());
when(mockScheduler.getJobState("0")).thenReturn(jobState);
when(mockScheduler.getUserSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
when(mockScheduler.getGlobalSpaceURIs()).thenReturn(Collections.singletonList(logFolder.getParent()));
InputStream fullLogs = (InputStream) restScheduler.jobFullLogs(validSessionId, "0", validSessionId, null).getEntity();
assertEquals("logs", IOUtils.toString(fullLogs, Charset.defaultCharset()));
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class RecoveredSchedulerStateTest method createJob.
public InternalJob createJob(JobStatus jobStatus, int id) {
InternalTaskFlowJob job = new InternalTaskFlowJob("MyJob", JobPriority.HIGH, OnTaskError.CANCEL_JOB, "Description");
InternalScriptTask internalScriptTask = new InternalScriptTask(job);
job.addTasks(ImmutableList.<InternalTask>of(internalScriptTask));
job.setId(JobIdImpl.makeJobId("" + id));
JobInfoImpl jobInfo = (JobInfoImpl) job.getJobInfo();
jobInfo.setStatus(jobStatus);
return job;
}
use of org.ow2.proactive.scheduler.job.InternalTaskFlowJob in project scheduling by ow2-proactive.
the class JobData method toInternalJob.
InternalJob toInternalJob() {
JobId jobIdInstance = new JobIdImpl(getId(), getJobName());
JobInfoImpl jobInfo = createJobInfo(jobIdInstance);
InternalJob internalJob = new InternalTaskFlowJob();
internalJob.setCredentials(getCredentials());
internalJob.setJobInfo(jobInfo);
internalJob.setParentId(getParentId());
internalJob.setGenericInformation(getGenericInformation());
internalJob.setVariables(variablesToJobVariables());
internalJob.setProjectName(getProjectName());
internalJob.setOwner(getOwner());
internalJob.setDescription(getDescription());
internalJob.setInputSpace(getInputSpace());
internalJob.setOutputSpace(getOutputSpace());
internalJob.setGlobalSpace(getGlobalSpace());
internalJob.setUserSpace(getGlobalSpace());
internalJob.setMaxNumberOfExecution(getMaxNumberOfExecution());
internalJob.setOnTaskError(OnTaskError.getInstance(this.onTaskErrorString));
if (getTaskRetryDelay() != null) {
internalJob.setTaskRetryDelay(getTaskRetryDelay());
}
internalJob.setScheduledTimeForRemoval(getScheduledTimeForRemoval());
try {
internalJob.setResultMap(SerializationUtil.deserializeVariableMap(getResultMap()));
} catch (IOException | ClassNotFoundException e) {
logger.error("error when serializing result map variables " + e);
}
List<JobContent> jobContentList = getJobContent();
if (jobContentList != null && jobContentList.size() > 0) {
internalJob.setJobContent(jobContentList.get(0).getInitJobContent());
if (internalJob.getJobContent() != null) {
GlobalVariablesData globalVariablesData = GlobalVariablesParser.getInstance().getVariablesFor(internalJob.getJobContent());
Map<String, JobVariable> globalVariables = new LinkedHashMap<>();
Map<String, JobVariable> configuredGlobalVariables = globalVariablesData.getVariables();
for (String variableName : configuredGlobalVariables.keySet()) {
if (internalJob.getVariables().containsKey(variableName)) {
globalVariables.put(variableName, internalJob.getVariables().get(variableName));
} else {
globalVariables.put(variableName, configuredGlobalVariables.get(variableName));
}
}
internalJob.setGlobalVariables(globalVariables);
Map<String, String> globalGenericInfo = new LinkedHashMap<>();
Map<String, String> configuredGlobalGenericInfo = globalVariablesData.getGenericInformation();
for (String giName : configuredGlobalGenericInfo.keySet()) {
if (internalJob.getGenericInformation().containsKey(giName)) {
globalGenericInfo.put(giName, internalJob.getGenericInformation().get(giName));
} else {
globalGenericInfo.put(giName, configuredGlobalGenericInfo.get(giName));
}
}
internalJob.setGlobalGenericInformation(globalGenericInfo);
}
}
return internalJob;
}
Aggregations