use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class ControllerUtils method getMirrorReplicationGroupNames.
/**
* Gets mirror replication group names from mirrors of all volumes in CG.
*/
public static Set<String> getMirrorReplicationGroupNames(List<Volume> volumes, DbClient dbClient) {
Set<String> groupNames = new HashSet<String>();
// check if replica of any of these volumes have replicationGroupInstance set
for (Volume volume : volumes) {
URIQueryResultList mirrorList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeBlockMirrorConstraint(volume.getId()), mirrorList);
Iterator<URI> iter = mirrorList.iterator();
while (iter.hasNext()) {
URI mirrorID = iter.next();
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorID);
if (mirror != null && !mirror.getInactive() && NullColumnValueGetter.isNotNullValue(mirror.getReplicationGroupInstance())) {
groupNames.add(mirror.getReplicationGroupInstance());
}
}
if (!groupNames.isEmpty()) {
// no need to check other CG members
break;
}
}
return groupNames;
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class ControllerUtils method getMirrorsPartOfReplicationGroup.
/**
* Gets the mirrors part of a given replication group.
*/
public static List<BlockMirror> getMirrorsPartOfReplicationGroup(String replicationGroupInstance, DbClient dbClient) {
List<BlockMirror> mirrors = new ArrayList<BlockMirror>();
URIQueryResultList uriQueryResultList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getMirrorReplicationGroupInstanceConstraint(replicationGroupInstance), uriQueryResultList);
Iterator<BlockMirror> mirrorIterator = dbClient.queryIterativeObjects(BlockMirror.class, uriQueryResultList);
while (mirrorIterator.hasNext()) {
BlockMirror mirror = mirrorIterator.next();
if (mirror != null && !mirror.getInactive()) {
mirrors.add(mirror);
}
}
return mirrors;
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class ControllerUtils method checkCGHasGroupRelationship.
/**
* Check if CG has any group relationship
*
* Note - on array side, if replica has been removed from replication group, but source volume has not been removed from CG yet,
* the CG will not have group relationship until the source volume get removed from the CG.
*
* As a result, getting associator names cannot be used to check if CG has group relationship.
*/
public static boolean checkCGHasGroupRelationship(StorageSystem storage, URI cgURI, DbClient dbClient) {
// get volumes part of this CG
List<Volume> volumes = ControllerUtils.getVolumesPartOfCG(cgURI, dbClient);
boolean isVNX = storage.deviceIsType(Type.vnxblock);
// check if replica of any of these volumes have replicationGroupInstance set
for (Volume volume : volumes) {
if (NullColumnValueGetter.isNotNullValue(volume.getReplicationGroupInstance())) {
if (!isVNX) {
// VNX doesn't have group clones/mirrors
// clone
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()) {
return true;
}
}
// mirror
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()) {
return true;
}
}
}
// snapshot
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()) {
return true;
}
}
// snapshot session
if (storage.checkIfVmax3()) {
URIQueryResultList sessionList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getBlockSnapshotSessionByConsistencyGroup(cgURI), sessionList);
Iterator<URI> itr = sessionList.iterator();
while (itr.hasNext()) {
URI sessionID = itr.next();
BlockSnapshotSession session = dbClient.queryObject(BlockSnapshotSession.class, sessionID);
if (session != null && !session.getInactive()) {
return true;
}
}
}
}
}
return false;
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class ControllerUtils method getAutoTieringPolicyName.
public static String getAutoTieringPolicyName(URI uri, DbClient dbClient) {
String policyName = Constants.NONE;
if (URIUtil.isType(uri, Volume.class)) {
Volume volume = dbClient.queryObject(Volume.class, uri);
URI policyURI = volume.getAutoTieringPolicyUri();
if (!NullColumnValueGetter.isNullURI(policyURI)) {
AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
policyName = policy.getPolicyName();
}
} else if (URIUtil.isType(uri, BlockSnapshot.class)) {
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, uri);
StorageSystem storage = dbClient.queryObject(StorageSystem.class, snapshot.getStorageController());
if (storage.checkIfVmax3()) {
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
URI policyURI = volume.getAutoTieringPolicyUri();
if (!NullColumnValueGetter.isNullURI(policyURI)) {
AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
policyName = policy.getPolicyName();
}
}
} else if (URIUtil.isType(uri, BlockMirror.class)) {
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, uri);
if (!NullColumnValueGetter.isNullURI(mirror.getAutoTieringPolicyUri())) {
AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, mirror.getAutoTieringPolicyUri());
policyName = policy.getPolicyName();
}
}
return policyName;
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class AbstractBlockServiceApiImpl method addDescriptorsForMirrors.
/**
* Given a list of VolumeDescriptors and a volume, adds the descriptors necessary
* for any BlockMirrors on the volume.
*
* @param descriptors
* List<VolumeDescriptor>
* @param volume
*/
protected void addDescriptorsForMirrors(List<VolumeDescriptor> descriptors, Volume volume) {
if (volume.getMirrors() != null && volume.getMirrors().isEmpty() == false) {
for (String mirrorId : volume.getMirrors()) {
BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, URI.create(mirrorId));
if (mirror != null && !mirror.getInactive()) {
VolumeDescriptor mirrorDesc = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_MIRROR, volume.getStorageController(), URI.create(mirrorId), null, null);
descriptors.add(mirrorDesc);
}
}
}
}
Aggregations