use of org.ow2.proactive.scheduler.common.job.JobState 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;
}
};
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerClientExample method main.
public static void main(String[] args) throws Exception {
// LOGIN IN
SchedulerRestClient client = new SchedulerRestClient("http://localhost:9191/rest/rest/");
SchedulerRestInterface scheduler = client.getScheduler();
String sessionId = scheduler.login("admin", "admin");
// JOB SUBMISSION
File xmlJobFile = new File("/home/ybonnaffe/src/cloud_service_provider_conectors/cloudstack/vminfo_job.xml");
JobIdData xmlJob;
try (FileInputStream inputStream = new FileInputStream(xmlJobFile)) {
xmlJob = client.submitXml(sessionId, inputStream);
}
System.out.println(xmlJob.getReadableName() + " " + xmlJob.getId());
// FLAT JOB SUBMISSION
JobIdData flatJob = scheduler.submitFlat(sessionId, "echo hello", "test-hello", null, null);
System.out.println("Jobid=" + flatJob);
String serverlog = scheduler.jobServerLog(sessionId, Long.toString(flatJob.getId()));
System.out.println(serverlog);
while (true) {
JobStateData jobState2 = scheduler.listJobs(sessionId, Long.toString(flatJob.getId()));
System.out.println(jobState2);
if (jobState2.getJobInfo().getStatus().name().equals("FINISHED")) {
break;
}
Thread.sleep(100);
}
JobResultData jobResultData = scheduler.jobResult(sessionId, Long.toString(flatJob.getId()));
System.out.println(jobResultData);
TaskResultData taskresult = scheduler.taskResult(sessionId, Long.toString(flatJob.getId()), "task_1");
System.out.println(taskresult);
List<TaskStateData> jobTaskStates = scheduler.getJobTaskStates(sessionId, Long.toString(flatJob.getId())).getList();
System.out.println(jobTaskStates);
TaskStateData task_1 = scheduler.jobTask(sessionId, Long.toString(flatJob.getId()), "task_1");
System.out.println(task_1);
// OTHER CALLS
List<SchedulerUserData> users = scheduler.getUsers(sessionId);
System.out.println(users);
System.out.println(users.size());
RestMapPage<Long, ArrayList<UserJobData>> page = scheduler.revisionAndJobsInfo(sessionId, 0, 50, true, true, true, true);
Map<Long, ArrayList<UserJobData>> map = page.getMap();
System.out.println(map);
System.out.println(scheduler.getSchedulerStatus(sessionId));
System.out.println(scheduler.getUsageOnMyAccount(sessionId, new Date(), new Date()));
// FAILING CALL
try {
JobStateData jobState = scheduler.listJobs(sessionId, "601");
System.out.println(jobState);
} catch (UnknownJobRestException e) {
System.err.println("exception! " + e.getMessage());
e.printStackTrace();
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class SchedulerFrontendState method getTaskState.
synchronized TaskState getTaskState(JobId jobId, TaskId taskId) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException {
checkPermissions("getJobState", getIdentifiedJob(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_GET_THE_STATE_OF_THIS_TASK);
if (jobsMap.get(jobId) == null) {
throw new UnknownJobException(jobId);
}
JobState jobState = jobsMap.get(jobId);
synchronized (jobState) {
TaskState ts = jobState.getHMTasks().get(taskId);
if (ts == null) {
throw new UnknownTaskException(taskId, jobId);
}
return ts;
}
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWhenNodesAreReservedInBatchTest method printJobStateAndReturnNumberOfRunningTasks.
private void printJobStateAndReturnNumberOfRunningTasks(JobId jobid) throws Exception {
Scheduler scheduler = schedulerHelper.getSchedulerInterface();
JobState jobState;
int numberOfPendingTasks;
int numberOfRunningTasks;
jobState = scheduler.getJobState(jobid);
numberOfPendingTasks = jobState.getNumberOfPendingTasks();
numberOfRunningTasks = jobState.getNumberOfRunningTasks();
int numberOfFinishedTasks = jobState.getNumberOfFinishedTasks();
int numberOfInErrorTasks = jobState.getNumberOfInErrorTasks();
SchedulerTHelper.log("Number of pending tasks " + numberOfPendingTasks);
SchedulerTHelper.log("Number of running tasks " + numberOfRunningTasks);
SchedulerTHelper.log("Number of finished tasks " + numberOfFinishedTasks);
SchedulerTHelper.log("Number of in error tasks " + numberOfInErrorTasks);
}
use of org.ow2.proactive.scheduler.common.job.JobState in project scheduling by ow2-proactive.
the class RunningTaskRecoveryWhenNodesAreReservedInBatchTest method action.
@Test
public void action() throws Throwable {
nodes = schedulerHelper.createRMNodeStarterNodes(RunningTaskRecoveryWhenNodesAreReservedInBatchTest.class.getSimpleName(), NB_NODES);
for (int i = 0; i < NB_NODES; i++) {
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
}
JobId jobid = schedulerHelper.submitJob(new File(JOB_DESCRIPTOR.toURI()).getAbsolutePath());
schedulerHelper.waitForEventJobRunning(jobid);
schedulerHelper.waitForEventTaskFinished(jobid, "Groovy_Task");
JobState jobState = schedulerHelper.getSchedulerInterface().getJobState(jobid);
SchedulerTHelper.log("Total number of tasks: " + jobState.getTotalNumberOfTasks());
List<TaskState> tasks = jobState.getTasks();
TaskState fifthTask = tasks.get(5);
SchedulerTHelper.log("Wait for the fifth task running");
// we wait for the fifth task to be running so that when we kill the
// scheduler we have a mix of pending/submitted/running tasks
schedulerHelper.waitForEventTaskRunning(fifthTask.getJobId(), fifthTask.getName());
SchedulerTHelper.log("Fifth task is running");
// restart scheduler
printRmStateAndReturnNotFreeNodeNumber();
printJobStateAndReturnNumberOfRunningTasks(jobid);
TestScheduler.kill();
schedulerHelper = new SchedulerTHelper(false, new File(SCHEDULER_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), new File(RM_CONFIGURATION_RESTART.toURI()).getAbsolutePath(), null, false);
SchedulerTHelper.log("Wait for job to finish");
JobInfo jobInfo = schedulerHelper.waitForEventJobFinished(jobid);
assertThat(jobInfo.getNumberOfFailedTasks()).isEqualTo(0);
assertThat(jobInfo.getNumberOfInErrorTasks()).isEqualTo(0);
// wait for all nodes released
while (printRmStateAndReturnNotFreeNodeNumber() != 0) {
schedulerHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
}
// all nodes should be free now
int notFreeNodeNumber = printRmStateAndReturnNotFreeNodeNumber();
assertThat(notFreeNodeNumber).isEqualTo(0);
}
Aggregations