use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class HDSMirrorOperations method fractureSingleVolumeMirror.
/**
* Split ShadowImage pair
*/
@Override
public void fractureSingleVolumeMirror(StorageSystem storage, URI mirror, Boolean sync, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("fractureSingleVolumeMirror started");
try {
BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
Volume sourceVolume = dbClient.queryObject(Volume.class, mirrorObj.getSource());
hdsProtectionOperations.modifyShadowImagePair(storage, sourceVolume.getNativeId(), mirrorObj.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.split);
HDSJob syncjob = new HDSReplicationSyncJob(storage.getId(), sourceVolume.getNativeId(), mirrorObj.getNativeId(), ReplicationStatus.SPLIT, taskCompleter);
hdsCommandHelper.waitForAsyncHDSJob(syncjob);
mirrorObj.setSyncState(SynchronizationState.FRACTURED.name());
dbClient.persistObject(mirrorObj);
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Failed to resume single volume mirror: {}", mirror, e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(dbClient, serviceError);
}
log.info("fractureSingleVolumeMirror completed");
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class ControllerUtils method getGroupNameFromReplicas.
/**
* Gets the replication group name from replicas of all volumes in CG.
*/
public static String getGroupNameFromReplicas(List<URI> replicas, BlockConsistencyGroup consistencyGroup, DbClient dbClient) {
URI replicaURI = replicas.iterator().next();
// get volumes part of this CG
List<Volume> volumes = ControllerUtils.getVolumesPartOfCG(consistencyGroup.getId(), dbClient);
// check if replica of any of these volumes have replicationGroupInstance set
for (Volume volume : volumes) {
if (URIUtil.isType(replicaURI, BlockSnapshot.class)) {
URIQueryResultList list = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), list);
Iterator<URI> it = list.iterator();
while (it.hasNext()) {
URI snapshotID = it.next();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotID);
if (snapshot != null && !snapshot.getInactive() && NullColumnValueGetter.isNotNullValue(snapshot.getReplicationGroupInstance())) {
return snapshot.getReplicationGroupInstance();
}
}
} else if (URIUtil.isType(replicaURI, Volume.class)) {
URIQueryResultList cloneList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getAssociatedSourceVolumeConstraint(volume.getId()), cloneList);
Iterator<URI> iter = cloneList.iterator();
while (iter.hasNext()) {
URI cloneID = iter.next();
Volume clone = dbClient.queryObject(Volume.class, cloneID);
if (clone != null && !clone.getInactive() && NullColumnValueGetter.isNotNullValue(clone.getReplicationGroupInstance())) {
return clone.getReplicationGroupInstance();
}
}
} else if (URIUtil.isType(replicaURI, BlockMirror.class)) {
URIQueryResultList mirrorList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeBlockMirrorConstraint(volume.getId()), mirrorList);
Iterator<URI> itr = mirrorList.iterator();
while (itr.hasNext()) {
URI mirrorID = itr.next();
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorID);
if (mirror != null && !mirror.getInactive() && NullColumnValueGetter.isNotNullValue(mirror.getReplicationGroupInstance())) {
return mirror.getReplicationGroupInstance();
}
}
}
}
return null;
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockMirrorDetachCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
try {
_log.info("START BlockMirrorDetachCompleter " + status);
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());
if (status == Status.ready) {
_log.info("Removing sync details for mirror " + mirror.getId());
mirror.setSynchronizedInstance(NullColumnValueGetter.getNullStr());
mirror.setSyncState(NullColumnValueGetter.getNullStr());
dbClient.persistObject(mirror);
_log.info("Removing mirror {} from source volume {}", mirror.getId().toString(), volume.getId().toString());
if (volume.getMirrors() != null) {
volume.getMirrors().remove(mirror.getId().toString());
dbClient.persistObject(volume);
}
}
switch(status) {
case error:
dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
break;
default:
dbClient.ready(Volume.class, volume.getId(), getOpId());
}
recordBlockMirrorOperation(dbClient, OperationTypeEnum.DETACH_VOLUME_MIRROR, status, eventMessage(status, volume, mirror), mirror, volume);
}
} catch (Exception e) {
_log.error("Failed updating status. BlockMirrorDetach {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockMirrorFractureCompleter 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:
dbClient.error(Volume.class, volume.getId(), getOpId(), coded);
break;
default:
mirror.setSyncState(SynchronizationState.FRACTURED.toString());
dbClient.persistObject(mirror);
dbClient.ready(Volume.class, volume.getId(), getOpId());
}
recordBlockMirrorOperation(dbClient, OperationTypeEnum.FRACTURE_VOLUME_MIRROR, Status.ready, eventMessage(status, volume, mirror), mirror, volume);
}
} catch (Exception e) {
_log.error("Failed updating status. BlockMirrorCreate {}, for task " + getOpId(), Joiner.on("\t").join(getIds()), e);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class SmisCommandHelper method getBlockObjectAlternateName.
/**
* This method will take a URI and return alternateName for the BlockObject object to which the
* URI applies.
*
* @param uri
* - URI
* @return Returns a nativeId String value
* @throws DeviceControllerException.exceptions.notAVolumeOrBlocksnapshotUri
* if URI is not a Volume/BlockSnapshot URI
*/
public String getBlockObjectAlternateName(URI uri) throws Exception {
String nativeId;
if (URIUtil.isType(uri, Volume.class)) {
Volume volume = _dbClient.queryObject(Volume.class, uri);
nativeId = volume.getAlternateName();
} else if (URIUtil.isType(uri, BlockSnapshot.class)) {
BlockSnapshot blockSnapshot = _dbClient.queryObject(BlockSnapshot.class, uri);
nativeId = blockSnapshot.getAlternateName();
} else if (URIUtil.isType(uri, BlockMirror.class)) {
BlockMirror blockMirror = _dbClient.queryObject(BlockMirror.class, uri);
nativeId = blockMirror.getAlternateName();
} else {
throw DeviceControllerException.exceptions.notAVolumeOrBlocksnapshotUri(uri);
}
return nativeId;
}
Aggregations