Search in sources :

Example 76 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class SchedulerClient method getTaskResult.

@Override
public TaskResult getTaskResult(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
    TaskResultImpl taskResult = null;
    try {
        TaskResultData taskResultData = restApi().taskResult(sid, jobId, taskName);
        taskResult = (TaskResultImpl) toTaskResult(JobIdImpl.makeJobId(jobId), taskResultData);
        if (taskResult.value() == null) {
            Serializable value = restApi().valueOfTaskResult(sid, jobId, taskName);
            if (value != null) {
                taskResult.setValue(value);
            }
        }
    } catch (Throwable t) {
        throwUJEOrNCEOrPEOrUTE(exception(t));
    }
    return taskResult;
}
Also used : Serializable(java.io.Serializable) TaskResultImpl(org.ow2.proactive.scheduler.rest.data.TaskResultImpl) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)

Example 77 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testThatGetPropagatedVariablesAreExtractedFromParents.

@Test
public void testThatGetPropagatedVariablesAreExtractedFromParents() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
    loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
    when(mockedTaskResultImpl.getPropagatedVariables()).thenReturn(new HashMap<String, byte[]>());
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenReturn(loadTaskResultsValue);
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJobTaskFlowType(this.getMockedJobDescriptorWithPausedTask()), this.getMockedInternalTask());
    verify(mockedTaskResultImpl, atLeastOnce()).getPropagatedVariables();
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 78 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testThatPropagatedVariablesAreExtractedFromParents.

@Test
public void testThatPropagatedVariablesAreExtractedFromParents() throws UnknownTaskException {
    Map<String, byte[]> fakeVariableMap = new HashMap<>();
    fakeVariableMap.put("ParentVar", "5623g".getBytes());
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedParentTaskResultImpl = mock(TaskResultImpl.class);
    Map<TaskId, TaskResult> loadParentTaskResultsValue = new HashMap<>();
    loadParentTaskResultsValue.put(this.createTaskID(), mockedParentTaskResultImpl);
    when(mockedParentTaskResultImpl.getPropagatedVariables()).thenReturn(fakeVariableMap);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenReturn(loadParentTaskResultsValue);
    TaskResult taskResult = taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJobTaskFlowType(this.getMockedJobDescriptorWithPausedTask()), this.getMockedInternalTask());
    when(taskResult.getPropagatedVariables()).thenCallRealMethod();
    assertThat(new String(taskResult.getPropagatedVariables().get("ParentVar")), is("5623g"));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 79 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testRunningTasksAreCheckedForATaskId.

@Test
public void testRunningTasksAreCheckedForATaskId() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = new TaskResultCreator();
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
    loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenReturn(loadTaskResultsValue);
    JobDescriptorImpl mockedJobDescriptorHasRunningTask = this.getMockedJobDescriptorWithRunningTask();
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(mockedJobDescriptorHasRunningTask), this.getMockedInternalTask());
    verify(mockedJobDescriptorHasRunningTask, atLeastOnce()).getRunningTasks();
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) JobDescriptorImpl(org.ow2.proactive.scheduler.descriptor.JobDescriptorImpl) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 80 with TaskResultImpl

use of org.ow2.proactive.scheduler.rest.data.TaskResultImpl in project scheduling by ow2-proactive.

the class TaskResultCreatorTest method testThatEmptyTaskResultIsUsedWhenResultIsNotInDatabase.

@Test
public void testThatEmptyTaskResultIsUsedWhenResultIsNotInDatabase() throws UnknownTaskException {
    TaskResultCreator taskResultCreator = spy(TaskResultCreator.class);
    TaskResultImpl mockedTaskResultImpl = mock(TaskResultImpl.class);
    doReturn(mockedTaskResultImpl).when(taskResultCreator).getEmptyTaskResult(any(InternalTask.class), any(Throwable.class), any(TaskLogs.class));
    Map<TaskId, TaskResult> loadTaskResultsValue = new HashMap<>();
    loadTaskResultsValue.put(this.createTaskID(), mockedTaskResultImpl);
    SchedulerDBManager mockedschedulerDbManager = mock(SchedulerDBManager.class);
    when(mockedschedulerDbManager.loadTasksResults(any(JobId.class), any(List.class))).thenThrow(DatabaseManagerException.class);
    taskResultCreator.getTaskResult(mockedschedulerDbManager, this.getMockedInternalJob(this.getMockedJobDescriptorWithPausedTask()), this.getMockedInternalTask());
    verify(mockedTaskResultImpl).setPropagatedVariables(any(Map.class));
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) HashMap(java.util.HashMap) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) TaskLogs(org.ow2.proactive.scheduler.common.task.TaskLogs) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)73 Test (org.junit.Test)70 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)32 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)30 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)26 SimpleScript (org.ow2.proactive.scripting.SimpleScript)26 TaskScript (org.ow2.proactive.scripting.TaskScript)26 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)25 TaskContext (org.ow2.proactive.scheduler.task.context.TaskContext)25 NodeDataSpacesURIs (org.ow2.proactive.scheduler.task.context.NodeDataSpacesURIs)22 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)21 JobId (org.ow2.proactive.scheduler.common.job.JobId)16 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)16 InProcessTaskExecutor (org.ow2.proactive.scheduler.task.executors.InProcessTaskExecutor)15 HashMap (java.util.HashMap)13 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)13 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)13 SimpleTaskLogs (org.ow2.proactive.scheduler.common.task.SimpleTaskLogs)12 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)11 TaskLauncherInitializer (org.ow2.proactive.scheduler.task.TaskLauncherInitializer)10