use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.
the class ComputeImageService method getReadyOp.
/*
* Returns task in ready state.
*/
private TaskResourceRep getReadyOp(ComputeImage ci, ResourceOperationTypeEnum opType) {
log.info("doImportImageDone");
String taskId = UUID.randomUUID().toString();
AsyncTask task = new AsyncTask(ComputeImage.class, ci.getId(), taskId);
Operation readyOp = new Operation();
readyOp.ready();
readyOp.setResourceType(opType);
_dbClient.createTaskOpStatus(ComputeImage.class, ci.getId(), task._opId, readyOp);
return TaskMapper.toTask(ci, task._opId, readyOp);
}
use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.
the class DiscoveredObjectTaskScheduler method scheduleAsyncTasks.
public TaskList scheduleAsyncTasks(List<AsyncTask> tasks) {
TaskList list = new TaskList();
for (AsyncTask task : tasks) {
if (task instanceof ArrayAffinityAsyncTask) {
List<URI> systemIds = ((ArrayAffinityAsyncTask) task).getSystemIds();
for (URI uri : systemIds) {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, uri);
Operation op = new Operation();
op.setResourceType(_taskExecutor.getOperation());
_dbClient.createTaskOpStatus(task._clazz, uri, task._opId, op);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
} else {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, task._id);
Operation op = new Operation();
op.setResourceType(_taskExecutor.getOperation());
_dbClient.createTaskOpStatus(task._clazz, task._id, task._opId, op);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
}
try {
_taskExecutor.executeTasks(tasks.toArray(new AsyncTask[tasks.size()]));
} catch (ControllerException | APIException ex) {
for (AsyncTask task : tasks) {
DataObject discoveredObject = (DataObject) _dbClient.queryObject(task._clazz, task._id);
Operation op = _dbClient.error(task._clazz, task._id, task._opId, ex);
list.getTaskList().add(toTask(discoveredObject, task._opId, op));
}
}
return list;
}
use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.
the class BlockControllerImpl method scanStorageProviders.
/**
* {@inheritDoc}
*/
@Override
public void scanStorageProviders(AsyncTask[] tasks) throws ControllerException {
try {
Map<String, DataCollectionScanJob> scanJobByInterfaceType = new HashMap<String, DataCollectionScanJob>();
for (AsyncTask task : tasks) {
ScanTaskCompleter completer = new ScanTaskCompleter(task);
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, completer.getId());
if (provider != null && !provider.getInactive()) {
if (scanJobByInterfaceType.get(provider.getInterfaceType()) == null) {
scanJobByInterfaceType.put(provider.getInterfaceType(), new DataCollectionScanJob());
}
scanJobByInterfaceType.get(provider.getInterfaceType()).addCompleter(completer);
}
}
for (DataCollectionScanJob job : scanJobByInterfaceType.values()) {
_util.scheduleScanningJobs(job);
}
} catch (Exception e) {
throw ClientControllerException.fatals.unableToScanSMISProviders(tasks, "BlockController", e);
}
}
use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.
the class ControllerServiceImpl method createDiscoverJobsForTasks.
private static ArrayList<DataCollectionJob> createDiscoverJobsForTasks(AsyncTask[] tasks, String jobType) {
ArrayList<DataCollectionJob> jobs = new ArrayList<DataCollectionJob>();
for (AsyncTask task : tasks) {
if (task instanceof ArrayAffinityAsyncTask) {
List<URI> hostIds = ((ArrayAffinityAsyncTask) task).getHostIds();
List<URI> systemIds = ((ArrayAffinityAsyncTask) task).getSystemIds();
ArrayAffinityDataCollectionTaskCompleter completer = new ArrayAffinityDataCollectionTaskCompleter(task._clazz, systemIds, task._opId, jobType);
DataCollectionJob job = new DataCollectionArrayAffinityJob(hostIds, systemIds, completer, task._namespace);
jobs.add(job);
} else {
DiscoverTaskCompleter completer = new DiscoverTaskCompleter(task, jobType);
if (null == task._namespace) {
task._namespace = Discovery_Namespaces.ALL.toString();
}
DataCollectionJob job = new DataCollectionDiscoverJob(completer, task._namespace);
jobs.add(job);
}
}
return jobs;
}
use of com.emc.storageos.volumecontroller.AsyncTask in project coprhd-controller by CoprHD.
the class ComputeControllerImpl method createHosts.
@Override
public void createHosts(URI varray, URI vcpoolId, AsyncTask[] tasks) throws InternalException {
_log.info("createHosts");
for (AsyncTask task : tasks) {
Host host = _dbClient.queryObject(Host.class, task._id);
if (host != null) {
if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
execCompute("createHost", computeElement.getComputeSystem(), vcpoolId, varray, task._id, task._opId);
} else {
_dbClient.error(Host.class, task._id, task._opId, ComputeSystemControllerException.exceptions.noComputeElementAssociatedWithHost(host.getNativeGuid().toString(), host.getId().toString(), null));
}
} else {
// if the host comes out to be null... Skipping for now
continue;
}
}
}
Aggregations