Search in sources :

Example 96 with TaskIdImpl.createTaskId

use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.

the class TaskLoggerTest method testFileAppender.

@Test
public void testFileAppender() throws IOException {
    JobId jobId = new JobIdImpl(1123, "readableName");
    TaskId taskId = TaskIdImpl.createTaskId(jobId, "taskreadableName", 123123);
    FileAppender appender = new FileAppender();
    File logFolder = folder.newFolder("logs");
    File logFile = new File(logFolder, TaskLogger.getTaskLogRelativePath(taskId));
    appender.setFilesLocation(logFolder.getAbsolutePath());
    try {
        appender.append(TaskLogger.getTaskLogRelativePath(taskId), new LoggingEvent("mylogger", Logger.getRootLogger(), Level.INFO, "HelloWorld", null));
    } catch (Exception e) {
        Assert.fail(e);
    }
    assertTrue(FileUtils.readFileToString(logFile, Charset.defaultCharset()).contains("HelloWorld"));
}
Also used : FileAppender(org.ow2.proactive.utils.appenders.FileAppender) LoggingEvent(org.apache.log4j.spi.LoggingEvent) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId) IOException(java.io.IOException) Test(org.junit.Test)

Example 97 with TaskIdImpl.createTaskId

use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.

the class LiveJobsTest method testGetRunningTaskByTaskId.

@Test(timeout = 600000)
public void testGetRunningTaskByTaskId() throws UnknownTaskException {
    PASchedulerProperties.NUMBER_OF_EXECUTION_ON_FAILURE.updateProperty("5");
    JobId id = new JobIdImpl(666L, "test-name");
    TaskId tid = TaskIdImpl.createTaskId(id, "task-name", 0L);
    submitJobAndStartTask(id, tid);
    JobId id2 = new JobIdImpl(667L, "test-name");
    TaskId tid2 = TaskIdImpl.createTaskId(id2, "task-name2", 0L);
    submitJobAndStartTask(id2, tid2);
    JobId id3 = new JobIdImpl(668L, "test-name");
    TaskId tid3 = TaskIdImpl.createTaskId(id3, "task-name3", 0L);
    submitJobAndStartTask(id3, tid3);
    JobId id4 = new JobIdImpl(669L, "test-name");
    TaskId tid4 = TaskIdImpl.createTaskId(id4, "task-name4", 0L);
    submitJobAndStartTask(id4, tid4);
    JobId id5 = new JobIdImpl(670L, "test-name");
    TaskId tid5 = TaskIdImpl.createTaskId(id5, "task-name5", 0L);
    submitJobAndStartTask(id5, tid5);
    assertThat(liveJobs.getRunningTasks().size(), is(5));
    assertThat(liveJobs.getRunningTask(tid).getTask().getName(), is("task-name"));
    assertThat(liveJobs.getRunningTask(tid).getTask().getJobId(), is(id));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 98 with TaskIdImpl.createTaskId

use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.

the class LiveJobsTest method testCanPingTask.

@Test(timeout = 60000)
public void testCanPingTask() throws UnknownJobException, UnknownTaskException {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    JobId id = new JobIdImpl(666L, "test-name");
    job.setId(id);
    List<InternalTask> tasksList = new ArrayList<>();
    InternalTask internalTask = new InternalScriptTask(job);
    TaskId taskId = TaskIdImpl.createTaskId(id, "task-name", 777L);
    internalTask.setId(taskId);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.RUNNING);
    internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
    tasksList.add(internalTask);
    job.setTasks(tasksList);
    liveJobs.jobSubmitted(job);
    liveJobs.lockJobsToSchedule();
    liveJobs.taskStarted(job, job.getTask("task-name"), null);
    assertThat(liveJobs.canPingTask(liveJobs.getRunningTasks().iterator().next()), is(true));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 99 with TaskIdImpl.createTaskId

use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.

the class LiveJobsTest method testTaskTerminatedWithResultSuspendTaskOnError.

@Test(timeout = 60000)
public void testTaskTerminatedWithResultSuspendTaskOnError() throws UnknownTaskException {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    JobId id = new JobIdImpl(666L, "test-name");
    job.setId(id);
    List<InternalTask> tasksList = new ArrayList<>();
    InternalTask internalTask = new InternalScriptTask(job);
    TaskId taskId = TaskIdImpl.createTaskId(id, "task-name", 0L);
    internalTask.setId(taskId);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.RUNNING);
    internalTask.setExecuterInformation(Mockito.mock(ExecuterInformation.class));
    TaskInfoImpl taskInfoImpl = (TaskInfoImpl) internalTask.getTaskInfo();
    taskInfoImpl.setNumberOfExecutionLeft(2);
    internalTask.setOnTaskError(OnTaskError.PAUSE_TASK);
    tasksList.add(internalTask);
    job.setTasks(tasksList);
    liveJobs.jobSubmitted(job);
    liveJobs.lockJobsToSchedule();
    liveJobs.taskStarted(job, job.getTask("task-name"), null);
    TaskResultImpl result = new TaskResultImpl(taskId, new Exception(), null, 330);
    liveJobs.taskTerminatedWithResult(taskId, result);
    assertThat(taskInfoImpl.getNumberOfExecutionLeft(), is(1));
    assertThat(taskInfoImpl.getStatus(), is(TaskStatus.WAITING_ON_ERROR));
    assertThat(job.getStatus(), is(JobStatus.STALLED));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 100 with TaskIdImpl.createTaskId

use of org.ow2.proactive.scheduler.task.TaskIdImpl.createTaskId in project scheduling by ow2-proactive.

the class TaskProActiveDataspacesIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    String rootPath = folder.getRoot().getAbsolutePath();
    System.out.println("Scheduler folder for dataspaces is " + rootPath);
    String owner = "bobot";
    JobId jobId = JobIdImpl.makeJobId("42");
    TaskId taskId = TaskIdImpl.createTaskId(jobId, "taskId", 0);
    schedulerDataspaceProcess = spawnNewJvm(SchedulerDataspace.class, rootPath);
    String schedulerDataspaceUrl = readLine(schedulerDataspaceProcess.getInputStream());
    schedulerDataspace = PAActiveObject.lookupActive(SchedulerDataspace.class, schedulerDataspaceUrl);
    schedulerDataspace.init(jobId, taskId, owner);
    String namingServiceUrl = schedulerDataspace.getNamingServiceUrl();
    nodeDataspaceProcess = spawnNewJvm(NodeDataspace.class);
    String nodeDataspaceUrl = readLine(nodeDataspaceProcess.getInputStream());
    nodeDataspace = PAActiveObject.lookupActive(NodeDataspace.class, nodeDataspaceUrl);
    nodeDataspace.init(taskId, namingServiceUrl);
    // prints the path to the scratch folder of the node
    System.out.println(readLine(nodeDataspaceProcess.getInputStream()));
    globalSpace = nodeDataspace.getGlobalSpace();
    userSpace = nodeDataspace.getUserSpace();
    inputSpace = nodeDataspace.getInputSpace();
    outputSpace = nodeDataspace.getOutputSpace();
    scratchSpace = nodeDataspace.getScratchFolder();
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) JobId(org.ow2.proactive.scheduler.common.job.JobId) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)86 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 SimpleScript (org.ow2.proactive.scripting.SimpleScript)52 TaskScript (org.ow2.proactive.scripting.TaskScript)52 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)49 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)32 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)30 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)29 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)22 JobId (org.ow2.proactive.scheduler.common.job.JobId)19 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)19 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)18 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)15 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)14 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)14 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)14 File (java.io.File)11 ArrayList (java.util.ArrayList)11 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)10 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)10