Search in sources :

Example 1 with ClientTaskState

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;
        }
    });
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ArrayList(java.util.ArrayList) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState) TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) JobType(org.ow2.proactive.scheduler.common.job.JobType) JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobState(org.ow2.proactive.scheduler.common.job.JobState) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) JobInfoImpl(org.ow2.proactive.scheduler.job.JobInfoImpl) Map(java.util.Map) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState)

Example 2 with ClientTaskState

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));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ClientJobState(org.ow2.proactive.scheduler.job.ClientJobState) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 3 with ClientTaskState

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());
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId) ClientTaskState(org.ow2.proactive.scheduler.task.ClientTaskState)

Aggregations

ClientTaskState (org.ow2.proactive.scheduler.task.ClientTaskState)3 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)2 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)2 ClientJobState (org.ow2.proactive.scheduler.job.ClientJobState)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.Test)1 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)1 JobState (org.ow2.proactive.scheduler.common.job.JobState)1 JobType (org.ow2.proactive.scheduler.common.job.JobType)1 TaskInfo (org.ow2.proactive.scheduler.common.task.TaskInfo)1 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)1 JobInfoImpl (org.ow2.proactive.scheduler.job.JobInfoImpl)1 TaskInfoImpl (org.ow2.proactive.scheduler.task.TaskInfoImpl)1