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;
}
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);
}
Aggregations