use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData 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:8080/rest/");
SchedulerRestInterface scheduler = client.getScheduler();
String sessionId = scheduler.login("admin", "admin");
// JOB SUBMISSION
File xmlJobFile = new File("/path/to/some/existing/job/job_1.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, true, null, null, null, null, null);
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_grid_cloud_portal.scheduler.dto.JobResultData in project scheduling by ow2-proactive.
the class GetJobResultCommandTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
DataFaker<JobResultData> jobResultFaker = new DataFaker<JobResultData>(JobResultData.class);
jobResultFaker.setGenerator("id.readableName", new PrefixPropertyGenerator("job", 1));
jobResultFaker.setGenerator("allResults.key", new PrefixPropertyGenerator("task", 1));
jobResultFaker.setGenerator("allResults.value.id.readableName", new PrefixPropertyGenerator("task", 1));
jobResultFaker.setGenerator("allResults.value.serializedValue", new FixedPropertyGenerator(ObjectByteConverter.serializableToBase64String("Hello")));
jobResult = jobResultFaker.fake();
DataFaker<TaskResultData> taskResultsDataFaker = new DataFaker<TaskResultData>(TaskResultData.class);
taskResultsDataFaker.setGenerator("id.readableName", new PrefixPropertyGenerator("task", 4));
taskResultsDataFaker.setGenerator("serializedValue", new FixedPropertyGenerator(ObjectByteConverter.serializableToBase64String("Hello")));
taskResults = taskResultsDataFaker.fakeList(3);
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData in project scheduling by ow2-proactive.
the class SchedulerClient method getJobResult.
@Override
public JobResult getJobResult(String jobId) throws NotConnectedException, PermissionException, UnknownJobException {
JobResult jobResult = null;
try {
JobResultData jobResultData = restApi().jobResult(sid, jobId);
jobResult = toJobResult(jobResultData);
} catch (Exception e) {
throwUJEOrNCEOrPE(e);
}
return jobResult;
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData in project scheduling by ow2-proactive.
the class GetJobResultCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
try {
SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
if (this.tag == null) {
JobResultData results = scheduler.jobResult(currentContext.getSessionId(), jobId);
resultStack(currentContext).push(results);
if (!currentContext.isForced()) {
writeLine(currentContext, "%s", StringUtility.jobResultAsString(job(), results));
}
} else {
List<TaskResultData> results = scheduler.taskResultByTag(currentContext.getSessionId(), jobId, tag);
resultStack(currentContext).push(results);
if (!currentContext.isForced()) {
writeLine(currentContext, "%s", StringUtility.taskResultsAsString(results));
}
}
} catch (Exception e) {
handleError(String.format("An error occurred while retrieving %s result:", job()), e, currentContext);
}
}
use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData in project scheduling by ow2-proactive.
the class SchedulerStateRestJobTaskResultTest method testValueOfJobResult.
@Test
public void testValueOfJobResult() throws Throwable {
TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("42"), "mytask", 1), ObjectToByteConverter.ObjectStream.convert("hello"), null, null, false);
JobResultImpl jobResultWithValue = new JobResultImpl();
JobInfoImpl jobInfo = new JobInfoImpl();
jobInfo.setJobId(new JobIdImpl(12, "myjob"));
jobResultWithValue.setJobInfo(jobInfo);
jobResultWithValue.addTaskResult("mytask", taskResult, false);
when(mockOfScheduler.getJobResult("42")).thenReturn(jobResultWithValue);
JobResultData jobResultData = restInterface.jobResult(sessionId, "42");
TaskResultData taskResultData = jobResultData.getAllResults().get("mytask");
assertNotNull(taskResultData);
assertNotNull(taskResultData.getValue());
assertEquals("hello", taskResultData.getValue());
Map<String, String> jobResult = restInterface.jobResultValue(sessionId, "42");
String result = jobResult.get("mytask");
assertNotNull(result);
assertEquals("hello", result);
}
Aggregations