Search in sources :

Example 1 with IsilonSyncJob

use of com.emc.storageos.isilon.restapi.IsilonSyncJob in project coprhd-controller by CoprHD.

the class IsilonMirrorOperations method doStartReplicationPolicy.

/**
 * Call to isilon to start replication session
 *
 * @param system
 * @param policyName
 * @return
 */
public BiosCommandResult doStartReplicationPolicy(StorageSystem system, String policyName, TaskCompleter taskCompleter) {
    _log.info("IsilonMirrorOperations -  doStartReplicationPolicy started on storagesystem {}", system.getLabel());
    try {
        IsilonApi isi = getIsilonDevice(system);
        IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
        IsilonSyncPolicy.JobState policyState = policy.getLastJobState();
        if (!policy.getEnabled()) {
            policy = doEnableReplicationPolicy(isi, policyName);
            if (policy.getEnabled()) {
                _log.info("Replication Policy - {} ENABLED successfully", policy.toString());
            }
        }
        if (!policyState.equals(JobState.running) || !policyState.equals(JobState.paused) || !policyState.equals(JobState.resumed)) {
            IsilonSyncJob job = new IsilonSyncJob();
            job.setId(policyName);
            isi.modifyReplicationJob(job);
            policy = isi.getReplicationPolicy(policyName);
            IsilonSyncJobStart isiSyncJobStart = new IsilonSyncJobStart(policyName, system.getId(), taskCompleter, policyName);
            try {
                ControllerServiceImpl.enqueueJob(new QueueJob(isiSyncJobStart));
                return BiosCommandResult.createPendingResult();
            } catch (Exception ex) {
                _log.error("Start Replication Job Failed ", ex);
                ServiceError error = DeviceControllerErrors.isilon.jobFailed("Start Replication Job Failed as:" + ex.getMessage());
                if (taskCompleter != null) {
                    taskCompleter.error(_dbClient, error);
                }
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            _log.error("Replication Policy - {} can't be STARTED because policy is in {} state", policyName, policyState);
            ServiceError error = DeviceControllerErrors.isilon.jobFailed("doStartReplicationPolicy as : Replication Policy can't be STARTED because " + "policy is already in Active state");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (IsilonException e) {
        _log.error("doStartReplicationPolicy failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSyncJobStart(com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobStart) JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonSyncJob(com.emc.storageos.isilon.restapi.IsilonSyncJob) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) 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 2 with IsilonSyncJob

use of com.emc.storageos.isilon.restapi.IsilonSyncJob in project coprhd-controller by CoprHD.

the class IsilonMirrorOperations method doResyncPrep.

/**
 * Call to resync-prep
 *
 * @param system
 * @param policyName
 * @param completer
 * @return
 * @throws IsilonException
 */
public BiosCommandResult doResyncPrep(StorageSystem system, String policyName, TaskCompleter completer) throws IsilonException {
    try {
        _log.info("resync-prep between source file system to target file system started and device ip:", system.getIpAddress());
        IsilonApi isi = getIsilonDevice(system);
        IsilonSyncPolicy syncPolicy = isi.getReplicationPolicy(policyName);
        // Before 'resync-prep' operation, Original source to target policy should be enabled.
        if (!syncPolicy.getEnabled()) {
            _log.info("Policy {} is in disabled state, enabling the policy before do resync-prep", policyName);
            syncPolicy = doEnableReplicationPolicy(isi, policyName);
            _log.info("Sleeping for 40 seconds for cancel operation to complete...");
            TimeUnit.SECONDS.sleep(40);
            syncPolicy = isi.getReplicationPolicy(policyName);
            _log.info("Replication Policy -{}  Enabled successfully.", syncPolicy.toString());
        }
        IsilonSyncJob job = new IsilonSyncJob();
        job.setId(policyName);
        job.setAction(Action.resync_prep);
        isi.modifyReplicationJob(job);
        IsilonSyncJobResync isilonSyncJobResync = new IsilonSyncJobResync(policyName, system.getId(), completer);
        ControllerServiceImpl.enqueueJob(new QueueJob(isilonSyncJobResync));
        return BiosCommandResult.createPendingResult();
    } catch (Exception ex) {
        _log.error("Resync-Prep Failed", ex);
        ServiceError error = DeviceControllerErrors.isilon.jobFailed("Resync-Prep FAILED  as : " + ex.getMessage());
        if (completer != null) {
            completer.error(_dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSyncJobResync(com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobResync) IsilonSyncJob(com.emc.storageos.isilon.restapi.IsilonSyncJob) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) URISyntaxException(java.net.URISyntaxException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 3 with IsilonSyncJob

use of com.emc.storageos.isilon.restapi.IsilonSyncJob 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 4 with IsilonSyncJob

use of com.emc.storageos.isilon.restapi.IsilonSyncJob in project coprhd-controller by CoprHD.

the class IsilonMirrorOperations method doCancelReplicationPolicy.

/**
 * Cancel the replication policy
 *
 * @param isi
 * @param policyName
 * @return
 */
public BiosCommandResult doCancelReplicationPolicy(IsilonApi isi, String policyName) {
    try {
        _log.info("Canceling Replication Policy  -{} because policy is in running state ", policyName);
        IsilonSyncJob syncJob = new IsilonSyncJob();
        syncJob.setState(JobState.canceled.name());
        isi.modifyReplicationJob(policyName, syncJob);
        _log.info("Sleeping for 40 seconds for cancel operation to complete...");
        TimeUnit.SECONDS.sleep(40);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        return BiosCommandResult.createErrorResult(e);
    } catch (InterruptedException ex) {
        _log.warn("Canceling ReplicationPolicy - {} Interrupted", policyName);
        ServiceError error = DeviceControllerErrors.isilon.jobFailed("Canceling ReplicationPolicy is Failed with Interrupt exception and message :" + ex.getMessage());
        return BiosCommandResult.createErrorResult(error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSyncJob(com.emc.storageos.isilon.restapi.IsilonSyncJob) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Aggregations

IsilonException (com.emc.storageos.isilon.restapi.IsilonException)4 IsilonSyncJob (com.emc.storageos.isilon.restapi.IsilonSyncJob)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)3 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)3 URISyntaxException (java.net.URISyntaxException)3 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)2 JobState (com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState)1 IsilonSyncTargetPolicy (com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy)1 IsilonSyncJobFailover (com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobFailover)1 IsilonSyncJobResync (com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobResync)1 IsilonSyncJobStart (com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobStart)1