Search in sources :

Example 1 with TaskStatus

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());
        }
    }
}
Also used : JMSException(javax.jms.JMSException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) TaskStatus(cz.metacentrum.perun.engine.scheduling.TaskStatus) Date(java.util.Date)

Example 2 with TaskStatus

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));
}
Also used : TaskStatusImpl(cz.metacentrum.perun.engine.scheduling.impl.TaskStatusImpl) TaskStatus(cz.metacentrum.perun.engine.scheduling.TaskStatus) Test(org.junit.Test) AbstractEngineTest(cz.metacentrum.perun.engine.AbstractEngineTest)

Example 3 with TaskStatus

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");
}
Also used : Destination(cz.metacentrum.perun.core.api.Destination) TaskStatusImpl(cz.metacentrum.perun.engine.scheduling.impl.TaskStatusImpl) TaskStatus(cz.metacentrum.perun.engine.scheduling.TaskStatus) Test(org.junit.Test) AbstractEngineTest(cz.metacentrum.perun.engine.AbstractEngineTest)

Example 4 with TaskStatus

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());
}
Also used : TaskStatusImpl(cz.metacentrum.perun.engine.scheduling.impl.TaskStatusImpl) TaskStatus(cz.metacentrum.perun.engine.scheduling.TaskStatus) Test(org.junit.Test) AbstractEngineTest(cz.metacentrum.perun.engine.AbstractEngineTest)

Example 5 with TaskStatus

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);
}
Also used : TaskStatus(cz.metacentrum.perun.engine.scheduling.TaskStatus) Test(org.junit.Test) AbstractEngineTest(cz.metacentrum.perun.engine.AbstractEngineTest)

Aggregations

TaskStatus (cz.metacentrum.perun.engine.scheduling.TaskStatus)10 AbstractEngineTest (cz.metacentrum.perun.engine.AbstractEngineTest)7 Test (org.junit.Test)7 TaskStatusImpl (cz.metacentrum.perun.engine.scheduling.impl.TaskStatusImpl)5 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)2 Date (java.util.Date)2 JMSException (javax.jms.JMSException)2 Destination (cz.metacentrum.perun.core.api.Destination)1