use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method setCloneState.
public void setCloneState(List<URI> clones, ReplicationState state, String opId) {
_log.info("Set clones state");
List<Volume> cloneVols = _dbClient.queryObject(Volume.class, clones);
for (Volume cloneVol : cloneVols) {
cloneVol.setReplicaState(state.name());
}
_dbClient.updateObject(cloneVols);
CloneCreateWorkflowCompleter completer = new CloneCreateWorkflowCompleter(clones, opId);
completer.ready(_dbClient);
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createFullCopy.
@Override
public void createFullCopy(URI storage, List<URI> fullCopyVolumes, Boolean createInactive, String taskId) throws ControllerException {
_log.info("START fullCopyVolumes");
TaskCompleter taskCompleter = new CloneCreateWorkflowCompleter(fullCopyVolumes, taskId);
Volume clone = _dbClient.queryObject(Volume.class, fullCopyVolumes.get(0));
URI sourceVolume = clone.getAssociatedSourceVolume();
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
Workflow workflow = _workflowService.getNewWorkflow(this, FULL_COPY_WORKFLOW, true, taskId);
boolean isCG = false;
Volume source = URIUtil.isType(sourceVolume, Volume.class) ? _dbClient.queryObject(Volume.class, sourceVolume) : null;
VolumeGroup volumeGroup = (source != null) ? source.getApplication(_dbClient) : null;
if (volumeGroup != null) {
/**
* If a Volume is in Volume Group (COPY type),
* Query all volumes belonging to that Volume Group,
* Group full-copies by Array Replication Group and create workflow step for each Array Group,
* these steps runs in parallel
*/
_log.info("Creating full copy for Application {}", volumeGroup.getLabel());
createFullCopyForApplicationCGs(workflow, volumeGroup, fullCopyVolumes, createInactive, taskCompleter);
} else if (checkCloneConsistencyGroup(fullCopyVolumes.get(0), _dbClient, taskCompleter)) {
// check if the clone is in a CG
isCG = true;
_log.info("Creating group full copy");
createCGFullCopy(storage, sourceVolume, fullCopyVolumes, storageSystem, workflow, createInactive, isCG);
} else {
for (URI uri : fullCopyVolumes) {
Workflow.Method createMethod = createFullCopyVolumeMethod(storage, sourceVolume, Arrays.asList(uri), createInactive, isCG);
Workflow.Method rollbackMethod = rollbackFullCopyVolumeMethod(storage, asList(uri));
workflow.createStep(FULL_COPY_CREATE_STEP_GROUP, "Creating full copy", null, storage, storageSystem.getSystemType(), getClass(), createMethod, rollbackMethod, null);
// clone state.
if (!createInactive && !getDriverManager().isDriverManaged(storageSystem.getSystemType())) {
// After all full copies have been created, wait for synchronization to complete
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(uri), isCG);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", FULL_COPY_CREATE_STEP_GROUP, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, rollbackMethodNullMethod(), null);
Volume cloneVol = _dbClient.queryObject(Volume.class, uri);
BlockObject sourceObj = BlockObject.fetch(_dbClient, cloneVol.getAssociatedSourceVolume());
// detach if source is snapshot, or storage system is not vmax/vnx/hds
if (storageSystem.deviceIsType(Type.openstack)) {
setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
} else if (sourceObj instanceof BlockSnapshot || !(storageSystem.deviceIsType(Type.vmax) || storageSystem.deviceIsType(Type.hds) || storageSystem.deviceIsType(Type.vnxblock))) {
Workflow.Method detachMethod = detachFullCopyMethod(storage, asList(uri));
workflow.createStep(FULL_COPY_DETACH_STEP_GROUP, "Detaching full copy", waitForSyncStep, storage, storageSystem.getSystemType(), getClass(), detachMethod, rollbackMethodNullMethod(), null);
} else if (storageSystem.deviceIsType(Type.vnxblock)) {
workflow.createStep(FULL_COPY_FRACTURE_STEP_GROUP, "fracture full copy", waitForSyncStep, storage, storageSystem.getSystemType(), BlockDeviceController.class, fractureCloneMethod(storage, Arrays.asList(uri), isCG), rollbackMethodNullMethod(), null);
} else {
setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
}
}
}
}
String successMsg = String.format("Full copy of %s to %s successful", sourceVolume, fullCopyVolumes);
workflow.executePlan(taskCompleter, successMsg);
} catch (InternalException e) {
_log.error("Failed to create full copy of volume", e);
doFailTask(Volume.class, sourceVolume, taskId, e);
WorkflowStepCompleter.stepFailed(taskId, e);
} catch (Exception e) {
_log.error("Failed to create full copy of volume", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, sourceVolume, taskId, serviceError);
WorkflowStepCompleter.stepFailed(taskId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateWorkflowCompleter in project coprhd-controller by CoprHD.
the class BlockOrchestrationDeviceController method createFullCopy.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController#createFullCopy(java.util.List,
* java.lang.String)
*/
@Override
public void createFullCopy(List<VolumeDescriptor> volumeDescriptors, String taskId) throws InternalException {
// The volume descriptors include the VPLEX source volume, which we do not want
// to pass to the completer. In case of error constructing the WF, the completer
// must mark all volumes prepared for this request inactive. However, we must not
// mark the VPLEX source volume inactive!
List<URI> volUris = new ArrayList<>();
URI vplexSourceURI = null;
for (VolumeDescriptor descriptor : volumeDescriptors) {
if (descriptor.getParameters().get(VolumeDescriptor.PARAM_IS_COPY_SOURCE_ID) == null) {
volUris.add(descriptor.getVolumeURI());
} else {
vplexSourceURI = descriptor.getVolumeURI();
}
}
TaskCompleter completer = new CloneCreateWorkflowCompleter(volUris, taskId);
Workflow workflow = null;
List<VolumeDescriptor> blockVolmeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA, VolumeDescriptor.Type.VPLEX_IMPORT_VOLUME }, new VolumeDescriptor.Type[] {});
List<URI> blockVolUris = VolumeDescriptor.getVolumeURIs(blockVolmeDescriptors);
// add all consistency groups to the completer
Set<URI> cgIds = new HashSet<URI>();
for (URI blockId : blockVolUris) {
Volume fcVolume = getDbClient().queryObject(Volume.class, blockId);
// Filed COP-23075 to move this check for null associated source volume to the utility method in x-wing
if (fcVolume != null && !fcVolume.getInactive() && !NullColumnValueGetter.isNullURI(fcVolume.getAssociatedSourceVolume())) {
BlockConsistencyGroup group = ConsistencyGroupUtils.getCloneConsistencyGroup(blockId, getDbClient());
if (group != null) {
cgIds.add(group.getId());
}
}
}
for (URI cgId : cgIds) {
completer.addConsistencyGroupId(cgId);
}
for (URI appId : ControllerUtils.getApplicationsForFullCopies(blockVolUris, getDbClient())) {
completer.addVolumeGroupId(appId);
}
try {
// For VPLEX full copies, validate the VPLEX source volume.
if (vplexSourceURI != null) {
validator.volumeURIs(Arrays.asList(vplexSourceURI), true, true, ValCk.ID, ValCk.VPLEX);
}
// Generate the Workflow.
workflow = _workflowService.getNewWorkflow(this, CREATE_FULL_COPIES_WF_NAME, false, taskId, completer);
// the wait for key returned by previous call
String waitFor = null;
s_logger.info("Adding steps for RecoverPoint create full copy");
// Call the RPDeviceController to add its methods if there are RP protections
waitFor = _rpDeviceController.addStepsForPreCreateReplica(workflow, waitFor, volumeDescriptors, taskId);
s_logger.info("Adding steps for storage array create full copies");
// First, call the BlockDeviceController to add its methods.
waitFor = _blockDeviceController.addStepsForCreateFullCopy(workflow, waitFor, volumeDescriptors, taskId);
// post recoverpoint steps disables image access which should be done after the
// create clone steps but before the vplex steps.
s_logger.info("Adding steps for RecoverPoint post create full copy");
// Call the RPDeviceController to add its methods if there are RP protections
waitFor = _rpDeviceController.addStepsForPostCreateReplica(workflow, waitFor, volumeDescriptors, taskId);
s_logger.info("Checking for VPLEX steps");
// Call the VPlexDeviceController to add its methods if there are VPLEX volumes.
waitFor = _vplexDeviceController.addStepsForCreateFullCopy(workflow, waitFor, volumeDescriptors, taskId);
// Finish up and execute the plan.
// The Workflow will handle the TaskCompleter
String successMessage = "Create volumes successful for: " + volUris.toString();
Object[] callbackArgs = new Object[] { volUris };
workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
} catch (Exception ex) {
s_logger.error("Could not create full copy volumes: " + volUris, ex);
releaseWorkflowLocks(workflow);
String opName = ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME.getName();
ServiceError serviceError = DeviceControllerException.errors.createVolumesFailed(volUris.toString(), opName, ex);
completer.error(s_dbClient, _locker, serviceError);
}
}
Aggregations