Search in sources :

Example 56 with Job

use of org.ow2.proactive.scheduler.common.job.Job 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 57 with Job

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

the class SchedulerClient method submit.

@Override
public JobId submit(URL job, Map<String, String> variables, Map<String, String> requestHeaderParams) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException {
    JobIdData jobIdData = null;
    try {
        URLConnection urlConnection = job.openConnection();
        for (Map.Entry<String, String> requestHeaderEntry : requestHeaderParams.entrySet()) {
            urlConnection.addRequestProperty(requestHeaderEntry.getKey(), requestHeaderEntry.getValue());
        }
        InputStream is = urlConnection.getInputStream();
        jobIdData = restApiClient().submitXml(sid, is, variables);
    } catch (Exception e) {
        throwNCEOrPEOrSCEOrJCE(e);
    }
    return jobId(jobIdData);
}
Also used : JobIdData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.JobIdData) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Map(java.util.Map) AbstractMap(java.util.AbstractMap) URLConnection(java.net.URLConnection) 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 58 with Job

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

the class SchedulerClientTest method testJobSubmissionEventListener.

@Test(timeout = MAX_WAIT_TIME * 2)
public void testJobSubmissionEventListener() throws Exception {
    ISchedulerClient client = clientInstance();
    SchedulerEventListenerImpl listener = new SchedulerEventListenerImpl();
    client.addEventListener(listener, true, SchedulerEvent.JOB_SUBMITTED, SchedulerEvent.USERS_UPDATE);
    Job job = defaultJob();
    JobId jobId = client.submit(job);
    JobState submittedJob = listener.getSubmittedJob();
    while (!submittedJob.getId().value().equals(jobId.value())) {
        submittedJob = listener.getSubmittedJob();
    }
    UserIdentification userIdentification = listener.getLastUserUpdate();
    assertTrue(userIdentification.getLastSubmitTime() != -1);
    client.removeEventListener();
    client.waitForJob(jobId, TimeUnit.SECONDS.toMillis(120));
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) JobState(org.ow2.proactive.scheduler.common.job.JobState) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) SimpleJob(functionaltests.jobs.SimpleJob) Job(org.ow2.proactive.scheduler.common.job.Job) NonTerminatingJob(functionaltests.jobs.NonTerminatingJob) UserIdentification(org.ow2.proactive.scheduler.common.job.UserIdentification) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 59 with Job

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

the class SchedulerClientTest method testWaitForTerminatingJob.

@Test(timeout = MAX_WAIT_TIME)
public void testWaitForTerminatingJob() throws Exception {
    ISchedulerClient client = clientInstance();
    Job job = defaultJob();
    JobId jobId = submitJob(job, client);
    // should return immediately
    client.waitForJob(jobId, TimeUnit.MINUTES.toMillis(3));
}
Also used : 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 60 with Job

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

the class SchedulerClientTest method testDataSpaceNodeClientPushDelete.

@Test(timeout = MAX_WAIT_TIME)
public void testDataSpaceNodeClientPushDelete() throws Throwable {
    ISchedulerClient client = clientInstance();
    Job job = nodeClientJob("/functionaltests/descriptors/dataspace_client_node_push_delete.groovy", "/functionaltests/descriptors/dataspace_client_node_fork.groovy");
    JobId jobId = submitJob(job, client);
    TaskResult tres = client.waitForTask(jobId.toString(), "NodeClientTask", TimeUnit.MINUTES.toMillis(5));
    System.out.println(tres.getOutput().getAllLogs(false));
    Assert.assertNotNull(tres);
    Assert.assertEquals("OK", tres.value());
}
Also used : 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) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)260 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)198 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)145 JobId (org.ow2.proactive.scheduler.common.job.JobId)122 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)91 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)87 File (java.io.File)76 SimpleScript (org.ow2.proactive.scripting.SimpleScript)70 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)68 TaskScript (org.ow2.proactive.scripting.TaskScript)65 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)64 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)58 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)52 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)48 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 ArrayList (java.util.ArrayList)46 JobState (org.ow2.proactive.scheduler.common.job.JobState)45 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)41 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)39