Search in sources :

Example 1 with MirrorFileFailbackTaskCompleter

use of com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method doFailBackMirrorSessionWF.

/**
 * Child Workflow for failback
 *
 * @param systemURI
 * @param fsURI source FS URI
 * @param taskId
 */
public void doFailBackMirrorSessionWF(URI systemURI, URI fsURI, String taskId) {
    TaskCompleter taskCompleter = null;
    String stepDescription;
    String stepId;
    Object[] args;
    try {
        FileShare sourceFS = s_dbClient.queryObject(FileShare.class, fsURI);
        StorageSystem primarysystem = s_dbClient.queryObject(StorageSystem.class, systemURI);
        StringSet targets = sourceFS.getMirrorfsTargets();
        List<URI> targetFSURI = new ArrayList<>();
        for (String target : targets) {
            targetFSURI.add(URI.create(target));
        }
        FileShare targetFS = s_dbClient.queryObject(FileShare.class, targetFSURI.get(0));
        StorageSystem secondarySystem = s_dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
        taskCompleter = new MirrorFileFailbackTaskCompleter(FileShare.class, sourceFS.getId(), taskId);
        Workflow workflow = _workflowService.getNewWorkflow(this, FAILBACK_FILE_SYSTEM_METHOD, false, taskId, taskCompleter);
        s_logger.info("Generating steps for failback to source file share: {} from target file share: {}", fsURI, targetFS.getId());
        /*
             * Step 1. Creates a mirror replication policy for the secondary cluster i.e Resync-prep on primary cluster , this will disable
             * primary cluster replication policy.
             */
        stepDescription = String.format("source resync-prep : creating mirror policy on target system: %s", secondarySystem.getId());
        stepId = workflow.createStepId();
        args = new Object[] { primarysystem.getId(), sourceFS.getId(), "resync" };
        String waitFor = _fileDeviceController.createMethod(workflow, null, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, primarysystem.getId(), args);
        /*
             * Step 2. Start the mirror replication policy manually, this will replicate new data (written during failover) from secondary
             * cluster to primary cluster.
             */
        stepDescription = String.format("start mirror policy: replicate target file share: %s, data to source file share:%s", targetFS.getId(), sourceFS.getId());
        stepId = workflow.createStepId();
        args = new Object[] { secondarySystem.getId(), targetFS.getId(), "start" };
        waitFor = _fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
        /*
             * Step 3. Allow Write on Primary Cluster local target after replication from step 2
             * i.e Fail over to Primary Cluster
             */
        stepDescription = String.format("failover on source file system : allow write on source file share: %s", sourceFS.getId());
        stepId = workflow.createStepId();
        List<URI> combined = Arrays.asList(sourceFS.getId(), targetFS.getId());
        MirrorFileFailoverTaskCompleter failoverCompleter = new MirrorFileFailoverTaskCompleter(FileShare.class, combined, stepId);
        args = new Object[] { primarysystem.getId(), sourceFS.getId(), failoverCompleter };
        waitFor = _fileDeviceController.createMethod(workflow, waitFor, FAILOVER_FILE_SYSTEM_METHOD, stepId, stepDescription, primarysystem.getId(), args);
        /*
             * Step 4. Resync-Prep on secondary cluster , same as step 1 but will be executed on secondary cluster instead of primary
             * cluster.
             */
        stepDescription = String.format(" target resync-prep : disabling mirror policy on target system: %s", secondarySystem.getId());
        stepId = workflow.createStepId();
        args = new Object[] { secondarySystem.getId(), targetFS.getId(), "resync" };
        _fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
        String successMsg = String.format("Failback of %s to %s successful", sourceFS.getId(), targetFS.getId());
        workflow.executePlan(taskCompleter, successMsg);
    } catch (Exception ex) {
        s_logger.error("Could not replicate source filesystem CIFS shares: " + fsURI, ex);
        String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILBACK.getName();
        ServiceError serviceError = DeviceControllerException.errors.createFileSharesFailed(fsURI.toString(), opName, ex);
        taskCompleter.error(s_dbClient, this._locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) ArrayList(java.util.ArrayList) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) StringSet(com.emc.storageos.db.client.model.StringSet) FileObject(com.emc.storageos.db.client.model.FileObject) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

FileObject (com.emc.storageos.db.client.model.FileObject)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)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 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)1 MirrorFileFailbackTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter)1 MirrorFileFailoverTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter)1 VNXeFSSnapshotTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter)1 Workflow (com.emc.storageos.workflow.Workflow)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1