Search in sources :

Example 11 with AsyncTask

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);
}
Also used : AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Operation(com.emc.storageos.db.client.model.Operation)

Example 12 with AsyncTask

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;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ControllerException(com.emc.storageos.volumecontroller.ControllerException) TaskList(com.emc.storageos.model.TaskList) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI)

Example 13 with AsyncTask

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);
    }
}
Also used : HashMap(java.util.HashMap) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) DataCollectionScanJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionScanJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ClientControllerException(com.emc.storageos.exceptions.ClientControllerException) RetryableDatabaseException(com.emc.storageos.db.exceptions.RetryableDatabaseException)

Example 14 with AsyncTask

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;
}
Also used : DataCollectionJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionJob) DataCollectionDiscoverJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionDiscoverJob) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) DataCollectionArrayAffinityJob(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DataCollectionArrayAffinityJob) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) ArrayList(java.util.ArrayList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) ArrayAffinityDataCollectionTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ArrayAffinityDataCollectionTaskCompleter) URI(java.net.URI)

Example 15 with AsyncTask

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;
        }
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) Host(com.emc.storageos.db.client.model.Host)

Aggregations

AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)34 ArrayList (java.util.ArrayList)22 TaskList (com.emc.storageos.model.TaskList)17 Consumes (javax.ws.rs.Consumes)16 Produces (javax.ws.rs.Produces)16 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)15 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)12 Operation (com.emc.storageos.db.client.model.Operation)11 ArrayAffinityAsyncTask (com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask)11 POST (javax.ws.rs.POST)11 Path (javax.ws.rs.Path)11 URI (java.net.URI)10 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)8 BlockController (com.emc.storageos.volumecontroller.BlockController)8 Host (com.emc.storageos.db.client.model.Host)6 ImageServerController (com.emc.storageos.imageservercontroller.ImageServerController)5 MapProtectionSystem (com.emc.storageos.api.mapper.functions.MapProtectionSystem)4 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)4 ProtectionController (com.emc.storageos.protectioncontroller.ProtectionController)4