Search in sources :

Example 11 with JobId

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

the class ServerJobAndTaskLogs method getJobLog.

public static String getJobLog(JobId jobId, Set<TaskId> tasks) {
    String jobLog = readLog(JobLogger.getJobLogRelativePath(jobId));
    if (jobLog == null) {
        return "Cannot retrieve logs for job " + jobId;
    }
    StringBuilder result = new StringBuilder();
    result.append("================= Job ").append(jobId).append(" logs =================\n");
    result.append(jobLog);
    for (TaskId taskId : tasks) {
        result.append("\n================ Task ").append(taskId).append(" logs =================\n");
        result.append(getTaskLog(taskId));
    }
    return result.toString();
}
Also used : TaskId(org.ow2.proactive.scheduler.common.task.TaskId)

Example 12 with JobId

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

the class TestJobInstantGetTaskResult method testJobInstantGetTaskResult.

@Test
public void testJobInstantGetTaskResult() throws Throwable {
    // create Scheduler client as an active object
    SubmitJob client = (SubmitJob) PAActiveObject.newActive(SubmitJob.class.getName(), new Object[] {});
    // begin to use the client : must be a futur result in order to start the scheduler at next step
    client.begin();
    // create job
    TaskFlowJob job = new TaskFlowJob();
    for (int i = 0; i < 50; i++) {
        JavaTask t = new JavaTask();
        t.setExecutableClassName(ResultAsArray.class.getName());
        t.setName("task" + i);
        job.addTask(t);
    }
    JobId id = schedulerHelper.submitJob(job);
    client.setJobId(id);
    schedulerHelper.waitForEventJobRemoved(id);
    PAActiveObject.terminateActiveObject(client, true);
}
Also used : ResultAsArray(functionaltests.executables.ResultAsArray) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 13 with JobId

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

the class TestLoadJobs method checkJobs.

private void checkJobs(List<JobInfo> jobs, JobId... expectedIds) {
    Set<JobId> jobIds = new HashSet<>(jobs.size());
    for (JobInfo job : jobs) {
        jobIds.add(job.getJobId());
        logger.info("Job " + job.getJobId() + " has status '" + job.getStatus() + "'");
    }
    for (JobId expectedId : expectedIds) {
        final boolean expectedJobIdContained = jobIds.contains(expectedId);
        logger.info("Checking if " + jobs + " contains " + expectedId + "? " + expectedJobIdContained);
        assertTrue(expectedJobIdContained);
    }
}
Also used : JobInfo(org.ow2.proactive.scheduler.common.job.JobInfo) JobId(org.ow2.proactive.scheduler.common.job.JobId) HashSet(java.util.HashSet)

Example 14 with JobId

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

the class TaskUsingCredentialsTest method jobs_using_third_party_credentials.

private void jobs_using_third_party_credentials() throws Exception {
    Scheduler scheduler = schedulerHelper.getSchedulerInterface();
    scheduler.putThirdPartyCredential("MY_APP_PASSWORD", "superpassword");
    TaskFlowJob job = (TaskFlowJob) StaxJobFactory.getFactory().createJob(new File(jobDescriptor.toURI()).getAbsolutePath());
    if (OperatingSystem.getOperatingSystem() == org.objectweb.proactive.utils.OperatingSystem.unix) {
        NativeTask nativeTask = new NativeTask();
        nativeTask.setCommandLine("echo", "$credentials_MY_APP_PASSWORD");
        job.addTask(nativeTask);
    }
    JobId jobId = scheduler.submit(job);
    schedulerHelper.waitForEventJobFinished(jobId);
    JobResult jobResult = schedulerHelper.getJobResult(jobId);
    for (TaskResult taskResult : jobResult.getAllResults().values()) {
        assertTrue("task " + taskResult.getTaskId().getReadableName() + " did not print the credential", taskResult.getOutput().getAllLogs(false).contains("superpassword"));
    }
}
Also used : JobResult(org.ow2.proactive.scheduler.common.job.JobResult) Scheduler(org.ow2.proactive.scheduler.common.Scheduler) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) NativeTask(org.ow2.proactive.scheduler.common.task.NativeTask) File(java.io.File) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Example 15 with JobId

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

the class TestThirdPartyCredentialsDefined method createAndSubmitTaskPrintingCredentials.

public String createAndSubmitTaskPrintingCredentials() throws Exception {
    ScriptTask scriptTask = new ScriptTask();
    scriptTask.setName("task");
    scriptTask.setScript(new TaskScript(new SimpleScript("print credentials", "python")));
    TaskFlowJob job = new TaskFlowJob();
    job.addTask(scriptTask);
    JobId id = schedulerHelper.submitJob(job);
    schedulerHelper.waitForEventJobFinished(id);
    JobResult jobResult = schedulerHelper.getJobResult(id);
    TaskResult result = jobResult.getResult(scriptTask.getName());
    return result.getOutput().getStdoutLogs(false).replaceAll("\n|\r", "");
}
Also used : ScriptTask(org.ow2.proactive.scheduler.common.task.ScriptTask) TaskScript(org.ow2.proactive.scripting.TaskScript) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) SimpleScript(org.ow2.proactive.scripting.SimpleScript) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) JobId(org.ow2.proactive.scheduler.common.job.JobId)

Aggregations

JobId (org.ow2.proactive.scheduler.common.job.JobId)179 Test (org.junit.Test)121 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)73 File (java.io.File)58 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)57 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)55 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)55 JobState (org.ow2.proactive.scheduler.common.job.JobState)51 ArrayList (java.util.ArrayList)45 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)43 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)42 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)40 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)38 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)37 JobResult (org.ow2.proactive.scheduler.common.job.JobResult)36 Path (javax.ws.rs.Path)35 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)35 PermissionRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException)34 Produces (javax.ws.rs.Produces)33 UnknownJobRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException)33