Search in sources :

Example 1 with CacheStatusTaskCompleter

use of com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter in project coprhd-controller by CoprHD.

the class VPlexDeviceController method invalidateCache.

/**
 * Called to invalidate the read cache for a VPLEX volume when
 * restoring a snapshot.
 *
 * @param vplexURI
 *            The URI of the VPLEX system.
 * @param vplexVolumeURI
 *            The URI of a VPLEX volume.
 * @param stepId
 *            The workflow step identifier.
 */
public void invalidateCache(URI vplexURI, URI vplexVolumeURI, String stepId) {
    _log.info("Executing invalidate cache for volume {} on VPLEX {}", vplexVolumeURI, vplexURI);
    try {
        // Update workflow step.
        WorkflowStepCompleter.stepExecuting(stepId);
        // Get the API client.
        StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexURI, _dbClient);
        VPlexApiClient client = getVPlexAPIClient(_vplexApiFactory, vplexSystem, _dbClient);
        _log.info("Got VPLEX API client");
        // Get the VPLEX volume.
        Volume vplexVolume = getDataObject(Volume.class, vplexVolumeURI, _dbClient);
        String vplexVolumeName = vplexVolume.getDeviceLabel();
        _log.info("Got VPLEX volumes");
        // Invalidate the cache for the volume.
        boolean stillInProgress = client.invalidateVirtualVolumeCache(vplexVolumeName);
        _log.info("Invalidated the VPLEX volume cache");
        // invalidation completes.
        if (stillInProgress) {
            CacheStatusTaskCompleter invalidateCompleter = new CacheStatusTaskCompleter(vplexVolumeURI, stepId);
            VPlexCacheStatusJob cacheStatusJob = new VPlexCacheStatusJob(invalidateCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(cacheStatusJob));
            _log.info("Queued job to monitor migration progress.");
        } else {
            // Update workflow step state to success.
            WorkflowStepCompleter.stepSucceded(stepId);
            _log.info("Updated workflow step state to success");
        }
    } catch (VPlexApiException vae) {
        _log.error("Exception invalidating VPLEX volume cache " + vae.getMessage(), vae);
        WorkflowStepCompleter.stepFailed(stepId, vae);
    } catch (Exception e) {
        _log.error("Exception invalidating VPLEX volume cache " + e.getMessage(), e);
        WorkflowStepCompleter.stepFailed(stepId, VPlexApiException.exceptions.failedInvalidatingVolumeCache(vplexVolumeURI.toString(), e));
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) VPlexCacheStatusJob(com.emc.storageos.vplexcontroller.job.VPlexCacheStatusJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CacheStatusTaskCompleter(com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 Volume (com.emc.storageos.db.client.model.Volume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)1 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)1 CacheStatusTaskCompleter (com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter)1 VPlexCacheStatusJob (com.emc.storageos.vplexcontroller.job.VPlexCacheStatusJob)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1