Search in sources :

Example 6 with HDSApiProtectionManager

use of com.emc.storageos.hds.api.HDSApiProtectionManager in project coprhd-controller by CoprHD.

the class HDSReplicationSyncJob method poll.

/**
 */
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
    try {
        StorageSystem storageSystem = jobContext.getDbClient().queryObject(StorageSystem.class, getStorageSystemURI());
        // log.info("HDSJob: Looking up job: id {}, provider: {} ", messageId, storageSystem.getActiveProviderURI());
        HDSApiClient hdsApiClient = jobContext.getHdsApiFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        if (hdsApiClient == null) {
            String errorMessage = "No HDS client found for provider ip: " + storageSystem.getActiveProviderURI();
            processTransientError(trackingPeriodInMillis, errorMessage, null);
        } else {
            HDSApiProtectionManager apiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
            Pair<ReplicationInfo, String> response = apiProtectionManager.getReplicationInfoFromSystem(sourceNativeId, targetNativeId);
            ReplicationStatus status = ReplicationStatus.UNKNOWN;
            if (response != null) {
                status = ReplicationStatus.getReplicationStatusFromCode(response.first.getStatus());
                log.info("Expected status :{}", expectedStatus.name());
                log.info("Current replication status :{}", status.name());
                if (expectedStatus == status) {
                    _status = JobStatus.SUCCESS;
                    _pollResult.setJobPercentComplete(100);
                    log.info("HDSReplicationSyncJob: {} {} succeeded", sourceNativeId, targetNativeId);
                } else if (!status.isErrorStatus()) {
                    /**
                     * HiCommand Device Manager is having issue to get the modified replication info
                     * status from pair management server. To get the latest pair status from device manager,
                     * we have introduced a workaround to trigger pair mgmt server host update call.
                     * Once Device Manager has a fix for this issue, we can revert this work around.
                     *
                     * Refreshing host (Pair Mgmt Server) for every 10th polling.
                     */
                    if (++pollingCount % 10 == 0) {
                        log.info("Attempting to refresh pair managerment server :{}", response.second);
                        apiProtectionManager.refreshPairManagementServer(response.second);
                    }
                }
            }
            if (response == null || status.isErrorStatus()) {
                _status = JobStatus.FAILED;
                _pollResult.setJobPercentComplete(100);
                _errorDescription = String.format("Replication Status %1$s", new Object[] { status.name() });
                log.error("HDSReplicationSyncJob: {} failed; Details: {}", getJobName(), _errorDescription);
            }
        }
    } catch (Exception e) {
        processTransientError(trackingPeriodInMillis, e.getMessage(), e);
        log.error(e.getMessage(), e);
    } finally {
        try {
            _postProcessingStatus = JobStatus.SUCCESS;
            updateStatus(jobContext);
            if (_postProcessingStatus == JobStatus.ERROR) {
                processPostProcessingError(trackingPeriodInMillis, _errorDescription, null);
            }
        } catch (Exception e) {
            setErrorStatus(e.getMessage());
            log.error("Problem while trying to update status", e);
        }
    }
    _pollResult.setJobStatus(_status);
    _pollResult.setErrorDescription(_errorDescription);
    return _pollResult;
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)6 HDSApiProtectionManager (com.emc.storageos.hds.api.HDSApiProtectionManager)6 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)5 Volume (com.emc.storageos.db.client.model.Volume)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 HDSException (com.emc.storageos.hds.HDSException)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 HDSReplicationSyncJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1