Search in sources :

Example 1 with VPlexCacheStatusInfo

use of com.emc.storageos.vplex.api.VPlexCacheStatusInfo in project coprhd-controller by CoprHD.

the class VPlexCacheStatusJob method poll.

/**
 * {@inheritDoc}
 */
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
    s_logger.debug("Polled cache status job");
    // Get the DB client from the job context.
    DbClient dbClient = jobContext.getDbClient();
    // Get the VPLEX volume associated with the cache invalidation job.
    Volume vplexVolume = dbClient.queryObject(Volume.class, _taskCompleter.getId());
    String vplexVolumeName = vplexVolume.getDeviceLabel();
    s_logger.debug("VPLEX volume is {}", vplexVolume.getId());
    // Get the VPlex storage system for that VPLEX volume.
    StorageSystem vplexSystem = dbClient.queryObject(StorageSystem.class, vplexVolume.getStorageController());
    s_logger.debug("VPlex system is {}", vplexSystem.getId());
    try {
        // Update the job info.
        _pollResult.setJobName(vplexVolumeName);
        _pollResult.setJobId(vplexSystem.getId().toString());
        _pollResult.setJobPercentComplete(0);
        s_logger.debug("Updated poll result");
        // Get the VPlex API client for this VPlex storage system
        // and get the cache invalidation status for the VPLEX volume.
        VPlexApiClient vplexApiClient = VPlexControllerUtils.getVPlexAPIClient(jobContext.getVPlexApiFactory(), vplexSystem, dbClient);
        s_logger.debug("Got VPlex APi Client");
        VPlexCacheStatusInfo cacheStatusInfo = vplexApiClient.getCacheStatus(vplexVolumeName);
        s_logger.debug("Got cache status info from VPlex");
        // Examine the status.
        InvalidateStatus invalidateStatus = cacheStatusInfo.getCacheInvalidateStatus();
        if (InvalidateStatus.SUCCESS.equals(invalidateStatus)) {
            // Completed successfully
            s_logger.info("Cache Invalidate for Volume: {} completed sucessfully", vplexVolume.getId());
            _pollResult.setJobPercentComplete(100);
            _status = JobStatus.SUCCESS;
        } else if (InvalidateStatus.FAILED.equals(invalidateStatus)) {
            // Failed.
            s_logger.info("Cache Invalidate for Volume : {} failed", vplexVolume.getId());
            _pollResult.setJobPercentComplete(100);
            _errorDescription = cacheStatusInfo.getCacheInvalidateFailedMessage();
            _status = JobStatus.FAILED;
        }
    } catch (Exception e) {
        _errorDescription = e.getMessage();
        s_logger.error(String.format("Unexpected error getting cache status for volume %s on VPlex %s: %s", vplexVolume.getId(), vplexSystem.getId(), _errorDescription), e);
        _status = JobStatus.FAILED;
    } finally {
        s_logger.debug("Updating status {}", _status);
        updateStatus(jobContext);
    }
    _pollResult.setJobStatus(_status);
    _pollResult.setErrorDescription(_errorDescription);
    return _pollResult;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) InvalidateStatus(com.emc.storageos.vplex.api.VPlexCacheStatusInfo.InvalidateStatus) VPlexCacheStatusInfo(com.emc.storageos.vplex.api.VPlexCacheStatusInfo) Volume(com.emc.storageos.db.client.model.Volume) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) URISyntaxException(java.net.URISyntaxException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

DbClient (com.emc.storageos.db.client.DbClient)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 Volume (com.emc.storageos.db.client.model.Volume)1 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)1 VPlexCacheStatusInfo (com.emc.storageos.vplex.api.VPlexCacheStatusInfo)1 InvalidateStatus (com.emc.storageos.vplex.api.VPlexCacheStatusInfo.InvalidateStatus)1 URISyntaxException (java.net.URISyntaxException)1