Search in sources :

Example 11 with TaskLauncher

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

the class KillTaskLauncherTest method finished_but_terminate_not_called_back.

@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void finished_but_terminate_not_called_back() throws Throwable {
    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("result='done'", "javascript")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory(new Semaphore(0)));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);
    TaskResultWaiter taskResultWaiter = new TaskResultWaiter();
    WaitForResultNotification waitForResultNotification = new WaitForResultNotification(taskResultWaiter);
    waitForResultNotification = PAActiveObject.turnActive(waitForResultNotification);
    taskLauncherPA.doTask(executableContainer, null, waitForResultNotification);
    assertEquals("done", taskResultWaiter.getTaskResult().value());
    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test) Repeat(org.ow2.proactive.utils.Repeat)

Example 12 with TaskLauncher

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

the class KillTaskLauncherTest method kill_while_sleeping_in_task.

@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void kill_while_sleeping_in_task() throws Exception {
    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("java.lang.Thread.sleep(10000)", "javascript")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    Semaphore taskRunning = new Semaphore(0);
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer, new TestTaskLauncherFactory(taskRunning));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);
    taskLauncherPA.doTask(executableContainer, null, null);
    taskRunning.acquire();
    taskLauncherPA.kill();
    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test) Repeat(org.ow2.proactive.utils.Repeat)

Example 13 with TaskLauncher

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

the class KillTaskLauncherTest method kill_when_copying.

@Test
@Repeat(value = repetitions, parallel = parallel, timeout = timeout)
public void kill_when_copying() throws Throwable {
    final ScriptExecutableContainer executableContainer = new ScriptExecutableContainer(new TaskScript(new SimpleScript("result='done'", "javascript")));
    TaskLauncherInitializer initializer = new TaskLauncherInitializer();
    initializer.setTaskId(TaskIdImpl.createTaskId(JobIdImpl.makeJobId("1000"), "job", 1000L));
    Semaphore taskRunning = new Semaphore(0);
    final TaskLauncher taskLauncher = createLauncherWithInjectedMocks(initializer, new SlowDataspacesTaskLauncherFactory(taskRunning));
    final TaskLauncher taskLauncherPA = PAActiveObject.turnActive(taskLauncher);
    taskLauncherPA.doTask(executableContainer, null, null);
    taskRunning.acquire();
    taskLauncherPA.kill();
    assertTaskLauncherIsTerminated(taskLauncherPA);
    PAActiveObject.terminateActiveObject(taskLauncherPA, true);
}
Also used : TaskScript(org.ow2.proactive.scripting.TaskScript) SimpleScript(org.ow2.proactive.scripting.SimpleScript) ScriptExecutableContainer(org.ow2.proactive.scheduler.task.containers.ScriptExecutableContainer) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test) Repeat(org.ow2.proactive.utils.Repeat)

Example 14 with TaskLauncher

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

the class SchedulingService method getProgressAndPingTaskNode.

void getProgressAndPingTaskNode(RunningTaskData taskData) {
    if (!jobs.canPingTask(taskData) || taskData.getPingAttempts() > PASchedulerProperties.SCHEDULER_NODE_PING_ATTEMPTS.getValueAsInt()) {
        return;
    }
    InternalTask task = taskData.getTask();
    try {
        // (2)
        int progress = taskData.getLauncher().getProgress();
        // get previous inside td
        if (progress != task.getProgress()) {
            // (1)
            task.setProgress(progress);
            // if progress != previously set progress (0 by default) -> update
            listener.taskStateUpdated(taskData.getUser(), new NotificationData<TaskInfo>(SchedulerEvent.TASK_PROGRESS, new TaskInfoImpl((TaskInfoImpl) task.getTaskInfo())));
        }
    } catch (Throwable t) {
        tlogger.debug(task.getId(), "TaskLauncher is not accessible, checking if the node can be reached.", t);
        pingTaskNodeAndInitiateRestart(task);
    }
}
Also used : TaskInfo(org.ow2.proactive.scheduler.common.task.TaskInfo) InternalTask(org.ow2.proactive.scheduler.task.internal.InternalTask) TaskInfoImpl(org.ow2.proactive.scheduler.task.TaskInfoImpl)

Example 15 with TaskLauncher

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

the class ExecuterInformationData method getReboundTaskLauncherIfStillExist.

private TaskLauncher getReboundTaskLauncherIfStillExist() {
    try {
        logger.debug("List AOs on " + taskLauncherNodeUrl + " (expect only one): " + Arrays.toString(NodeFactory.getNode(taskLauncherNodeUrl).getActiveObjects()));
        Object[] aos = NodeFactory.getNode(taskLauncherNodeUrl).getActiveObjects();
        return (TaskLauncher) aos[0];
    } catch (Throwable t) {
        logger.warn("Failed to rebind TaskLauncher of task " + taskId + ". TaskLauncher with node URL: " + taskLauncherNodeUrl + " could not be looked up. Running task cannot be recovered, it will be restarted if possible.");
        return new TaskLauncher();
    }
}
Also used : TaskLauncher(org.ow2.proactive.scheduler.task.TaskLauncher) PAActiveObject(org.objectweb.proactive.api.PAActiveObject)

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