Search in sources :

Example 26 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class InternalTask method getDefaultTaskLauncherInitializer.

/**
 * Prepare and return the default task launcher initializer (ie the one that works for every launcher)<br>
 * Concrete launcher may have to add values to the created initializer to bring more information to the launcher.
 *
 * @return the default created task launcher initializer
 */
protected TaskLauncherInitializer getDefaultTaskLauncherInitializer() {
    TaskLauncherInitializer tli = new TaskLauncherInitializer();
    tli.setTaskId(getId());
    tli.setJobOwner(internalJob.getJobInfo().getJobOwner());
    tli.setSchedulerRestUrl(PASchedulerProperties.SCHEDULER_REST_URL.getValueAsStringOrNull());
    tli.setCatalogRestUrl(PASchedulerProperties.CATALOG_REST_URL.getValueAsStringOrNull());
    tli.setPreScript(getPreScript());
    tli.setPostScript(getPostScript());
    tli.setControlFlowScript(getFlowScript());
    tli.setTaskInputFiles(getInputFilesList());
    tli.setTaskOutputFiles(getOutputFilesList());
    tli.setNamingService(internalJob.getTaskDataSpaceApplications().get(getId().longValue()).getNamingServiceStub());
    tli.setIterationIndex(getIterationIndex());
    tli.setReplicationIndex(getReplicationIndex());
    Map<String, String> gInfo = getRuntimeGenericInformation();
    tli.setGenericInformation(gInfo);
    ForkEnvironment environment = getForkEnvironment();
    if (environment != null) {
        Script environmentScript = environment.getEnvScript();
        if ((environmentScript != null) && !isScriptAuthorized(getId(), environmentScript)) {
            tli.setAuthorizedForkEnvironmentScript(false);
        }
    }
    tli.setForkEnvironment(getForkEnvironment());
    if (isWallTimeSet()) {
        tli.setWalltime(wallTime);
    }
    tli.setPreciousLogs(isPreciousLogs());
    tli.setJobVariables(internalJob.getVariables());
    tli.setTaskVariables(getVariables());
    tli.setPingPeriod(PASchedulerProperties.SCHEDULER_NODE_PING_FREQUENCY.getValueAsInt());
    tli.setPingAttempts(PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt());
    return tli;
}
Also used : Script(org.ow2.proactive.scripting.Script) ForkEnvironment(org.ow2.proactive.scheduler.common.task.ForkEnvironment) TaskLauncherInitializer(org.ow2.proactive.scheduler.task.TaskLauncherInitializer)

Example 27 with Task

use of org.ow2.proactive.scheduler.common.task.Task 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 28 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class SubmitJob method taskStateUpdatedEvent.

public void taskStateUpdatedEvent(NotificationData<TaskInfo> notif) {
    try {
        System.out.println("Task '" + notif.getData().getTaskId() + "' result received !!");
        TaskResult result = user.getTaskResult(notif.getData().getJobId(), notif.getData().getTaskId().getReadableName());
        terminated++;
        System.out.println("(" + terminated + ")Result value = " + result.value());
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult)

Example 29 with Task

use of org.ow2.proactive.scheduler.common.task.Task in project scheduling by ow2-proactive.

the class TestGetUsers method createJob.

private TaskFlowJob createJob() throws Exception {
    TaskFlowJob job = new TaskFlowJob();
    job.setName(this.getClass().getSimpleName());
    JavaTask task = new JavaTask();
    task.setExecutableClassName(EmptyExecutable.class.getName());
    job.addTask(task);
    return job;
}
Also used : EmptyExecutable(functionaltests.executables.EmptyExecutable) TaskFlowJob(org.ow2.proactive.scheduler.common.job.TaskFlowJob) JavaTask(org.ow2.proactive.scheduler.common.task.JavaTask)

Example 30 with Task

use of org.ow2.proactive.scheduler.common.task.Task 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)

Aggregations

Test (org.junit.Test)152 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)112 TaskFlowJob (org.ow2.proactive.scheduler.common.job.TaskFlowJob)100 JobId (org.ow2.proactive.scheduler.common.job.JobId)73 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)69 JavaTask (org.ow2.proactive.scheduler.common.task.JavaTask)68 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)60 ArrayList (java.util.ArrayList)49 TaskId (org.ow2.proactive.scheduler.common.task.TaskId)48 TaskResultImpl (org.ow2.proactive.scheduler.task.TaskResultImpl)43 Task (org.ow2.proactive.scheduler.common.task.Task)41 JobIdImpl (org.ow2.proactive.scheduler.job.JobIdImpl)41 File (java.io.File)37 Scheduler (org.ow2.proactive.scheduler.common.Scheduler)34 HashMap (java.util.HashMap)33 UnknownJobException (org.ow2.proactive.scheduler.common.exception.UnknownJobException)33 SimpleScript (org.ow2.proactive.scripting.SimpleScript)33 InternalScriptTask (org.ow2.proactive.scheduler.task.internal.InternalScriptTask)27 TaskScript (org.ow2.proactive.scripting.TaskScript)27 UnknownTaskException (org.ow2.proactive.scheduler.common.exception.UnknownTaskException)26