Search in sources :

Example 1 with InternalTaskFlowJob

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));
}
Also used : InputStream(java.io.InputStream) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) File(java.io.File) Test(org.junit.Test)

Example 2 with InternalTaskFlowJob

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));
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl)

Example 3 with InternalTaskFlowJob

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()));
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InputStream(java.io.InputStream) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) File(java.io.File) Test(org.junit.Test)

Example 4 with InternalTaskFlowJob

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;
}
Also used : InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl)

Example 5 with InternalTaskFlowJob

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;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) GlobalVariablesData(org.ow2.proactive.scheduler.common.job.factories.globalvariables.GlobalVariablesData) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobVariable(org.ow2.proactive.scheduler.common.job.JobVariable) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)39 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)33 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)33 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)30 Test (org.junit.Test)27 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)27 JobId (org.ow2.proactive.scheduler.common.job.JobId)22 ArrayList (java.util.ArrayList)20 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)14 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)10 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)5 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)5 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)5 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)5 InputStream (java.io.InputStream)3 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)3 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 Node (org.objectweb.proactive.core.node.Node)2 SchedulerDBManager (org.ow2.proactive.scheduler.core.db.SchedulerDBManager)2