Search in sources :

Example 56 with Task

use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.

the class ClusterService method resourceHasPendingTasks.

/**
 * Verify if the given resource has pending/running tasks associated.
 * @param id URI of resource to check for task
 *
 * @return true if resource has tasks running/pending else false.
 */
private boolean resourceHasPendingTasks(URI id) {
    boolean hasPendingTasks = false;
    List<Task> taskList = TaskUtils.findResourceTasks(_dbClient, id);
    for (Task task : taskList) {
        if (!task.getInactive() && task.isPending()) {
            hasPendingTasks = true;
            break;
        }
    }
    return hasPendingTasks;
}
Also used : Task(com.emc.storageos.db.client.model.Task) TaskMapper.toTask(com.emc.storageos.api.mapper.TaskMapper.toTask)

Example 57 with Task

use of com.emc.storageos.db.client.model.Task in project coprhd-controller by CoprHD.

the class ControllerWorkflowCleanupHandler method cleanupTasks.

private void cleanupTasks() {
    log.info("Start task cleanup");
    List<URI> taskIds = dbClient.queryByType(Task.class, true);
    Iterator<Task> tasks = dbClient.queryIterativeObjects(Task.class, taskIds);
    int cnt = 0;
    while (tasks.hasNext()) {
        Task task = tasks.next();
        if (task.isPending() || task.isQueued()) {
            DeviceControllerException ex = DeviceControllerException.exceptions.terminatedForControllerFailover();
            task.setServiceCode(ex.getServiceCode().getCode());
            task.setStatus(String.valueOf(Task.Status.error));
            task.setMessage(ex.getMessage());
            task.setProgress(100);
            task.setEndTime(Calendar.getInstance());
            log.info("Terminate task {}", task.getId());
            dbClient.updateObject(task);
            cnt++;
        }
    }
    log.info("Total {} tasks processed", cnt);
}
Also used : Task(com.emc.storageos.db.client.model.Task) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Aggregations

Task (com.emc.storageos.db.client.model.Task)57 URI (java.net.URI)21 Operation (com.emc.storageos.db.client.model.Operation)20 TaskMapper.toTask (com.emc.storageos.api.mapper.TaskMapper.toTask)17 DataObject (com.emc.storageos.db.client.model.DataObject)15 NamedURI (com.emc.storageos.db.client.model.NamedURI)13 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)10 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)8 MapTask (com.emc.storageos.api.mapper.functions.MapTask)7 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)7 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)7 Volume (com.emc.storageos.db.client.model.Volume)6 WorkflowStep (com.emc.storageos.db.client.model.WorkflowStep)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)5