use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class SchedulingPoolImpl method closeTasksForEngine.
@Override
public void closeTasksForEngine() {
List<Task> tasks = taskStore.getTasksWithStatus(TaskStatus.PLANNED, TaskStatus.GENERATING, TaskStatus.GENERATED, TaskStatus.SENDING);
// switch all processing tasks to error, remove the engine queue association
log.debug("Switching processing tasks on engine to ERROR, the engine went down...");
for (Task task : tasks) {
log.info("[{}] Switching Task to ERROR, the engine it was running on went down.", task.getId());
task.setStatus(TaskStatus.ERROR);
}
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class SchedulingPoolImpl method reloadTasks.
@Override
public void reloadTasks() {
log.debug("Going to reload Tasks from database...");
this.clear();
EngineMessageProducer queue = engineMessageProducerFactory.getProducer();
for (Task task : tasksManagerBl.listAllTasks(sess)) {
try {
// just add DB Task to in-memory structure
addToPool(task);
} catch (TaskStoreException e) {
log.error("Adding Task {} and Queue {} into SchedulingPool failed, so the Task will be lost.", task, queue);
}
// done/error tasks will be rescheduled later by periodic jobs of PropagationMaintainer !!
if (Arrays.asList(TaskStatus.WAITING, TaskStatus.PLANNED, TaskStatus.GENERATING, TaskStatus.SENDING).contains(task.getStatus())) {
if (task.getStatus().equals(TaskStatus.WAITING)) {
// reset timestamp to 'now' for WAITING Tasks, since scheduling task
// sets this to all tasks except the waiting
task.setSchedule(LocalDateTime.now());
tasksManagerBl.updateTask(sess, task);
}
scheduleTask(task, 0);
}
}
log.debug("Reload of Tasks from database finished.");
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class TaskSchedulerTest method sourceUpdatedRunTest.
@Test
public void sourceUpdatedRunTest() {
simpleSpy.setTask(simpleFutureTask);
simpleSpy.setSchedulingPool(schedulingPool);
Long timeLimit = 100L;
Task[] tasks = simpleSetup(timeLimit, schedulingPool);
Task testTask1 = tasks[0], testTask2 = tasks[1];
testTask2.setSourceUpdated(true);
schedulingPool.scheduleTask(testTask2, 4);
schedulingPool.scheduleTask(testTask1, 4);
simpleFutureTask.run();
assertFalse(simpleSpy.testFailed);
try {
// FIXME - make every second test not to fail on interrupted exception
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class TaskSchedulerTest method sourceUpdatedRecurrenceRunTest.
@Test
public void sourceUpdatedRecurrenceRunTest() {
recurrenceSpy.setTask(recurrenceFutureTask);
recurrenceSpy.setSchedulingPool(schedulingPool);
Long timeLimit = 100L;
Task[] tasks = simpleSetup(timeLimit, schedulingPool);
Task testTask1 = tasks[0];
schedulingPool.scheduleTask(testTask1, 2);
recurrenceFutureTask.run();
assertFalse(recurrenceSpy.testFailed);
try {
// FIXME - make every second test not to fail on interrupted exception
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class TaskSchedulerTest method simpleRunTest.
@Test
public void simpleRunTest() throws InterruptedException {
simpleSpy.setTask(simpleFutureTask);
simpleSpy.setSchedulingPool(schedulingPool);
Long timeLimit = 100L;
Task[] tasks = simpleSetup(timeLimit, schedulingPool);
Task testTask1 = tasks[0], testTask2 = tasks[1];
schedulingPool.scheduleTask(testTask1, 4);
schedulingPool.scheduleTask(testTask1, 4);
Thread.sleep(timeLimit / 100);
schedulingPool.scheduleTask(testTask1, 4);
Thread.sleep((timeLimit / 100) * 8);
schedulingPool.scheduleTask(testTask2, 4);
simpleFutureTask.run();
assertFalse(simpleSpy.testFailed);
try {
// FIXME - make every second test not to fail on interrupted exception
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Aggregations