use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusManagerImpl method getTaskStatus.
@Override
public TaskStatus getTaskStatus(Task task) {
TaskStatus taskStatus;
synchronized (taskToStatusMap) {
if (taskToStatusMap.containsKey(task.getId())) {
taskStatus = taskToStatusMap.get(task.getId());
} else {
taskStatus = new TaskStatusImpl(task);
taskToStatusMap.put(task.getId(), taskStatus);
}
}
// TODO: persist created taskStatus in storage
return taskStatus;
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusManagerImpl method onTaskDestinationDone.
@Override
public void onTaskDestinationDone(Task task, Destination destination, TaskResult result) {
if (result != null) {
try {
jmsQueueManager.reportFinishedDestination(task, destination, result);
} catch (JMSException e) {
log.error("Failed to report finished task " + task.toString() + ": " + e.getMessage());
}
}
if (task.getExecService().getExecServiceType().equals(ExecServiceType.GENERATE)) {
task.setEndTime(new Date(System.currentTimeMillis()));
schedulingPool.setTaskStatus(task, cz.metacentrum.perun.taskslib.model.Task.TaskStatus.DONE);
} else {
TaskStatus taskStatus = this.getTaskStatus(task);
try {
taskStatus.setDestinationStatus(destination, TaskDestinationStatus.DONE);
taskStatus.setDestinationResult(destination, result);
} catch (InternalErrorException e) {
log.error("Error setting DONE status for task " + task.toString() + ": " + e.getMessage());
}
if (taskStatus.isTaskFinished()) {
task.setEndTime(new Date(System.currentTimeMillis()));
schedulingPool.setTaskStatus(task, taskStatus.getTaskStatus());
}
}
// report success on forced propagations immediately...
if (task.isPropagationForced() && task.getStatus().equals(cz.metacentrum.perun.taskslib.model.Task.TaskStatus.DONE)) {
log.debug("TASK " + task.toString() + " finished");
try {
log.debug("TASK reported as finished at " + System.currentTimeMillis());
jmsQueueManager.reportFinishedTask(task, "Destinations []");
schedulingPool.removeTask(task);
log.debug("TASK {} removed from database.", task.getId());
} catch (JMSException e) {
log.error("Failed to report finished task " + task.toString() + ": " + e.getMessage());
}
}
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusImplTest method getTaskStatusTest.
@Test
public void getTaskStatusTest() throws InternalErrorException {
System.out.println("TaskStatusImpl.getTaskStatusTest");
TaskStatus taskStatus = new TaskStatusImpl(task1);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.PROCESSING));
taskStatus.setDestinationStatus(destination1, TaskDestinationStatus.DONE);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.PROCESSING));
taskStatus.setDestinationStatus(destination3, TaskDestinationStatus.ERROR);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.PROCESSING));
taskStatus.setDestinationStatus(destination4, TaskDestinationStatus.DONE);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.PROCESSING));
taskStatus.setDestinationStatus(destination2, TaskDestinationStatus.DONE);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.DONE));
taskStatus = new TaskStatusImpl(task1);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.PROCESSING));
taskStatus.setDestinationStatus(destination1, TaskDestinationStatus.DONE);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.PROCESSING));
taskStatus.setDestinationStatus(destination3, TaskDestinationStatus.DONE);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.PROCESSING));
taskStatus.setDestinationStatus(destination2, TaskDestinationStatus.ERROR);
Assert.isTrue(taskStatus.getTaskStatus().equals(Task.TaskStatus.ERROR));
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusImplTest method setDestinationStatusTest.
@Test
public void setDestinationStatusTest() throws InternalErrorException {
System.out.println("TaskStatusImpl.setDestinationStatusTest");
TaskStatus taskStatus = new TaskStatusImpl(task1);
taskStatus.setDestinationStatus(destination1, TaskDestinationStatus.DONE);
Assert.isTrue(taskStatus.getDestinationStatus(destination1).equals(TaskDestinationStatus.DONE));
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusManagerImplTest method getTaskStatusTest.
@Test
public void getTaskStatusTest() {
System.out.println("TaskStatusManagerImpl.getTaskStatusTest");
TaskStatus taskStatus1 = taskStatusManager.getTaskStatus(task1);
TaskStatus taskStatus2 = taskStatusManager.getTaskStatus(task1);
Assert.isTrue(taskStatus1 == taskStatus2);
}
Aggregations