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);
}
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);
}
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);
}
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);
}
}
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();
}
}
Aggregations