Search in sources :

Example 6 with TaskLauncher

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

the class InternalForkedScriptTask method createLauncher.

/**
 * {@inheritDoc}
 */
@Override
public TaskLauncher createLauncher(Node node) throws ActiveObjectCreationException, NodeException {
    logger.info(getTaskInfo().getTaskId(), "creating forked task launcher");
    TaskLauncher launcher = (TaskLauncher) PAActiveObject.newActive(TaskLauncher.class.getName(), new Object[] { getDefaultTaskLauncherInitializer(), new ProActiveForkedTaskLauncherFactory() }, node);
    // wait until the task launcher is active
    launcher.isActivated();
    setExecuterInformation(new ExecuterInformation(launcher, node));
    return launcher;
}
Also used : TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) ProActiveForkedTaskLauncherFactory(org.ow2.proactive.scheduler.task.ProActiveForkedTaskLauncherFactory)

Example 7 with TaskLauncher

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

the class InternalScriptTask method createLauncher.

/**
 * {@inheritDoc}
 */
@Override
public TaskLauncher createLauncher(Node node) throws ActiveObjectCreationException, NodeException {
    logger.info(getTaskInfo().getTaskId(), "creating non forked task launcher");
    TaskLauncher launcher = (TaskLauncher) PAActiveObject.newActive(TaskLauncher.class.getName(), new Object[] { getDefaultTaskLauncherInitializer(), new ProActiveNonForkedTaskLauncherFactory() }, node);
    // wait until the task launcher is active
    launcher.isActivated();
    setExecuterInformation(new ExecuterInformation(launcher, node));
    return launcher;
}
Also used : TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) ProActiveNonForkedTaskLauncherFactory(org.ow2.proactive.scheduler.task.ProActiveNonForkedTaskLauncherFactory)

Example 8 with TaskLauncher

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

the class OnErrorPolicyInterpreterTest method createTask.

private InternalTask createTask() {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CANCEL_JOB, "description");
    InternalTask task = new InternalTask(job) {

        @Override
        public boolean handleResultsArguments() {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public TaskLauncher createLauncher(Node node) throws ActiveObjectCreationException, NodeException {
            // TODO Auto-generated method stub
            return null;
        }
    };
    return task;
}
Also used : InternalJob(org.ow2.proactive.scheduler.job.InternalJob) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) Node(org.objectweb.proactive.core.node.Node) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob)

Example 9 with TaskLauncher

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

the class LiveJobsTest method testFinishInErrorTask.

@Test(timeout = 60000)
public void testFinishInErrorTask() throws UnknownTaskException, UnknownJobException {
    InternalJob job = new InternalTaskFlowJob("test-name", JobPriority.NORMAL, OnTaskError.CONTINUE_JOB_EXECUTION, "description");
    JobId id = new JobIdImpl(666L, "test-name");
    job.setId(id);
    List<InternalTask> tasksList = new ArrayList<>();
    InternalTask internalTask = new InternalScriptTask(job);
    internalTask.setName("task-name");
    internalTask.setStatus(TaskStatus.IN_ERROR);
    Node node = Mockito.mock(Node.class);
    Mockito.when(node.getVMInformation()).thenAnswer(new Answer<VMInformation>() {

        @Override
        public VMInformation answer(InvocationOnMock invocation) throws Throwable {
            return Mockito.mock(VMInformation.class);
        }
    });
    Mockito.when(node.getNodeInformation()).thenAnswer(new Answer<NodeInformation>() {

        @Override
        public NodeInformation answer(InvocationOnMock invocation) throws Throwable {
            return Mockito.mock(NodeInformation.class);
        }
    });
    TaskLauncher taskLauncher = Mockito.mock(TaskLauncher.class);
    internalTask.setExecuterInformation(new ExecuterInformation(taskLauncher, node));
    tasksList.add(internalTask);
    job.setTasks(tasksList);
    liveJobs.jobSubmitted(job);
    liveJobs.finishInErrorTask(job.getId(), "task-name");
    assertThat(internalTask.getStatus(), is(TaskStatus.FINISHED));
}
Also used : ExecuterInformation(org.ow2.proactive.scheduler.task.internal.ExecuterInformation) InternalJob(org.ow2.proactive.scheduler.job.InternalJob) NodeInformation(org.objectweb.proactive.core.node.NodeInformation) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) VMInformation(org.objectweb.proactive.core.runtime.VMInformation) TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) Node(org.objectweb.proactive.core.node.Node) ArrayList(java.util.ArrayList) InternalScriptTask(org.ow2.proactive.scheduler.task.internal.InternalScriptTask) InvocationOnMock(org.mockito.invocation.InvocationOnMock) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) InternalTaskFlowJob(org.ow2.proactive.scheduler.job.InternalTaskFlowJob) JobId(org.ow2.proactive.scheduler.common.job.JobId) Test(org.junit.Test)

Example 10 with TaskLauncher

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

the class EnabledListenJobLogsSupport method listenJobLogs.

@Override
public synchronized void listenJobLogs(JobId jobId, AppenderProvider appenderProvider) throws UnknownJobException {
    jlogger.info(jobId, "listening logs");
    // create the appender to the remote listener
    Appender clientAppender = null;
    try {
        clientAppender = appenderProvider.getAppender();
    } catch (LogForwardingException e) {
        jlogger.error(jobId, "cannot create an appender", e);
        throw new InternalException("Cannot create an appender for job " + jobId, e);
    }
    boolean logIsAlreadyInitialized = jobsToBeLogged.contains(jobId);
    initJobLogging(jobId, clientAppender);
    JobResult result = dbManager.loadJobResult(jobId);
    if (result == null) {
        throw new UnknownJobException(jobId);
    }
    // for finished tasks, add logs events "manually"
    Collection<TaskResult> allRes = result.getAllResults().values();
    for (TaskResult tr : allRes) {
        this.flushTaskLogs(tr, clientAppender, jobId);
    }
    for (RunningTaskData taskData : liveJobs.getRunningTasks(jobId)) {
        jlogger.debug(jobId, "Handling log initialization for task " + taskData.getTask().getName());
        try {
            TaskLauncher taskLauncher = taskData.getLauncher();
            if (logIsAlreadyInitialized) {
                jlogger.debug(jobId, "Call getStoredLogs");
                taskLauncher.getStoredLogs(appenderProvider);
            } else {
                jlogger.debug(jobId, "Call activateLogs");
                taskLauncher.activateLogs(lfs.getAppenderProvider());
            }
        } catch (Exception e) {
            tlogger.error(taskData.getTask().getId(), "cannot create an appender provider", e);
        }
    }
    if (!result.getJobInfo().getStatus().isJobAlive()) {
        jlogger.info(jobId, "cleaning loggers for already finished job");
        cleanLoggers(jobId);
    }
}
Also used : Appender(org.apache.log4j.Appender) JobResult(org.ow2.proactive.scheduler.common.job.JobResult) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException) InternalException(org.ow2.proactive.scheduler.common.exception.InternalException)

Aggregations

TaskLauncher (org.ow2.proactive.scheduler.task.TaskLauncher)9 Test (org.junit.Test)7 ScriptExecutableContainer (org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer)6 SimpleScript (org.ow2.proactive.scripting.SimpleScript)6 TaskScript (org.ow2.proactive.scripting.TaskScript)6 Semaphore (java.util.concurrent.Semaphore)5 Repeat (org.ow2.proactive.utils.Repeat)5 InternalTask (org.ow2.proactive.scheduler.task.internal.InternalTask)4 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)3 ExecuterInformation (org.ow2.proactive.scheduler.task.internal.ExecuterInformation)3 Node (org.objectweb.proactive.core.node.Node)2 TaskResult (org.ow2.proactive.scheduler.common.task.TaskResult)2 InternalJob (org.ow2.proactive.scheduler.job.InternalJob)2 InternalTaskFlowJob (org.ow2.proactive.scheduler.job.InternalTaskFlowJob)2 NodeSet (org.ow2.proactive.utils.NodeSet)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Appender (org.apache.log4j.Appender)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1