use of org.ow2.proactive.scheduler.task.ClientTaskState in project scheduling by ow2-proactive.
the class DozerMappingTest method createJobState.
private JobState createJobState() {
return new ClientJobState(new JobState() {
@Override
public void update(TaskInfo taskInfo) {
}
@Override
public void update(JobInfo jobInfo) {
}
@Override
public JobInfo getJobInfo() {
return new JobInfoImpl();
}
@Override
public ArrayList<TaskState> getTasks() {
return new ArrayList<>(getHMTasks().values());
}
@Override
public Map<TaskId, TaskState> getHMTasks() {
TaskId taskId = TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 1);
TaskState value = new ClientTaskState(new TaskState() {
@Override
public void update(TaskInfo taskInfo) {
}
@Override
public List<TaskState> getDependences() {
return null;
}
@Override
public TaskInfo getTaskInfo() {
TaskInfoImpl taskInfo = new TaskInfoImpl();
taskInfo.setTaskId(TaskIdImpl.createTaskId(new JobIdImpl(42, "job"), "remoteVisuTask", 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 Collections.singletonMap(taskId, value);
}
@Override
public String getOwner() {
return null;
}
@Override
public JobType getType() {
return null;
}
});
}
use of org.ow2.proactive.scheduler.task.ClientTaskState 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.task.ClientTaskState in project scheduling by ow2-proactive.
the class JobInfoImpl method setTasksChanges.
public void setTasksChanges(ChangedTasksInfo changesInfo, JobState job) {
this.modifiedTasks = new ArrayList<>(changesInfo.getNewTasks().size() + changesInfo.getUpdatedTasks().size());
for (TaskId id : changesInfo.getNewTasks()) {
modifiedTasks.add(new ClientTaskState(job.getHMTasks().get(id)));
}
for (TaskId id : changesInfo.getUpdatedTasks()) {
modifiedTasks.add(new ClientTaskState(job.getHMTasks().get(id)));
}
this.tasksSkipped = new HashSet<>(changesInfo.getSkippedTasks());
}
Aggregations