use of org.ow2.proactive.scheduler.task.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;
}
use of org.ow2.proactive.scheduler.task.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();
}
use of org.ow2.proactive.scheduler.task.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"));
}
use of org.ow2.proactive.scheduler.task.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();
}
use of org.ow2.proactive.scheduler.task.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));
}
Aggregations