Search in sources :

Example 1 with TaskResultData

use of org.ow2.proactive.scheduler.core.db.TaskResultData in project scheduling by ow2-proactive.

the class GetTaskResultCommand method execute.

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    SchedulerRestInterface scheduler = currentContext.getRestClient().getScheduler();
    try {
        TaskResultData taskResult = scheduler.taskResult(currentContext.getSessionId(), jobId, taskId);
        resultStack(currentContext).push(taskResult);
        if (!currentContext.isSilent()) {
            writeLine(currentContext, "%s", StringUtility.taskResultAsString(task(), taskResult));
        }
    } catch (Exception e) {
        handleError(String.format("An error occurred while retrieving %s result:", task()), e, currentContext);
    }
}
Also used : TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) CLIException(org.ow2.proactive_grid_cloud_portal.cli.CLIException)

Example 2 with TaskResultData

use of org.ow2.proactive.scheduler.core.db.TaskResultData in project scheduling by ow2-proactive.

the class GetJobResultCommandTest method testCommandJobIdUnknownTag.

@Test
public void testCommandJobIdUnknownTag() throws Exception {
    when(restApi.taskResultByTag(anyString(), eq(jobId), eq(unknownTag))).thenReturn(new ArrayList<TaskResultData>());
    executeTest(jobId, unknownTag);
    String out = capturedOutput.toString();
    System.out.println(out);
    assertThat(out, equalTo(System.lineSeparator()));
}
Also used : TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 3 with TaskResultData

use of org.ow2.proactive.scheduler.core.db.TaskResultData 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);
}
Also used : PrefixPropertyGenerator(objectFaker.propertyGenerator.PrefixPropertyGenerator) JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) DataFaker(objectFaker.DataFaker) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) FixedPropertyGenerator(objectFaker.propertyGenerator.FixedPropertyGenerator) Before(org.junit.Before)

Example 4 with TaskResultData

use of org.ow2.proactive.scheduler.core.db.TaskResultData in project scheduling by ow2-proactive.

the class JobResultImpl method createTaskResultMap.

private Map<String, TaskResult> createTaskResultMap(Map<String, TaskResultData> inputDataMap) {
    Map<String, TaskResult> map = new HashMap<>();
    for (String taskName : inputDataMap.keySet()) {
        TaskResultData taskResultData = inputDataMap.get(taskName);
        map.put(taskName, toTaskResult(jobId, taskResultData));
    }
    return map;
}
Also used : HashMap(java.util.HashMap) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) DataUtility.toTaskResult(org.ow2.proactive.scheduler.rest.data.DataUtility.toTaskResult) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 5 with TaskResultData

use of org.ow2.proactive.scheduler.core.db.TaskResultData 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();
    }
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) TaskStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskStateData) TaskResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData) ArrayList(java.util.ArrayList) JobStateData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobStateData) SchedulerUserData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.SchedulerUserData) FileInputStream(java.io.FileInputStream) Date(java.util.Date) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SchedulerRestInterface(org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface) File(java.io.File)

Aggregations

TaskResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskResultData)12 ArrayList (java.util.ArrayList)4 JobResultData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData)4 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)3 SchedulerRestInterface (org.ow2.proactive_grid_cloud_portal.common.SchedulerRestInterface)3 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)3 File (java.io.File)2 List (java.util.List)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 GZIP (org.jboss.resteasy.annotations.GZIP)2 Test (org.junit.Test)2 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)2 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)2 DBTaskId (org.ow2.proactive.scheduler.core.db.TaskData.DBTaskId)2 JobResultImpl (org.ow2.proactive.scheduler.job.JobResultImpl)2 CLIException (org.ow2.proactive_grid_cloud_portal.cli.CLIException)2