use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskResultsByTag.
@Override
public List<TaskResult> getTaskResultsByTag(JobId jobId, String taskTag) throws NotConnectedException, UnknownJobException, PermissionException {
List<TaskState> taskStates = getJobState(jobId).getTasksByTag(taskTag);
ArrayList<TaskResult> results = new ArrayList<TaskResult>(taskStates.size());
for (TaskState currentState : taskStates) {
String taskName = currentState.getTaskInfo().getName();
try {
TaskResult currentResult = getTaskResult(jobId, taskName);
results.add(currentResult);
} catch (UnknownTaskException ex) {
// never occurs because tasks are filtered by tag so they cannot
// be unknown.
logger.warn("Unknown task.", ex);
}
}
return results;
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class SchedulerClient method getTaskStates.
@Override
public Page<TaskState> getTaskStates(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit, SortSpecifierContainer sortParams) throws NotConnectedException, PermissionException {
RestPage<TaskStateData> page = null;
SortSpecifierContainer sortContainer = new SortSpecifierContainer(sortParams.toString());
try {
page = restApi().getTaskStates(sid, from, to, mytasks, running, pending, finished, offset, limit, sortContainer);
} catch (NotConnectedRestException e) {
throw new NotConnectedException(e);
} catch (PermissionRestException e) {
throw new PermissionException(e);
}
List<TaskState> lTaskStates = new ArrayList<TaskState>(page.getList().size());
for (TaskStateData taskStateData : page.getList()) {
lTaskStates.add(new TaskStateImpl(taskStateData));
}
return new Page<TaskState>(lTaskStates, page.getSize());
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class JobStateImpl method getHMTasks.
@Override
public Map<TaskId, TaskState> getHMTasks() {
Map<String, TaskStateData> taskStateDataMap = jobStateData.getTasks();
Map<TaskId, TaskState> taskStateMap = new HashMap<>();
for (TaskStateData taskStateData : taskStateDataMap.values()) {
TaskIdData taskIdData = taskStateData.getTaskInfo().getTaskId();
taskStateMap.put(DataUtility.taskId(DataUtility.jobId(jobStateData.getJobInfo().getJobId()), taskIdData), DataUtility.taskState(taskStateData));
}
return taskStateMap;
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class ClientJobStateSerializationTest method JobStateSerializationRestoresAllDependenciesFromClientTaskSates.
@Test
public void JobStateSerializationRestoresAllDependenciesFromClientTaskSates() {
// Task1 depends on task2
ClientTaskState clientTaskState1 = new ClientTaskState(new TestTaskState(1L));
ClientTaskState clientTaskState2 = new ClientTaskState(new TestTaskState(2L));
clientTaskState2.getDependences().add(clientTaskState1);
// Create JClientJobState which contains task1 and task2
TestJobState testJobState = new TestJobState(1);
testJobState.getHMTasks().put(clientTaskState1.getId(), clientTaskState1);
testJobState.getHMTasks().put(clientTaskState2.getId(), clientTaskState2);
ClientJobState clientJobState = new ClientJobState(testJobState);
// Serialize and de-serialize the ClientJobState instance
ClientJobState deserializedClientJobState = null;
try {
ByteArrayOutputStream output = new ByteArrayOutputStream();
new ObjectOutputStream(output).writeObject(clientJobState);
deserializedClientJobState = (ClientJobState) new ObjectInputStream(new ByteArrayInputStream(output.toByteArray())).readObject();
} catch (Exception e) {
e.printStackTrace();
fail("Serialization must not fail with exception. " + e.getMessage());
}
List<TaskState> listWithOneElement = deserializedClientJobState.getHMTasks().get(clientTaskState2.getId()).getDependences();
assertThat(listWithOneElement.size(), is(1));
}
use of org.ow2.proactive.scheduler.common.task.TaskState in project scheduling by ow2-proactive.
the class ClientJobStateTest method createJobState.
private JobState createJobState(final JobInfoImpl jobInfo) {
return new JobState() {
@Override
public void update(TaskInfo info) {
}
@Override
public void update(JobInfo jobInfo) {
}
@Override
public JobInfo getJobInfo() {
return jobInfo;
}
@Override
public List<TaskState> getTasks() {
List<TaskState> tasks = new ArrayList<>(0);
tasks.add(new TaskState() {
@Override
public void update(TaskInfo taskInfo) {
}
@Override
public List<TaskState> getDependences() {
return null;
}
@Override
public TaskInfo getTaskInfo() {
TaskInfoImpl taskInfo = new TaskInfoImpl();
taskInfo.setJobInfo(jobInfo);
taskInfo.setTaskId(TaskIdImpl.createTaskId(jobInfo.getJobId(), "task", 1));
return taskInfo;
}
@Override
public int getMaxNumberOfExecutionOnFailure() {
return 0;
}
@Override
public TaskState replicate() throws Exception {
return null;
}
@Override
public int getIterationIndex() {
return 0;
}
@Override
public int getReplicationIndex() {
return 0;
}
});
return tasks;
}
@Override
public Map<TaskId, TaskState> getHMTasks() {
return null;
}
@Override
public String getOwner() {
return null;
}
@Override
public JobType getType() {
return null;
}
};
}
Aggregations