Search in sources :

Example 6 with IsilonSyncTargetPolicy

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSyncTargetPolicy(com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy) IsilonSyncJob(com.emc.storageos.isilon.restapi.IsilonSyncJob) IsilonSyncJobFailover(com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobFailover) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) URISyntaxException(java.net.URISyntaxException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 7 with IsilonSyncTargetPolicy

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;
}
Also used : IsilonSyncTargetPolicy(com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy) JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) URISyntaxException(java.net.URISyntaxException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Aggregations

IsilonSyncTargetPolicy (com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy)7 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)3 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)3 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)2 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)2 URISyntaxException (java.net.URISyntaxException)2 FileShare (com.emc.storageos.db.client.model.FileShare)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 IsilonSyncJob (com.emc.storageos.isilon.restapi.IsilonSyncJob)1 JobState (com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 IsilonSyncJobFailover (com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobFailover)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1