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