Search in sources :

Example 76 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class TaskMapper method toTask.

public static TaskResourceRep toTask(DataObject resource, List<? extends DataObject> assocResources, String taskId, Operation operation) {
    TaskResourceRep task = toTask(resource, taskId, operation);
    List<NamedRelatedResourceRep> associatedReps = new ArrayList<NamedRelatedResourceRep>();
    for (DataObject assoc : assocResources) {
        associatedReps.add(toNamedRelatedResource(assoc));
    }
    task.setAssociatedResources(associatedReps);
    return task;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 77 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class Tasks method waitFor.

/**
 * Waits for tasks to complete (go into a pending or error state). If an error occurs
 * it will be thrown as an exception.
 *
 * @param timeoutMillis Timeout after a number of milliseconds
 * @throws com.emc.vipr.client.exceptions.TimeoutException Thrown if a timeout occurs.
 * @throws ViPRException Thrown if any task is in an error state.
 * @return This tasks.
 */
public Tasks<R> waitFor(final long timeoutMillis) throws ViPRException {
    final CountDownLatch countdown = new CountDownLatch(tasks.size());
    final List<TaskResourceRep> taskImpls = new ArrayList<>();
    for (final Task<R> task : tasks) {
        taskExecutor.execute(new Runnable() {

            @Override
            public void run() {
                try {
                    task.doTaskWait(timeoutMillis);
                    taskImpls.add(task.getTaskResource());
                } finally {
                    countdown.countDown();
                }
            }
        });
    }
    try {
        countdown.await();
        taskExecutor.shutdown();
    } catch (InterruptedException e) {
        log.error(e.getMessage(), e);
    }
    TaskUtil.checkForErrors(taskImpls);
    return this;
}
Also used : ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 78 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class TasksDataTable method fetch.

public static List<Task> fetch(URI resourceId) {
    if (resourceId == null) {
        return Collections.EMPTY_LIST;
    }
    List<TaskResourceRep> clientTasks = TaskUtils.getTasks(resourceId);
    List<Task> dataTableTasks = Lists.newArrayList();
    if (clientTasks != null) {
        for (TaskResourceRep clientTask : clientTasks) {
            dataTableTasks.add(new Task(clientTask));
        }
    }
    return dataTableTasks;
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 79 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class Events method details.

public static void details(String eventId) {
    if (StringUtils.isBlank(eventId)) {
        listAll();
    }
    EventRestRep event = EventUtils.getEvent(uri(eventId));
    if (event == null) {
        flash.error(MessagesUtils.get(UNKNOWN, eventId));
        listAll();
    }
    Common.angularRenderArgs().put("event", getEventSummary(event));
    List<String> approveDetails = Lists.newArrayList();
    List<String> declineDetails = Lists.newArrayList();
    if (event.getEventStatus().equalsIgnoreCase(ActionableEvent.Status.pending.name().toString()) || event.getEventStatus().equalsIgnoreCase(ActionableEvent.Status.failed.name().toString())) {
        EventDetailsRestRep details = getViprClient().events().getDetails(uri(eventId));
        approveDetails = details.getApproveDetails();
        declineDetails = details.getDeclineDetails();
    } else {
        approveDetails = event.getApproveDetails();
        declineDetails = event.getDeclineDetails();
    }
    Common.angularRenderArgs().put("approveDetails", approveDetails);
    Common.angularRenderArgs().put("declineDetails", declineDetails);
    List<TaskResourceRep> tasks = Lists.newArrayList();
    if (event != null && event.getTaskIds() != null) {
        tasks = getViprClient().tasks().getByRefs(event.getTaskIds());
    }
    render(event, approveDetails, declineDetails, tasks);
}
Also used : EventDetailsRestRep(com.emc.storageos.model.event.EventDetailsRestRep) EventRestRep(com.emc.storageos.model.event.EventRestRep) TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 80 with TaskResourceRep

use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.

the class Tasks method taskPoll.

private static List<TaskResourceRep> taskPoll(Long lastUpdated, Boolean systemTasks, int maxTasks) {
    List<TaskResourceRep> taskResourceReps = Lists.newArrayList();
    ViPRCoreClient client = getViprClient();
    URI tenant = null;
    if (systemTasks) {
        tenant = SYSTEM_TENANT;
    } else {
        tenant = uri(Models.currentAdminTenant());
    }
    for (TaskResourceRep item : client.tasks().findCreatedSince(tenant, lastUpdated, maxTasks)) {
        taskResourceReps.add(item);
    }
    return taskResourceReps;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI)

Aggregations

TaskResourceRep (com.emc.storageos.model.TaskResourceRep)160 URI (java.net.URI)85 TaskList (com.emc.storageos.model.TaskList)82 Operation (com.emc.storageos.db.client.model.Operation)68 Produces (javax.ws.rs.Produces)59 ArrayList (java.util.ArrayList)56 Volume (com.emc.storageos.db.client.model.Volume)55 Path (javax.ws.rs.Path)54 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)53 POST (javax.ws.rs.POST)50 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)49 Consumes (javax.ws.rs.Consumes)36 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)35 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 NamedURI (com.emc.storageos.db.client.model.NamedURI)30 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)23 Project (com.emc.storageos.db.client.model.Project)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)18 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)17 Copy (com.emc.storageos.model.block.Copy)17