use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VMAX3BlockSnapshotSessionApiImpl method verifyNewTargetCount.
/**
* {@inheritDoc}
*/
@Override
protected void verifyNewTargetCount(BlockObject sourceObj, int newTargetsCount, boolean zeroIsValid) {
// Call super first.
super.verifyNewTargetCount(sourceObj, newTargetsCount, zeroIsValid);
// Now make sure max is not exceeded.
if (newTargetsCount > 0) {
// The total number of linked targets for all sessions for a given
// source can't exceed 1024. So, get all sessions for the source
// and add all linked targets for these sessions. That value plus
// the number of new targets cannot exceed the max.
int totalLinkedTargets = newTargetsCount;
List<BlockSnapshotSession> snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(sourceObj.getId()));
for (BlockSnapshotSession snapSession : snapSessions) {
StringSet linkedTargetIds = snapSession.getLinkedTargets();
if (linkedTargetIds != null) {
totalLinkedTargets += linkedTargetIds.size();
}
}
if (totalLinkedTargets > MAX_LINKED_TARGETS_PER_SOURCE) {
throw APIException.badRequests.invalidNewLinkedTargetsCount(newTargetsCount, sourceObj.getLabel(), MAX_LINKED_TARGETS_PER_SOURCE - totalLinkedTargets);
}
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VMAX3BlockFullCopyApiImpl method validateSnapshotCreateRequest.
/**
* {@inheritDoc}
*/
@Override
public void validateSnapshotCreateRequest(Volume requestedVolume, List<Volume> volumesToSnap) {
// so verify there are no active full copies for the volume.
for (Volume volumeToSnap : volumesToSnap) {
// Check if the volume to snap is an active full copy.
if ((BlockFullCopyUtils.isVolumeFullCopy(volumeToSnap, _dbClient)) && (!BlockFullCopyUtils.isFullCopyDetached(volumeToSnap, _dbClient)) && (!BlockFullCopyUtils.isFullCopyInactive(volumeToSnap, _dbClient))) {
throw APIException.badRequests.noSnapshotsForVMAX3VolumeWithActiveFullCopy();
}
// Now check if the volume to be snapped is a full copy source
// that has active full copies.
StringSet fullCopyIds = volumeToSnap.getFullCopies();
if ((fullCopyIds != null) && (!fullCopyIds.isEmpty())) {
Iterator<String> fullCopyIdsIter = fullCopyIds.iterator();
while (fullCopyIdsIter.hasNext()) {
URI fullCopyURI = URI.create(fullCopyIdsIter.next());
Volume fullCopyVolume = _dbClient.queryObject(Volume.class, fullCopyURI);
if ((fullCopyVolume != null) && (!fullCopyVolume.getInactive()) && (!BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) && (!BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient))) {
throw APIException.badRequests.noSnapshotsForVMAX3VolumeWithActiveFullCopy();
}
}
}
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method validateUnManagedExportMasks.
/**
* Validates that all the selected UnManagedExportMasks are compatible for ingestion.
*
* Currently only VPLEX volumes are checked for presence of a
* single storage view per VPLEX cluster per host initiator.
*
* @param unManagedVolume the UnManagedVolume being ingested
* @param unManagedMasks the UnManagedExportMasks being ingested
* @param dbClient a reference to the database client
*/
public static void validateUnManagedExportMasks(UnManagedVolume unManagedVolume, List<UnManagedExportMask> unManagedMasks, DbClient dbClient) {
if (isVplexVolume(unManagedVolume)) {
Map<String, Set<String>> initToMaskMap = new HashMap<String, Set<String>>();
// vplex brownfield requires initiators to only be in one storage view.
// assemble a Set of all initiator ports being masked to the ingesting unmanaged volume
StringSet allInitiatorPortsBeingIngested = new StringSet();
for (UnManagedExportMask mask : unManagedMasks) {
allInitiatorPortsBeingIngested.addAll(mask.getKnownInitiatorNetworkIds());
allInitiatorPortsBeingIngested.addAll(mask.getUnmanagedInitiatorNetworkIds());
}
URIQueryResultList result = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageSystemUnManagedExportMaskConstraint(unManagedVolume.getStorageSystemUri()), result);
Set<URI> allMasksUrisForVplex = new HashSet<URI>();
Iterator<URI> it = result.iterator();
while (it.hasNext()) {
allMasksUrisForVplex.add(it.next());
}
Iterator<UnManagedExportMask> allMasksForVplex = dbClient.queryIterativeObjects(UnManagedExportMask.class, allMasksUrisForVplex, true);
while (allMasksForVplex.hasNext()) {
UnManagedExportMask mask = allMasksForVplex.next();
if (null != mask) {
mapInitsToVplexStorageViews(initToMaskMap, mask, allInitiatorPortsBeingIngested);
}
}
_logger.info("initiator to UnManagedExportMask map is " + initToMaskMap);
// filter out any initiator to mask entries that satisfy the requirements of 1 storage view per initiator
Iterator<Entry<String, Set<String>>> mapEntries = initToMaskMap.entrySet().iterator();
while (mapEntries.hasNext()) {
Entry<String, Set<String>> entry = mapEntries.next();
if (entry.getValue().size() <= 1) {
mapEntries.remove();
}
}
// if any are left in the map, they violate the single storage view per initiator rule
if (!initToMaskMap.isEmpty()) {
StringBuilder errorDetails = new StringBuilder();
for (Entry<String, Set<String>> mapEntry : initToMaskMap.entrySet()) {
errorDetails.append("Initiator port ").append(mapEntry.getKey());
errorDetails.append(" is contained in the following storage views: ");
errorDetails.append(Joiner.on(", ").join(mapEntry.getValue())).append(". ");
}
_logger.error(errorDetails.toString());
throw IngestionException.exceptions.invalidExportConfiguration(errorDetails.toString());
}
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method setupMirrorParentRelations.
/**
* Setup relationships between a mirror and its parent BlockObject.
*
* @param mirror the mirror BlockObject
* @param parentVolume the mirror's parent BlockObject
* @param dbClient a reference to the database client
*/
public static void setupMirrorParentRelations(BlockObject mirror, BlockObject parent, DbClient dbClient) {
_logger.info("Setting up relationship between mirror {} ({}) and parent {} ({})", new Object[] { mirror.getLabel(), mirror.getId(), parent.getLabel(), parent.getId() });
((BlockMirror) mirror).setSource(new NamedURI(parent.getId(), parent.getLabel()));
if (parent instanceof Volume) {
StringSet mirrors = ((Volume) parent).getMirrors();
if (mirrors == null) {
mirrors = new StringSet();
}
mirrors.add(mirror.getId().toString());
((Volume) parent).setMirrors(mirrors);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method setupSnapParentRelations.
/**
* Setup relationships between a snapshot and its parent BlockObject.
*
* @param snapshot the snapshot BlockObject
* @param parentVolume the snapshot's parent BlockObject
* @param dbClient a reference to the database client
*/
public static void setupSnapParentRelations(BlockObject snapshot, BlockObject parentVolume, DbClient dbClient) {
_logger.info("Setting up relationship between snapshot {} ({}) and parent {} ({})", new Object[] { snapshot.getLabel(), snapshot.getId(), parentVolume.getLabel(), parentVolume.getId() });
((BlockSnapshot) snapshot).setSourceNativeId(parentVolume.getNativeId());
((BlockSnapshot) snapshot).setParent(new NamedURI(parentVolume.getId(), parentVolume.getLabel()));
snapshot.setProtocol(new StringSet());
snapshot.getProtocol().addAll(parentVolume.getProtocol());
URI cgUri = parentVolume.getConsistencyGroup();
// Do not associate parent's CG if it is a RP protected parent volume
boolean isRP = (parentVolume instanceof Volume && ((Volume) parentVolume).checkForRp()) || (parentVolume instanceof BlockSnapshot && ((BlockSnapshot) parentVolume).getProtectionController() != null);
if (!isRP && cgUri != null) {
snapshot.setConsistencyGroup(cgUri);
}
// TODO - check how to populate snapsetlabel if in consistency group
}
Aggregations