use of com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doFailover.
/**
* Call to device to failover the policy
*
* @param system
* @param policyName
* @param taskCompleter
* @return
*/
public BiosCommandResult doFailover(StorageSystem system, String policyName, TaskCompleter taskCompleter) {
_log.info("IsilonMirrorOperations - doFailover started ");
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncTargetPolicy syncTargetPolicy = isi.getTargetReplicationPolicy(policyName);
if (syncTargetPolicy.getFoFbState().equals(FOFB_STATES.writes_enabled)) {
_log.info("can't perform failover operation on policy: {} because failover is done already", syncTargetPolicy.getName());
return BiosCommandResult.createSuccessfulResult();
}
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
job.setAction(Action.allow_write);
isi.modifyReplicationJob(job);
IsilonSyncJobFailover isiSyncJobFailover = new IsilonSyncJobFailover(policyName, system.getId(), taskCompleter, policyName);
try {
ControllerServiceImpl.enqueueJob(new QueueJob(isiSyncJobFailover));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Failover to Secondary Cluster Failed", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Failover to Secondary Cluster Failed as :" + ex.getMessage());
if (taskCompleter != null) {
taskCompleter.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy in project coprhd-controller by CoprHD.
the class IsilonSyncJobFailover method poll.
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
String currentJob = _jobIds.get(0);
try {
IsilonApi isiApiClient = getIsilonRestClient(jobContext);
if (isiApiClient == null) {
String errorMessage = "No Isilon REST API client found for: " + _storageSystemUri;
processTransientError(currentJob, trackingPeriodInMillis, errorMessage, null);
} else {
_pollResult.setJobName(_jobName);
_pollResult.setJobId(_taskCompleter.getOpId());
IsilonSyncTargetPolicy policy = null;
IsilonSyncPolicy.JobState policyState = null;
policy = isiApiClient.getTargetReplicationPolicy(currentJob);
policyState = policy.getLastJobState();
if (policyState != null && policyState.equals(JobState.running) || policy.equals(FOFB_STATES.enabling_writes)) {
_status = JobStatus.IN_PROGRESS;
} else if (policyState != null && policyState.equals(JobState.finished)) {
_status = JobStatus.SUCCESS;
_pollResult.setJobPercentComplete(100);
_logger.info("IsilonSyncIQJob: {} succeeded", currentJob);
} else if (policyState != null && policyState.equals(JobState.failed)) {
_errorDescription = isiGetReportErrMsg(isiApiClient.getTargetReplicationPolicyReports(currentJob).getList());
_pollResult.setJobPercentComplete(100);
_pollResult.setErrorDescription(_errorDescription);
_status = JobStatus.FAILED;
_logger.error("IsilonSyncIQJob: {} failed; Details: {}", currentJob, _errorDescription);
}
}
} catch (Exception e) {
processTransientError(currentJob, trackingPeriodInMillis, e.getMessage(), e);
} finally {
try {
updateStatus(jobContext);
} catch (Exception e) {
setErrorStatus(e.getMessage());
_logger.error("Problem while trying to update status", e);
}
}
_pollResult.setJobStatus(_status);
return _pollResult;
}
Aggregations