use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusManagerImpl method onTaskDestinationError.
@Override
public void onTaskDestinationError(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.ERROR);
} else {
TaskStatus taskStatus = this.getTaskStatus(task);
try {
taskStatus.setDestinationStatus(destination, TaskDestinationStatus.ERROR);
taskStatus.setDestinationResult(destination, result);
} catch (InternalErrorException e) {
log.error("Error setting ERROR status for task " + task.toString() + ": " + e.getMessage());
}
if (taskStatus.isTaskFinished()) {
task.setEndTime(new Date(System.currentTimeMillis()));
schedulingPool.setTaskStatus(task, taskStatus.getTaskStatus());
}
}
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusImplTest method getDestinationStatusTest.
@Test
public void getDestinationStatusTest() throws InternalErrorException {
System.out.println("TaskStatusImpl.getDestinationStatusTest");
TaskStatus taskStatus = new TaskStatusImpl(task1);
Assert.isTrue(taskStatus.getDestinationStatus(destination1).equals(TaskDestinationStatus.WAITING));
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusImplTest method getWaitingDestinationsTest.
@Test
public void getWaitingDestinationsTest() throws InternalErrorException {
System.out.println("TaskStatusImpl.getWaitingDestinationsTest");
TaskStatus taskStatus = new TaskStatusImpl(task1);
List<Destination> destinations = taskStatus.getWaitingDestinations();
log.debug("destinations: " + destinations.toString());
Assert.isTrue(destinations.size() == 3, "size == 3");
Assert.isTrue(destinations.contains(destination1), "destination1");
Assert.isTrue(destinations.contains(destination2), "destination2");
Assert.isTrue(destinations.contains(destination3) || destinations.contains(destination4), "destination3 or destination4");
destinations = taskStatus.getWaitingDestinations();
Assert.isTrue(destinations.size() == 1, "size == 1");
taskStatus.setDestinationStatus(destination3, TaskDestinationStatus.DONE);
destinations = taskStatus.getWaitingDestinations();
Assert.isTrue(destinations.size() == 0, "size == 0");
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusImplTest method isTaskFinishedTest.
@Test
public void isTaskFinishedTest() throws InternalErrorException {
System.out.println("TaskStatusImpl.isTaskFinishedTest");
TaskStatus taskStatus = new TaskStatusImpl(task1);
Assert.isTrue(!taskStatus.isTaskFinished());
taskStatus.setDestinationStatus(destination1, TaskDestinationStatus.DONE);
Assert.isTrue(!taskStatus.isTaskFinished());
taskStatus.setDestinationStatus(destination3, TaskDestinationStatus.DONE);
Assert.isTrue(!taskStatus.isTaskFinished());
taskStatus.setDestinationStatus(destination2, TaskDestinationStatus.ERROR);
Assert.isTrue(taskStatus.isTaskFinished());
taskStatus.setDestinationStatus(destination4, TaskDestinationStatus.ERROR);
Assert.isTrue(taskStatus.isTaskFinished());
}
use of cz.metacentrum.perun.engine.scheduling.TaskStatus in project perun by CESNET.
the class TaskStatusManagerImplTest method clearTaskStatusTest.
@Test
public void clearTaskStatusTest() {
System.out.println("TaskStatusManagerImpl.getTaskStatusTest");
TaskStatus taskStatus1 = taskStatusManager.getTaskStatus(task1);
taskStatusManager.clearTaskStatus(task1);
TaskStatus taskStatus2 = taskStatusManager.getTaskStatus(task1);
Assert.isTrue(taskStatus1 != taskStatus2);
}
Aggregations