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;
}
Aggregations