Search in sources :

Example 16 with ReplicationInfo

use of com.emc.storageos.hds.model.ReplicationInfo 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

ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)16 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)7 HDSHost (com.emc.storageos.hds.model.HDSHost)7 HashMap (java.util.HashMap)7 ClientResponse (com.sun.jersey.api.client.ClientResponse)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 URI (java.net.URI)6 JavaResult (org.milyn.payload.JavaResult)6 Volume (com.emc.storageos.db.client.model.Volume)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 HDSException (com.emc.storageos.hds.HDSException)5 HDSApiProtectionManager (com.emc.storageos.hds.api.HDSApiProtectionManager)5 ReplicationGroup (com.emc.storageos.hds.model.ReplicationGroup)5 SnapshotGroup (com.emc.storageos.hds.model.SnapshotGroup)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 Add (com.emc.storageos.hds.model.Add)2