Search in sources :

Example 26 with JobResult

use of org.ow2.proactive.scheduler.common.job.JobResult 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;
}
Also used : JobResultData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobResultData) DataUtility.toJobResult(org.ow2.proactive.scheduler.rest.data.DataUtility.toJobResult) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) IOException(java.io.IOException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) TimeoutException(java.util.concurrent.TimeoutException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException)

Example 27 with JobResult

use of org.ow2.proactive.scheduler.common.job.JobResult in project scheduling by ow2-proactive.

the class SchedulerClientTest method testKillTask.

@Test(timeout = MAX_WAIT_TIME)
public void testKillTask() throws Exception {
    ISchedulerClient client = clientInstance();
    Job job = createJob(NonTerminatingJob.class);
    SchedulerEventListenerImpl listener = new SchedulerEventListenerImpl();
    client.addEventListener(listener, true, SchedulerEvent.TASK_PENDING_TO_RUNNING);
    JobId jobId = submitJob(job, client);
    TaskInfo startedTask = listener.getStartedTask();
    while (!startedTask.getJobId().value().equals(jobId.value())) {
        startedTask = listener.getStartedTask();
    }
    client.killTask(jobId, getTaskNameForClass(NonTerminatingJob.class));
    client.removeEventListener();
    // should return immediately
    JobResult result = client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(3));
    TaskResult tresult = result.getResult(getTaskName(NonTerminatingJob.class));
    Assert.assertTrue(tresult.hadException());
    Assert.assertTrue(tresult.getException() instanceof TaskAbortedException);
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) TaskAbortedException(org.ow2.proactive.scheduler.common.exception.TaskAbortedException) JobId(org.ow2.proactive.scheduler.common.job.JobId) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) Test(org.junit.Test)

Example 28 with JobResult

use of org.ow2.proactive.scheduler.common.job.JobResult in project scheduling by ow2-proactive.

the class SchedulerClientTest method testSchedulerNodeClientCleanScript.

@Test(timeout = MAX_WAIT_TIME)
public void testSchedulerNodeClientCleanScript() throws Throwable {
    ISchedulerClient client = clientInstance();
    client.putThirdPartyCredential("TEST_CREDS", "mypassword_${PA_JOB_ID}");
    Job job = nodeClientJob("/functionaltests/descriptors/scheduler_client_node.groovy", "/functionaltests/descriptors/scheduler_client_node_fork.groovy");
    JobId jobId = submitJob(job, client);
    JobResult jres = client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(5));
    Assert.assertNotNull(jres);
    // wait 10 seconds because it is possible clean script executes after job
    Thread.sleep(10000);
    String jobLog = client.getJobServerLogs("" + jobId);
    // assert schedulerapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("SCHEDULERAPI_URI_LIST_NOT_NULL=true"));
    // assert userspaceapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("USERSPACE_FILE_LIST_NOT_NULL=true"));
    // assert globalspaceapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("GLOBALSPACE_FILE_LIST_NOT_NULL=true"));
    // assert globalspaceapi.connect() worked
    Assert.assertThat(jobLog, CoreMatchers.containsString("TEST_CREDS=mypassword_" + jobId.toString()));
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 29 with JobResult

use of org.ow2.proactive.scheduler.common.job.JobResult in project scheduling by ow2-proactive.

the class SchedulerClientTest method testJobResult.

@Test(timeout = MAX_WAIT_TIME)
public void testJobResult() throws Throwable {
    ISchedulerClient client = clientInstance();
    Job job = createJobManyTasks("JobResult", SimpleJob.class, ErrorTask.class, LogTask.class, VariableTask.class, MetadataTask.class, RawTask.class);
    JobId jobId = submitJob(job, client);
    JobResult result = client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(3));
    // job result
    Assert.assertNotNull(result.getJobId());
    Assert.assertNotNull(result.getJobInfo());
    Assert.assertEquals(JobStatus.FINISHED, result.getJobInfo().getStatus());
    // the following check cannot work because of the way the job id is created on the client side.
    // Assert.assertEquals(job.getName(), result.getName());
    Assert.assertTrue(result.hadException());
    Assert.assertEquals(1, result.getExceptionResults().size());
    // job info
    checkJobInfo(result.getJobInfo());
    checkJobInfo(client.getJobInfo(jobId.value()));
    JobState jobState = client.getJobState(jobId.value());
    JobStatus status = jobState.getStatus();
    Assert.assertFalse(status.isJobAlive());
    Assert.assertEquals(JobStatus.FINISHED, status);
    checkJobInfo(jobState.getJobInfo());
    TaskState errorTaskState = findTask(getTaskNameForClass(ErrorTask.class), jobState.getHMTasks());
    Assert.assertNotNull(errorTaskState);
    TaskState simpleTaskState = findTask(getTaskNameForClass(SimpleJob.class), jobState.getHMTasks());
    Assert.assertNotNull(simpleTaskState);
    Assert.assertEquals(TaskStatus.FAULTY, errorTaskState.getStatus());
    Assert.assertEquals(TaskStatus.FINISHED, simpleTaskState.getStatus());
    // task result simple
    TaskResult tResSimple = result.getResult(getTaskNameForClass(SimpleJob.class));
    Assert.assertNotNull(tResSimple.value());
    Assert.assertNotNull(tResSimple.getSerializedValue());
    Assert.assertEquals(new StringWrapper(TEST_JOB), tResSimple.value());
    Assert.assertEquals(new StringWrapper(TEST_JOB), ObjectByteConverter.byteArrayToObject(tResSimple.getSerializedValue()));
    // task result with error
    TaskResult tResError = result.getResult(getTaskNameForClass(ErrorTask.class));
    Assert.assertNotNull(tResError);
    Assert.assertTrue(tResError.hadException());
    Assert.assertNotNull(tResError.getException());
    Assert.assertTrue(tResError.getException() instanceof TaskException);
    // task result with logs
    TaskResult tResLog = result.getResult(getTaskNameForClass(LogTask.class));
    Assert.assertNotNull(tResLog);
    Assert.assertNotNull(tResLog.getOutput());
    System.err.println(tResLog.getOutput().getStdoutLogs(false));
    Assert.assertTrue(tResLog.getOutput().getStdoutLogs(false).contains(LogTask.HELLO_WORLD));
    // task result with variables
    TaskResult tResVar = result.getResult(getTaskNameForClass(VariableTask.class));
    Assert.assertNotNull(tResVar.getPropagatedVariables());
    Map<String, Serializable> vars = tResVar.getVariables();
    System.out.println(vars);
    Assert.assertTrue(tResVar.getPropagatedVariables().containsKey(VariableTask.MYVAR));
    Assert.assertEquals("myvalue", vars.get(VariableTask.MYVAR));
    // task result with metadata
    TaskResult tMetaVar = result.getResult(getTaskNameForClass(MetadataTask.class));
    Assert.assertNotNull(tMetaVar.getMetadata());
    Assert.assertTrue(tMetaVar.getMetadata().containsKey(MetadataTask.MYVAR));
    // task result with raw result
    TaskResult tResRaw = result.getResult(getTaskNameForClass(RawTask.class));
    Assert.assertNotNull(tResRaw.value());
    Assert.assertNotNull(tResRaw.getSerializedValue());
    Assert.assertArrayEquals(TEST_JOB.getBytes(), (byte[]) tResRaw.value());
    Assert.assertArrayEquals(TEST_JOB.getBytes(), tResRaw.getSerializedValue());
}
Also used : StringWrapper(org.objectweb.proactive.core.util.wrapper.StringWrapper) Serializable(java.io.Serializable) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) JobStatus(org.ow2.proactive.scheduler.common.job.JobStatus) VariableTask(functionaltests.jobs.VariableTask) TaskException(org.ow2.proactive.scheduler.task.exceptions.TaskException) RawTask(functionaltests.jobs.RawTask) MetadataTask(functionaltests.jobs.MetadataTask) ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) JobState(org.ow2.proactive.scheduler.common.job.JobState) SimpleJob(functionaltests.jobs.SimpleJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) ErrorTask(functionaltests.jobs.ErrorTask) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) TaskState(org.ow2.proactive.scheduler.common.task.TaskState) JobId(org.ow2.proactive.scheduler.common.job.JobId) LogTask(functionaltests.jobs.LogTask) Test(org.junit.Test)

Example 30 with JobResult

use of org.ow2.proactive.scheduler.common.job.JobResult in project scheduling by ow2-proactive.

the class GetResultMetricTest method test.

@Test(timeout = 3600000)
public void test() throws Exception {
    // in milliseconds
    final int taskDuration = 1000;
    final int nodeNumber = 1;
    ProActiveConfiguration.load();
    RMFactory.setOsJavaProperty();
    schedulerHelper = new SchedulerTHelper(false, SCHEDULER_CONFIGURATION_START.getPath(), RM_CONFIGURATION_START.getPath(), null);
    schedulerHelper.createNodeSourceWithInfiniteTimeout("local", nodeNumber);
    final TaskFlowJob job = SchedulerEfficiencyMetricsTest.createJob(taskNumber, taskDuration);
    final long start = System.currentTimeMillis();
    jobId = schedulerHelper.submitJob(job);
    schedulerHelper.waitForEventJobFinished(jobId);
    final JobResult jobResult = schedulerHelper.getSchedulerInterface().getJobResult(jobId);
    long wholeTime = System.currentTimeMillis() - start;
    long timeToGetResult = wholeTime - taskDuration;
    LOGGER.info(makeCSVString(GetResultMetricTest.class.getSimpleName(), taskNumber, timeLimit, timeToGetResult, ((timeToGetResult < timeLimit) ? SUCCESS : FAILURE)));
}
Also used : SchedulerTHelper(functionaltests.utils.SchedulerTHelper) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) Test(org.junit.Test)

Aggregations

JobResult (org.ow2.proactive.scheduler.common.job.JobResult)39 JobId (org.ow2.proactive.scheduler.common.job.JobId)26 Test (org.junit.Test)25 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)24 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)22 File (java.io.File)16 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)9 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)7 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)6 NativeTask (org.ow2.proactive.scheduler.common.task.NativeTask)6 JobResultImpl (org.ow2.proactive.scheduler.job.JobResultImpl)6 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)6 Job (org.ow2.proactive.scheduler.common.job.Job)4 JobInfo (org.ow2.proactive.scheduler.common.job.JobInfo)4 ForkEnvironment (org.ow2.proactive.scheduler.common.task.ForkEnvironment)4 TaskState (org.ow2.proactive.scheduler.common.task.TaskState)4 NonTerminatingJob (functionaltests.jobs.NonTerminatingJob)3 SimpleJob (functionaltests.jobs.SimpleJob)3 HashMap (java.util.HashMap)3 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3