Search in sources :

Example 1 with IsilonSyncJobStart

use of com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobStart 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)

Aggregations

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