use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method promoteMirror.
public void promoteMirror(List<URI> mirrorList, List<URI> promotedVolumeList, Boolean isCG, String opId) {
_log.info("START promoteMirror");
Volume promoted = null;
try {
List<BlockMirror> mirrors = new ArrayList<BlockMirror>(mirrorList.size());
List<Volume> promotedVolumes = new ArrayList<Volume>(mirrorList.size());
int count = 0;
for (URI id : mirrorList) {
BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, id);
Volume source = _dbClient.queryObject(Volume.class, mirror.getSource().getURI());
String promotedLabel = ControllerUtils.getMirrorLabel(source.getLabel(), mirror.getLabel());
if (isCG) {
promotedLabel = mirror.getLabel();
}
promoted = VolumeFactory.newInstance(mirror);
promoted.setId(promotedVolumeList.get(count++));
promoted.setLabel(promotedLabel);
promotedVolumes.add(promoted);
_log.info("Promoted mirror {} to volume {}", mirror.getId(), promoted.getId());
// If there are exports masks/export groups associated, then
// remove the mirror from them and add the promoted volume.
ExportUtils.updatePromotedMirrorExports(mirror, promoted, _dbClient);
mirror.setInactive(true);
mirrors.add(mirror);
}
_dbClient.updateObject(mirrors);
_dbClient.updateObject(promotedVolumes);
WorkflowStepCompleter.stepSucceded(opId);
} catch (Exception e) {
String msg = String.format("Failed to promote mirror %s", Joiner.on("\t").join(mirrorList));
_log.error(msg, e);
WorkflowStepCompleter.stepFailed(opId, DeviceControllerException.exceptions.stopVolumeMirrorFailed(mirrorList.get(0)));
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method rollbackListMirror.
public void rollbackListMirror(URI storage, List<URI> mirrorList, String taskId) {
WorkflowStepCompleter.stepExecuting(taskId);
try {
List<BlockMirror> mirrorsNoRollback = new ArrayList<BlockMirror>();
List<BlockMirror> mirrorsToRollback = new ArrayList<BlockMirror>();
Iterator<BlockMirror> mirrorIterator = _dbClient.queryIterativeObjects(BlockMirror.class, mirrorList);
while (mirrorIterator.hasNext()) {
BlockMirror mirror = mirrorIterator.next();
if (mirror != null && !mirror.getInactive()) {
if (isNullOrEmpty(mirror.getNativeId())) {
mirror.setInactive(true);
mirrorsNoRollback.add(mirror);
} else {
mirrorsToRollback.add(mirror);
}
}
}
if (!mirrorsNoRollback.isEmpty()) {
_dbClient.updateObject(mirrorsNoRollback);
}
if (!mirrorsToRollback.isEmpty()) {
List<URI> mirrorURIsToRollback = new ArrayList<URI>(transform(mirrorsToRollback, FCTN_MIRROR_TO_URI));
String mirrorNativeIds = Joiner.on(", ").join(transform(mirrorsToRollback, fctnBlockObjectToNativeID()));
if (mirrorIsPausable(mirrorsToRollback)) {
_log.info("Attempting to fracture {} for rollback", mirrorNativeIds);
fractureMirror(storage, mirrorURIsToRollback, false, false, generateStepIdForDependentCallDuringRollback());
}
_log.info("Attempting to detach {} for rollback", mirrorNativeIds);
detachMirror(storage, mirrorURIsToRollback, false, false, generateStepIdForDependentCallDuringRollback());
_log.info("Attempting to delete {} for rollback", mirrorNativeIds);
deleteMirror(storage, mirrorURIsToRollback, false, generateStepIdForDependentCallDuringRollback());
}
WorkflowStepCompleter.stepSucceded(taskId);
} catch (InternalException ie) {
_log.error(String.format("rollbackListMirror failed - Array:%s, Mirror:%s", storage, Joiner.on("\t").join(mirrorList)));
doFailTask(BlockMirror.class, mirrorList, taskId, ie);
WorkflowStepCompleter.stepFailed(taskId, ie);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(taskId, serviceError);
doFailTask(BlockMirror.class, mirrorList, taskId, serviceError);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method resumeNativeContinuousCopies.
@Override
public void resumeNativeContinuousCopies(URI storage, List<URI> mirrors, String opId) throws ControllerException {
_log.info("START resume continuous copies workflow");
Workflow workflow = _workflowService.getNewWorkflow(this, RESUME_MIRRORS_WF_NAME, false, opId);
TaskCompleter taskCompleter = null;
List<BlockMirror> mirrorList = _dbClient.queryObject(BlockMirror.class, mirrors);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
List<URI> sourceVolumes = getSourceVolumes(mirrorList);
try {
taskCompleter = new BlockMirrorTaskCompleter(Volume.class, sourceVolumes, opId);
boolean isCG = ControllerUtils.checkMirrorConsistencyGroup(mirrors, _dbClient, taskCompleter);
if (!isCG) {
for (BlockMirror blockMirror : mirrorList) {
if (SynchronizationState.FRACTURED.toString().equals(blockMirror.getSyncState())) {
workflow.createStep("resumeStep", "resume", null, storage, storageObj.getSystemType(), this.getClass(), resumeNativeContinuousCopyMethod(storage, asList(blockMirror.getId()), isCG), null, null);
}
}
} else {
if (hasFracturedState(mirrorList)) {
workflow.createStep("resumeStep", "resume", null, storage, storageObj.getSystemType(), this.getClass(), resumeNativeContinuousCopyMethod(storage, mirrors, isCG), null, null);
}
}
workflow.executePlan(taskCompleter, "Successfully resumed continuous copies");
} catch (Exception e) {
String msg = String.format("Failed to execute resume continuous copies workflow for volume %s", Joiner.on("\t").join(sourceVolumes));
_log.error(msg, e);
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method rollbackMirror.
/**
* {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method rollbackMirrorMethod just above
* (except opId).
*/
public void rollbackMirror(URI storage, List<URI> mirrorList, String taskId) {
WorkflowStepCompleter.stepExecuting(taskId);
try {
List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
boolean isCG = isCGMirror(mirrorList.get(0), _dbClient);
List<BlockMirror> mirrorsNoRollback = new ArrayList<BlockMirror>();
for (BlockMirror mirror : mirrors) {
// for non CG mirror, filter out mirror with no native Id
if ((isCG && NullColumnValueGetter.isNullValue(mirror.getReplicationGroupInstance()) || (!isCG && isNullOrEmpty(mirror.getNativeId())))) {
mirror.setInactive(true);
mirrorsNoRollback.add(mirror);
}
}
if (!mirrorsNoRollback.isEmpty()) {
_dbClient.updateObject(mirrorsNoRollback);
mirrors.removeAll(mirrorsNoRollback);
}
if (!mirrors.isEmpty()) {
List<URI> mirrorURIsToRollback = new ArrayList<URI>(transform(mirrors, FCTN_MIRROR_TO_URI));
String mirrorNativeIds = Joiner.on(", ").join(transform(mirrors, fctnBlockObjectToNativeID()));
if (mirrorIsPausable(mirrors)) {
_log.info("Attempting to fracture {} for rollback", mirrorNativeIds);
fractureMirror(storage, mirrorURIsToRollback, isCG, false, taskId);
}
_log.info("Attempting to detach {} for rollback", mirrorNativeIds);
detachMirror(storage, mirrorURIsToRollback, isCG, false, taskId);
_log.info("Attempting to delete {} for rollback", mirrorNativeIds);
deleteMirror(storage, mirrorURIsToRollback, isCG, taskId);
}
WorkflowStepCompleter.stepSucceded(taskId);
} catch (InternalException ie) {
_log.error(String.format("rollbackMirror Failed - Array:%s, Mirror:%s", storage, Joiner.on("\t").join(mirrorList)));
doFailTask(Volume.class, mirrorList, taskId, ie);
WorkflowStepCompleter.stepFailed(taskId, ie);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(taskId, serviceError);
doFailTask(Volume.class, mirrorList, taskId, serviceError);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockMirrorCreateCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
super.complete(dbClient, status, coded);
List<BlockMirror> mirrorList = dbClient.queryObject(BlockMirror.class, getIds());
for (BlockMirror mirror : mirrorList) {
Volume volume = dbClient.queryObject(Volume.class, mirror.getSource());
switch(status) {
case error:
mirror.setInactive(true);
dbClient.persistObject(mirror);
removeMirrorFromVolume(mirror.getId(), volume, dbClient);
dbClient.error(BlockMirror.class, mirror.getId(), getOpId(), coded);
dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
break;
default:
dbClient.ready(BlockMirror.class, mirror.getId(), getOpId());
dbClient.ready(Volume.class, volume.getId(), getOpId());
}
recordBlockMirrorOperation(dbClient, OperationTypeEnum.CREATE_VOLUME_MIRROR, status, eventMessage(status, volume, mirror), mirror, volume);
}
} catch (Exception e) {
_log.error("Failed updating status. BlockMirrorCreate {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
}
}
Aggregations