use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method scheduleStorageForVpoolChangeProtected.
/**
* Scheduler for a Vpool change from a protected VPLEX Virtual volume to a different type
* of protection. Ex: RP+VPLEX upgrade to MetroPoint
*
* @param volume volume that is being changed to a protected vpool
* @param newVpool vpool requested to change to (must be protected)
* @param protectionVarrays Varrays to protect this volume to.
* @param vpoolChangeParam The change param for the vpool change operation
* @return list of Recommendation objects to satisfy the request
*/
public List<Recommendation> scheduleStorageForVpoolChangeProtected(Volume volume, VirtualPool newVpool, List<VirtualArray> protectionVirtualArraysForVirtualPool) {
_log.info(String.format("Schedule storage for vpool change to vpool [%s : %s] for volume [%s : %s]", newVpool.getLabel(), newVpool.getId().toString(), volume.getLabel(), volume.getId().toString()));
this.initResources();
VirtualPool currentVpool = dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
VirtualArray varray = dbClient.queryObject(VirtualArray.class, volume.getVirtualArray());
// Swap src and ha if the flag has been set on the vpool
SwapContainer container = this.swapSrcAndHAIfNeeded(varray, newVpool);
Project project = dbClient.queryObject(Project.class, volume.getProject());
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, volume.getCapacity());
capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
List<StoragePool> sourcePools = new ArrayList<StoragePool>();
List<StoragePool> haPools = new ArrayList<StoragePool>();
VirtualArray haVarray = vplexScheduler.getHaVirtualArray(container.getSrcVarray(), project, container.getSrcVpool());
VirtualPool haVpool = vplexScheduler.getHaVirtualPool(container.getSrcVarray(), project, container.getSrcVpool());
// Recommendations to return
List<Recommendation> recommendations = Lists.newArrayList();
// Upgrade RP+VPLEX to MetroPoint
if (VirtualPool.vPoolSpecifiesRPVPlex(currentVpool) && VirtualPool.vPoolSpecifiesMetroPoint(newVpool)) {
// We already have our VPLEX Metro source and targets provisioned.
// We're going to leverage this for placement.
_log.info("Scheduling storage for upgrade to MetroPoint, we need to place a HA/Stand-by/Secondary Journal");
// Get a handle on the existing source and ha volumes, we want to use the references to their
// existing storage pools to pass to the RP Scheduler.
Volume sourceBackingVolume = null;
Volume haBackingVolume = null;
if (null == volume.getAssociatedVolumes() || volume.getAssociatedVolumes().isEmpty()) {
_log.error("VPLEX volume {} has no backend volumes.", volume.forDisplay());
throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(volume.forDisplay());
}
for (String associatedVolumeId : volume.getAssociatedVolumes()) {
URI associatedVolumeURI = URI.create(associatedVolumeId);
Volume backingVolume = dbClient.queryObject(Volume.class, associatedVolumeURI);
if (backingVolume.getVirtualArray().equals(volume.getVirtualArray())) {
sourceBackingVolume = backingVolume;
} else {
haBackingVolume = backingVolume;
}
}
// We already have a source vpool from the (the existing one), so just add that one only to the list.
sourcePools.add(dbClient.queryObject(StoragePool.class, sourceBackingVolume.getPool()));
haPools.add(dbClient.queryObject(StoragePool.class, haBackingVolume.getPool()));
// Obtain a list of RP protection Virtual Arrays.
List<VirtualArray> tgtVarrays = RecoverPointScheduler.getProtectionVirtualArraysForVirtualPool(project, container.getSrcVpool(), dbClient, _permissionsHelper);
recommendations = createMetroPointRecommendations(container.getSrcVarray(), tgtVarrays, container.getSrcVpool(), haVarray, haVpool, project, capabilities, sourcePools, haPools, volume);
}
// There is only one entry of type RPProtectionRecommendation ever in the returned recommendation list.
_log.info(String.format("%s %n", ((RPProtectionRecommendation) recommendations.get(0)).toString(dbClient)));
return recommendations;
}
use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method createRPProtectionRecommendationForMetroPoint.
/**
* Creates primary (active) and secondary (standby) cluster recommendations for MetroPoint.
*
* We first determine the type of MetroPoint request based on the protection virtual array
* configuration (single remote, local only, or local and remote). Using this information
* we determine a possible placement recommendation for the primary cluster. Using the
* primary cluster recommendation we then figure out a secondary cluster recommendation.
* The secondary cluster recommendation needs protection attributes that give with the
* primary cluster recommendation to satisfy the type of MetroPoint configuration requested.
*
* @param varray the source virtual array.
* @param protectionVarrays the RecoverPoint protection virtual arrays.
* @param vpool the source virtual pool.
* @param haVarray the HA virtual array - secondary cluster.
* @param haVpool the HA virtual pool - secondary cluster.
* @param capabilities parameters.
* @param candidateActiveSourcePools the candidate primary cluster source pools.
* @param candidateStandbySourcePools the candidate secondary cluster source pools.
* @param candidateProtectionPoolsMap pre-populated map for tgt varray to storage pools, use null if not needed
* @return list of Recommendation objects to satisfy the request
*/
private RPProtectionRecommendation createRPProtectionRecommendationForMetroPoint(VirtualArray varray, List<VirtualArray> protectionVarrays, VirtualPool vpool, VirtualArray haVarray, VirtualPool haVpool, VirtualPoolCapabilityValuesWrapper capabilities, List<StoragePool> candidateActiveSourcePools, List<StoragePool> candidateStandbySourcePools, Map<VirtualArray, List<StoragePool>> candidateProtectionPools, Volume vpoolChangeVolume, Project project) {
// Initialize a list of recommendations to be returned.
Set<ProtectionSystem> secondaryProtectionSystems = null;
placementStatus = new PlacementStatus();
secondaryPlacementStatus = new PlacementStatus();
int requestedResourceCount = capabilities.getResourceCount();
int totalSatisfiedCount = 0;
List<URI> protectionVarrayURIs = new ArrayList<URI>();
for (VirtualArray vArray : protectionVarrays) {
protectionVarrayURIs.add(vArray.getId());
placementStatus.getProcessedProtectionVArrays().put(vArray.getId(), false);
}
// Active journal varray - Either explicitly set by the user or use the default varray.
VirtualArray activeJournalVarray = (NullColumnValueGetter.isNotNullValue(vpool.getJournalVarray()) ? dbClient.queryObject(VirtualArray.class, URI.create(vpool.getJournalVarray())) : varray);
// Active journal vpool - Either explicitly set by the user or use the default vpool.
VirtualPool activeJournalVpool = (NullColumnValueGetter.isNotNullValue(vpool.getJournalVpool()) ? dbClient.queryObject(VirtualPool.class, URI.create(vpool.getJournalVpool())) : vpool);
// Standby journal varray - Either explicitly set by the user or use the default haVarray.
VirtualArray standbyJournalVarray = (NullColumnValueGetter.isNotNullValue(vpool.getStandbyJournalVarray()) ? dbClient.queryObject(VirtualArray.class, URI.create(vpool.getStandbyJournalVarray())) : haVarray);
// Standby journal vpool - Either explicitly set by the user or use the default haVpool.
VirtualPool standbyJournalVpool = (NullColumnValueGetter.isNotNullValue(vpool.getStandbyJournalVpool()) ? dbClient.queryObject(VirtualPool.class, URI.create(vpool.getStandbyJournalVpool())) : haVpool);
// Build the list of protection virtual arrays to consider for determining a
// primary placement solution. Add all virtual arrays from the source virtual
// pool list of protection virtual arrays, except for the HA/standby virtual array.
// In the case of local and/or remote protection, the HA virtual array should
// never be considered as a valid protection target for primary placement.
List<VirtualArray> activeProtectionVarrays = new ArrayList<VirtualArray>();
for (VirtualArray protectionVarray : protectionVarrays) {
if (!protectionVarray.getId().equals(haVarray.getId())) {
activeProtectionVarrays.add(protectionVarray);
}
}
// Build the list of protection virtual arrays to consider for determining a
// standby placement solution. Add all virtual arrays from the source virtual
// pool list of protection virtual arrays, except for the source virtual array.
// In the case of local and/or remote protection, the source virtual array should
// never be considered as a valid protection target for standby placement.
List<VirtualArray> standbyProtectionVarrays = new ArrayList<VirtualArray>();
for (VirtualArray protectionVarray : protectionVarrays) {
if (!protectionVarray.getId().equals(varray.getId())) {
standbyProtectionVarrays.add(protectionVarray);
}
}
// The attributes below will not change throughout the placement process
placementStatus.setSrcVArray(varray.getLabel());
placementStatus.setSrcVPool(vpool.getLabel());
boolean secondaryRecommendationSolution = false;
int satisfiedSourceVolCount = 0;
int totalRequestedResourceCount = capabilities.getResourceCount();
boolean isChangeVpool = (vpoolChangeVolume != null);
// Top level recommendation object
RPProtectionRecommendation rpProtectionRecommendation = new RPProtectionRecommendation();
// Source pool recommendations
List<Recommendation> sourcePoolRecommendations = new ArrayList<Recommendation>();
// Map to hold standby storage pools to protection systems
Map<URI, Set<ProtectionSystem>> standbyStoragePoolsToProtectionSystems = new HashMap<URI, Set<ProtectionSystem>>();
// Change vpool only: Set values for change vpool. If not a change vpool these values will be null.
rpProtectionRecommendation.setVpoolChangeVolume(vpoolChangeVolume != null ? vpoolChangeVolume.getId() : null);
rpProtectionRecommendation.setVpoolChangeNewVpool(vpoolChangeVolume != null ? vpool.getId() : null);
rpProtectionRecommendation.setVpoolChangeProtectionAlreadyExists(vpoolChangeVolume != null ? vpoolChangeVolume.checkForRp() : false);
// Change vpool only: Recommendation objects specifically used for change vpool. These will not be populated otherwise.
Recommendation changeVpoolSourceRecommendation = new Recommendation();
Recommendation changeVpoolStandbyRecommendation = new Recommendation();
if (isChangeVpool) {
// valid pool, the existing ones for active and standby. This is just to used to pass through the placement code.
if (null == vpoolChangeVolume.getAssociatedVolumes() || vpoolChangeVolume.getAssociatedVolumes().isEmpty()) {
_log.error("VPLEX volume {} has no backend volumes.", vpoolChangeVolume.forDisplay());
throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(vpoolChangeVolume.forDisplay());
}
for (String associatedVolume : vpoolChangeVolume.getAssociatedVolumes()) {
Volume assocVol = dbClient.queryObject(Volume.class, URI.create(associatedVolume));
if (assocVol.getVirtualArray().equals(varray.getId())) {
// This is the existing active source backing volume
changeVpoolSourceRecommendation.setSourceStoragePool(assocVol.getPool());
StoragePool pool = dbClient.queryObject(StoragePool.class, assocVol.getPool());
changeVpoolSourceRecommendation.setSourceStorageSystem(pool.getStorageDevice());
changeVpoolSourceRecommendation.setResourceCount(1);
sourcePoolRecommendations.add(changeVpoolSourceRecommendation);
_log.info(String.format("RP Placement : Change Virtual Pool - Active source pool already exists, reuse pool: [%s] [%s].", pool.getLabel().toString(), pool.getId().toString()));
} else if (assocVol.getVirtualArray().equals(haVarray.getId())) {
// This is the existing standby source backing volume
changeVpoolStandbyRecommendation.setSourceStoragePool(assocVol.getPool());
StoragePool pool = dbClient.queryObject(StoragePool.class, assocVol.getPool());
changeVpoolStandbyRecommendation.setSourceStorageSystem(pool.getStorageDevice());
changeVpoolStandbyRecommendation.setResourceCount(1);
_log.info(String.format("RP Placement : Change Virtual Pool - Standby source pool already exists, reuse pool: [%s] [%s].", pool.getLabel().toString(), pool.getId().toString()));
}
}
satisfiedSourceVolCount = 1;
} else {
// If this is not a change vpool, then gather the recommended pools for the source.
sourcePoolRecommendations = getRecommendedPools(rpProtectionRecommendation, varray, vpool, null, null, capabilities, RPHelper.SOURCE, null);
}
// If we have no source pools at this point, throw an exception.
if (sourcePoolRecommendations == null || sourcePoolRecommendations.isEmpty()) {
_log.error(String.format("RP Placement : No matching storage pools found for the source varray: [%s. " + "There are no storage pools that match the passed vpool parameters and protocols and/or there are " + "no pools that have enough capacity to hold at least one resource of the requested size.", varray.getLabel()));
throw APIException.badRequests.noMatchingStoragePoolsForVpoolAndVarray(vpool.getLabel(), varray.getLabel());
}
_log.info(String.format("RP Placement : Determining RP placement for the primary (active) MetroPoint cluster for %s resources.", totalRequestedResourceCount));
// Keep track of the possible pools to use for the source. This will help us determine if we have
// exhausted all our options.
int remainingPossiblePrimarySrcPoolSolutions = sourcePoolRecommendations.size();
// Iterate over the source pools found to find a solution...
for (Recommendation recommendedPool : sourcePoolRecommendations) {
StoragePool sourcePool = dbClient.queryObject(StoragePool.class, recommendedPool.getSourceStoragePool());
--remainingPossiblePrimarySrcPoolSolutions;
satisfiedSourceVolCount = (recommendedPool.getResourceCount() >= requestedResourceCount) ? requestedResourceCount : recommendedPool.getResourceCount();
Set<ProtectionSystem> primaryProtectionSystems = new HashSet<ProtectionSystem>();
ProtectionSystem cgProtectionSystem = getCgProtectionSystem(capabilities.getBlockConsistencyGroup());
// used by other volumes in it.
if (cgProtectionSystem != null) {
BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
_log.info(String.format("RP Placement : Narrowing down placement to use protection system %s, which is currently used " + "by RecoverPoint consistency group %s.", cgProtectionSystem.getLabel(), cg));
primaryProtectionSystems.add(cgProtectionSystem);
} else {
primaryProtectionSystems = getProtectionSystemsForStoragePool(sourcePool, varray, true);
if (primaryProtectionSystems.isEmpty()) {
continue;
}
}
// Sort the ProtectionSystems based on the last time a CG was created. Always use the
// ProtectionSystem with the oldest cgLastCreated timestamp to support a round-robin
// style of load balancing.
List<ProtectionSystem> primaryProtectionSystemsList = sortProtectionSystems(primaryProtectionSystems);
for (ProtectionSystem primaryProtectionSystem : primaryProtectionSystemsList) {
Calendar cgLastCreated = primaryProtectionSystem.getCgLastCreatedTime();
_log.info(String.format("RP Placement : Attempting to use protection system [%s], which was last used to create a CG on [%s].", primaryProtectionSystem.getLabel(), cgLastCreated != null ? cgLastCreated.getTime().toString() : "N/A"));
// Get a list of associated storage systems for the pool, varray, and the protection system.
// This will return a list of strings that are in the format of:
// <storage system serial number>:<rp site name>
List<String> primaryAssociatedStorageSystems = getCandidateVisibleStorageSystems(sourcePool, primaryProtectionSystem, varray, activeProtectionVarrays, true);
if (primaryAssociatedStorageSystems.isEmpty()) {
// In this case no rp sites were connected to this storage system, we should not hit this,
// but just to be safe we'll catch it.
_log.info(String.format("RP Placement: Protection System %s does not have an rp site cluster connected to Storage pool %s ", primaryProtectionSystem.getLabel(), sourcePool.getLabel()));
continue;
}
// Iterate over the associated storage systems
for (String primaryAssociatedStorageSystem : primaryAssociatedStorageSystems) {
rpProtectionRecommendation.setProtectionDevice(primaryProtectionSystem.getId());
_log.info(String.format("RP Placement : Build MetroPoint Active Recommendation..."));
RPRecommendation sourceRec = buildSourceRecommendation(primaryAssociatedStorageSystem, varray, vpool, primaryProtectionSystem, sourcePool, capabilities, satisfiedSourceVolCount, placementStatus, vpoolChangeVolume, false);
if (sourceRec == null) {
// No source placement found for the primaryAssociatedStorageSystem, so continue.
_log.warn(String.format("RP Placement : Could not create MetroPoint Active Recommendation using [%s], continuing...", primaryAssociatedStorageSystem));
continue;
}
URI primarySourceStorageSystemURI = sourceRec.getVirtualVolumeRecommendation().getVPlexStorageSystem();
if (rpProtectionRecommendation.getSourceJournalRecommendation() == null) {
_log.info(String.format("RP Placement : Build MetroPoint Active Journal Recommendation..."));
RPRecommendation activeJournalRecommendation = buildJournalRecommendation(rpProtectionRecommendation, sourceRec.getInternalSiteName(), vpool.getJournalSize(), activeJournalVarray, activeJournalVpool, primaryProtectionSystem, capabilities, totalRequestedResourceCount, vpoolChangeVolume, false);
if (activeJournalRecommendation == null) {
// No source journal placement found, so continue.
_log.warn(String.format("RP Placement : Could not create MetroPoint Active Journal Recommendation, continuing..."));
continue;
}
rpProtectionRecommendation.setSourceJournalRecommendation(activeJournalRecommendation);
}
rpProtectionRecommendation.getSourceRecommendations().add(sourceRec);
_log.info("RP Placement : An RP source placement solution has been identified for the MetroPoint primary (active) cluster.");
// Find a solution, given this vpool, and the target varrays
if (findSolution(rpProtectionRecommendation, sourceRec, varray, vpool, activeProtectionVarrays, capabilities, satisfiedSourceVolCount, true, null, project)) {
_log.info("RP Placement : An RP target placement solution has been identified for the MetroPoint primary (active) cluster.");
// We have a primary cluster protection recommendation for the specified metroPointType. We need to now determine if
// we can protect the secondary cluster for the given metroPointType.
_log.info("RP Placement : Determining RP placement for the secondary (standby) MetroPoint cluster.");
secondaryRecommendationSolution = false;
// Get the candidate secondary cluster source pools - sets secondarySourcePoolURIs.
List<Recommendation> secondaryPoolsRecommendation = new ArrayList<Recommendation>();
if (isChangeVpool) {
secondaryPoolsRecommendation.add(changeVpoolStandbyRecommendation);
} else {
secondaryPoolsRecommendation = getRecommendedPools(rpProtectionRecommendation, haVarray, haVpool, null, null, capabilities, RPHelper.TARGET, null);
}
secondaryPlacementStatus.setSrcVArray(haVarray.getLabel());
secondaryPlacementStatus.setSrcVPool(haVpool.getLabel());
for (Recommendation secondaryPoolRecommendation : secondaryPoolsRecommendation) {
// Start with the top of the list of source pools, find a solution based on that.
StoragePool standbySourcePool = dbClient.queryObject(StoragePool.class, secondaryPoolRecommendation.getSourceStoragePool());
// Lookup source pool protection systems in the cache first.
if (standbyStoragePoolsToProtectionSystems.containsKey(standbySourcePool.getId())) {
secondaryProtectionSystems = standbyStoragePoolsToProtectionSystems.get(standbySourcePool.getId());
} else {
secondaryProtectionSystems = getProtectionSystemsForStoragePool(standbySourcePool, haVarray, true);
if (secondaryProtectionSystems.isEmpty()) {
continue;
}
// Cache the result for this pool
standbyStoragePoolsToProtectionSystems.put(standbySourcePool.getId(), secondaryProtectionSystems);
}
ProtectionSystem selectedSecondaryProtectionSystem = null;
// Ensure the we have a secondary protection system that matches the primary protection system
for (ProtectionSystem secondaryProtectionSystem : secondaryProtectionSystems) {
if (secondaryProtectionSystem.getId().equals(rpProtectionRecommendation.getProtectionDevice())) {
// We have a protection system match for this pool, continue.
selectedSecondaryProtectionSystem = secondaryProtectionSystem;
break;
}
}
if (selectedSecondaryProtectionSystem == null) {
// There is no protection system for this pool that matches the selected primary
// protection system. So lets try another pool.
_log.info(String.format("RP Placement: Secondary source storage pool %s " + " does not have connectivity to the selected primary protection system.", standbySourcePool.getLabel()));
continue;
} else {
// List of concatenated strings that contain the RP site + associated storage system.
List<String> secondaryAssociatedStorageSystems = getCandidateVisibleStorageSystems(standbySourcePool, selectedSecondaryProtectionSystem, haVarray, activeProtectionVarrays, true);
// make sure you check RP topology to see if the sites can protect that many targets
if (secondaryAssociatedStorageSystems.isEmpty()) {
// no rp site clusters connected to this storage system, should not hit this,
// but just to be safe we'll catch it
_log.info("RP Placement: Protection System " + selectedSecondaryProtectionSystem.getLabel() + " does not have an rp site cluster connected to Storage pool " + standbySourcePool.getLabel());
continue;
}
Set<String> validSecondaryAssociatedStorageSystems = new LinkedHashSet<String>();
// that reference the same storage system as the primary recommendation and has a different RP site.
for (String secondaryAssociatedStorageSystem : secondaryAssociatedStorageSystems) {
String secondarySourceInternalSiteName = ProtectionSystem.getAssociatedStorageSystemSiteName(secondaryAssociatedStorageSystem);
URI secondarySourceStorageSystemURI = ConnectivityUtil.findStorageSystemBySerialNumber(ProtectionSystem.getAssociatedStorageSystemSerialNumber(secondaryAssociatedStorageSystem), dbClient, StorageSystemType.BLOCK);
boolean validForStandbyPlacement = false;
if (secondarySourceStorageSystemURI.equals(primarySourceStorageSystemURI) && !secondarySourceInternalSiteName.equals(sourceRec.getInternalSiteName())) {
validForStandbyPlacement = true;
validSecondaryAssociatedStorageSystems.add(secondaryAssociatedStorageSystem);
}
_log.info(String.format("RP Placement: associated storage system entry [%s] " + "%s valid for standby placement.", secondaryAssociatedStorageSystem, (validForStandbyPlacement ? "" : "NOT")));
}
for (String secondaryAssociatedStorageSystem : validSecondaryAssociatedStorageSystems) {
_log.info(String.format("RP Placement : Build MetroPoint Standby Recommendation..."));
RPRecommendation secondaryRpRecommendation = buildSourceRecommendation(secondaryAssociatedStorageSystem, haVarray, haVpool, selectedSecondaryProtectionSystem, standbySourcePool, capabilities, satisfiedSourceVolCount, secondaryPlacementStatus, null, true);
if (secondaryRpRecommendation == null) {
// No standby placement found for the secondaryAssociatedStorageSystem, so continue.
_log.warn(String.format("RP Placement : Could not create MetroPoint Standby Recommendation using [%s], continuing...", secondaryAssociatedStorageSystem));
continue;
}
if (rpProtectionRecommendation.getStandbyJournalRecommendation() == null) {
_log.info(String.format("RP Placement : Build MetroPoint Standby Journal Recommendation..."));
RPRecommendation standbyJournalRecommendation = buildJournalRecommendation(rpProtectionRecommendation, secondaryRpRecommendation.getInternalSiteName(), vpool.getJournalSize(), standbyJournalVarray, standbyJournalVpool, primaryProtectionSystem, capabilities, totalRequestedResourceCount, vpoolChangeVolume, true);
if (standbyJournalRecommendation == null) {
// No standby journal placement found, so continue.
_log.warn(String.format("RP Placement : Could not create MetroPoint Standby Journal Recommendation, continuing..."));
continue;
}
rpProtectionRecommendation.setStandbyJournalRecommendation(standbyJournalRecommendation);
}
sourceRec.setHaRecommendation(secondaryRpRecommendation);
// Find a solution, given this vpool, and the target varrays
if (findSolution(rpProtectionRecommendation, secondaryRpRecommendation, haVarray, vpool, standbyProtectionVarrays, capabilities, satisfiedSourceVolCount, true, sourceRec, project)) {
_log.info("RP Placement : An RP target placement solution has been identified for the " + "MetroPoint secondary (standby) cluster.");
secondaryRecommendationSolution = true;
break;
} else {
_log.info("RP Placement : Unable to find a suitable solution, continuining to find other solutions.");
continue;
}
}
if (secondaryRecommendationSolution) {
break;
} else {
continue;
}
}
}
if (!secondaryRecommendationSolution) {
_log.info("RP Placement : Unable to find MetroPoint secondary cluster placement recommendation that " + "jives with primary cluster recommendation. Need to find a new primary recommendation.");
// Exhausted all the secondary pool URIs. Need to find another primary solution.
break;
}
// We are done - secondary recommendation found
requestedResourceCount = requestedResourceCount - satisfiedSourceVolCount;
totalSatisfiedCount += satisfiedSourceVolCount;
if (totalSatisfiedCount >= totalRequestedResourceCount) {
rpProtectionRecommendation.setResourceCount(totalSatisfiedCount);
// Check to ensure the protection system can handle the new resources about to come down
if (!verifyPlacement(primaryProtectionSystem, rpProtectionRecommendation, rpProtectionRecommendation.getResourceCount())) {
continue;
}
return rpProtectionRecommendation;
} else {
// loop back to the next pool
break;
}
} else {
// Not sure there's anything to do here. Just go to the next candidate protection system or Protection System
_log.info(String.format("RP Placement : Could not find a solution against protection system %s and internal " + "cluster name %s", primaryProtectionSystem.getLabel(), sourceRec.getInternalSiteName()));
rpProtectionRecommendation = getNewProtectionRecommendation(vpoolChangeVolume, vpool);
}
}
// end of for loop trying to find solution using possible rp cluster sites
rpProtectionRecommendation = getNewProtectionRecommendation(vpoolChangeVolume, vpool);
}
// end of protection systems for loop
}
// a solution
if ((remainingPossiblePrimarySrcPoolSolutions == 0) && totalSatisfiedCount < capabilities.getResourceCount()) {
_log.error("Could not find a MetroPoint placement solution. In a MetroPoint consistency group, there can " + "exist at most one remote copy and from zero to two local copies. If there is no remote copy, " + "there must be two local copies, one at each side of the VPLEX Metro.");
throw APIException.badRequests.cannotFindSolutionForRP(buildMetroProintPlacementStatusString());
}
_log.error("ViPR could not find matching target storage pools that could be protected via RecoverPoint");
_log.error("Could not find a MetroPoint placement solution. In a MetroPoint consistency group, there can " + "exist at most one remote copy and from zero to two local copies. If there is no remote copy, " + "there must be two local copies, one at each side of the VPLEX Metro.");
throw APIException.badRequests.cannotFindSolutionForRP(buildMetroProintPlacementStatusString());
}
use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method buildCgRecommendations.
/**
* Builds a recommendation from existing CG.
*
* This method is called when adding more volumes into an existing CG or change vpool scenario.
*
* When adding to an existing CG we can accommodate the request with the recommendations from
* resources that have already been placed in the existing CG.
*
* @param capabilities - Virtual Pool capabilities
* @param vpool - Virtual Pool
* @param protectionVarrays - List of target copy virtual arrays
* @param vpoolChangeVolume - change virtual pool volume
* @return - List of recommendations
*/
protected List<Recommendation> buildCgRecommendations(VirtualPoolCapabilityValuesWrapper capabilities, VirtualPool vpool, List<VirtualArray> protectionVarrays, Volume vpoolChangeVolume) {
BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
_log.info(String.format("Attempting to align placement (protection system, storage pools, internal site names) with " + "existing volumes in RecoverPoint consistency group %s.", cg.getLabel()));
List<Recommendation> recommendations = new ArrayList<Recommendation>();
// Find the first existing source volume
List<Volume> sourceVolumes = RPHelper.getCgSourceVolumes(cg.getId(), dbClient);
if (sourceVolumes.isEmpty()) {
_log.info(String.format("Unable to fully align placement with existing volumes in RecoverPoint consistency group %s. " + "The consistency group currently contains no volumes.", cg.getLabel()));
return recommendations;
}
// Verify that all the underlying protection storage pools used by the existing source volume are available to this request
if (!verifyExistingSourceProtectionPools(sourceVolumes.get(0), vpool, cg.getLabel())) {
return recommendations;
}
Volume sourceVolume = null;
boolean createRecommendations = false;
for (Volume currentSourceVolume : sourceVolumes) {
// enough capacity, use it to produce the recommendation.
if (cgPoolsHaveAvailableCapacity(currentSourceVolume, capabilities, vpool, protectionVarrays)) {
createRecommendations = true;
sourceVolume = currentSourceVolume;
break;
}
}
if (!createRecommendations) {
return recommendations;
}
RPProtectionRecommendation recommendation = new RPProtectionRecommendation();
if (sourceVolume.getProtectionController() != null) {
ProtectionSystem ps = dbClient.queryObject(ProtectionSystem.class, sourceVolume.getProtectionController());
if (ps.getInactive()) {
// be protected so we must fail.
throw APIException.badRequests.cgReferencesInvalidProtectionSystem(cg.getId(), sourceVolume.getProtectionController());
}
} else {
// be protected so we must fail.
throw APIException.badRequests.cgReferencesInvalidProtectionSystem(cg.getId(), sourceVolume.getProtectionController());
}
recommendation.setProtectionDevice(sourceVolume.getProtectionController());
recommendation.setVpoolChangeVolume(vpoolChangeVolume != null ? vpoolChangeVolume.getId() : null);
recommendation.setVpoolChangeNewVpool(vpoolChangeVolume != null ? vpool.getId() : null);
recommendation.setVpoolChangeProtectionAlreadyExists(vpoolChangeVolume != null ? vpoolChangeVolume.checkForRp() : false);
recommendation.setResourceCount(capabilities.getResourceCount());
// Check to see if we need an additional journal for Source
Map<Integer, Long> additionalJournalForSource = RPHelper.additionalJournalRequiredForRPCopy(vpool.getJournalSize(), cg.getId(), capabilities.getSize(), capabilities.getResourceCount(), sourceVolume.getRpCopyName(), dbClient);
if (!CollectionUtils.isEmpty(additionalJournalForSource)) {
// ACTIVE SOURCE JOURNAL Recommendation
List<Volume> sourceJournals = RPHelper.findExistingJournalsForCopy(dbClient, sourceVolume.getConsistencyGroup(), sourceVolume.getRpCopyName());
Volume sourceJournal = sourceJournals.get(0);
if (sourceJournal == null) {
_log.error(String.format("No existing source journal found in CG [%s] for copy [%s], returning false", sourceVolume.getConsistencyGroup(), sourceVolume.getRpCopyName()));
throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
}
VirtualPool sourceJournalVpool = NullColumnValueGetter.isNotNullValue(vpool.getJournalVpool()) ? dbClient.queryObject(VirtualPool.class, URI.create(vpool.getJournalVpool())) : vpool;
Long sourceJournalSize = getJournalCapabilities(vpool.getJournalSize(), capabilities, 1).getSize();
RPRecommendation sourceJournalRecommendation = buildRpRecommendationFromExistingVolume(sourceJournal, sourceJournalVpool, capabilities, sourceJournalSize);
// Parse out the calculated values
Map.Entry<Integer, Long> entry = additionalJournalForSource.entrySet().iterator().next();
Integer journalCount = entry.getKey();
Long journalSize = entry.getValue();
// Override values in recommendation with calculated journal count and size
sourceJournalRecommendation.setResourceCount(journalCount);
sourceJournalRecommendation.setSize(journalSize);
recommendation.setSourceJournalRecommendation(sourceJournalRecommendation);
// STANDBY SOURCE JOURNAL Recommendation
String standbyCopyName = RPHelper.getStandbyProductionCopyName(dbClient, sourceVolume);
if (standbyCopyName != null) {
List<Volume> existingStandbyJournals = RPHelper.findExistingJournalsForCopy(dbClient, sourceVolume.getConsistencyGroup(), standbyCopyName);
Volume standbyJournal = existingStandbyJournals.get(0);
if (standbyJournal == null) {
_log.error(String.format("No existing standby journal found in CG [%s] for copy [%s], returning false", sourceVolume.getConsistencyGroup(), standbyCopyName));
throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
}
VirtualPool haVpool = (null != VirtualPool.getHAVPool(vpool, dbClient)) ? VirtualPool.getHAVPool(vpool, dbClient) : vpool;
VirtualPool standbyJournalVpool = NullColumnValueGetter.isNotNullValue(vpool.getStandbyJournalVpool()) ? dbClient.queryObject(VirtualPool.class, URI.create(vpool.getStandbyJournalVpool())) : haVpool;
RPRecommendation standbyJournalRecommendation = buildRpRecommendationFromExistingVolume(standbyJournal, standbyJournalVpool, capabilities, sourceJournalSize);
// Override values in recommendation with calculated journal count and size
standbyJournalRecommendation.setResourceCount(journalCount);
standbyJournalRecommendation.setSize(journalSize);
recommendation.setStandbyJournalRecommendation(standbyJournalRecommendation);
}
}
// SOURCE Recommendation
RPRecommendation sourceRecommendation = buildRpRecommendationFromExistingVolume(sourceVolume, vpool, capabilities, null);
recommendation.getSourceRecommendations().add(sourceRecommendation);
// TARGET Recommendation(s)
Map<URI, VpoolProtectionVarraySettings> protectionSettings = VirtualPool.getProtectionSettings(vpool, dbClient);
for (VirtualArray protectionVarray : protectionVarrays) {
Volume targetVolume = getTargetVolumeForProtectionVirtualArray(sourceVolume, protectionVarray);
// if the target vpool is not set, it defaults to the source vpool
VirtualPool targetVpool = vpool;
if (protectionSettings.get(protectionVarray.getId()) != null && protectionSettings.get(protectionVarray.getId()).getVirtualPool() != null) {
targetVpool = dbClient.queryObject(VirtualPool.class, protectionSettings.get(protectionVarray.getId()).getVirtualPool());
}
RPRecommendation targetRecommendation = buildRpRecommendationFromExistingVolume(targetVolume, targetVpool, capabilities, null);
if (sourceRecommendation.getTargetRecommendations() == null) {
sourceRecommendation.setTargetRecommendations(new ArrayList<RPRecommendation>());
}
sourceRecommendation.getTargetRecommendations().add(targetRecommendation);
// Check to see if we need an additional journal for Target
Map<Integer, Long> additionalJournalForTarget = RPHelper.additionalJournalRequiredForRPCopy(vpool.getJournalSize(), cg.getId(), capabilities.getSize(), capabilities.getResourceCount(), targetVolume.getRpCopyName(), dbClient);
if (!CollectionUtils.isEmpty(additionalJournalForTarget)) {
// TARGET JOURNAL Recommendation
List<Volume> targetJournals = RPHelper.findExistingJournalsForCopy(dbClient, targetVolume.getConsistencyGroup(), targetVolume.getRpCopyName());
Volume targetJournal = targetJournals.get(0);
if (targetJournal == null) {
_log.error(String.format("No existing target journal found in CG [%s] for copy [%s], returning false", targetVolume.getConsistencyGroup(), targetVolume.getRpCopyName()));
throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
}
VirtualPool targetJournalVpool = protectionSettings.get(protectionVarray.getId()).getJournalVpool() != null ? dbClient.queryObject(VirtualPool.class, protectionSettings.get(protectionVarray.getId()).getJournalVpool()) : targetVpool;
Long targetJournalSize = getJournalCapabilities(protectionSettings.get(protectionVarray.getId()).getJournalSize(), capabilities, 1).getSize();
RPRecommendation targetJournalRecommendation = buildRpRecommendationFromExistingVolume(targetJournal, targetJournalVpool, capabilities, targetJournalSize);
// Parse out the calculated values
Map.Entry<Integer, Long> entry = additionalJournalForSource.entrySet().iterator().next();
Integer journalCount = entry.getKey();
Long journalSize = entry.getValue();
// Override values in recommendation with calculated journal count and size
targetJournalRecommendation.setResourceCount(journalCount);
targetJournalRecommendation.setSize(journalSize);
if (recommendation.getTargetJournalRecommendations() == null) {
recommendation.setTargetJournalRecommendations(new ArrayList<RPRecommendation>());
}
recommendation.getTargetJournalRecommendations().add(targetJournalRecommendation);
}
}
_log.info(String.format("Produced recommendations based on existing source volume [%s](%s) from " + "RecoverPoint consistency group [%s].", sourceVolume.getLabel(), sourceVolume.getId(), cg.getLabel()));
recommendations.add(recommendation);
return recommendations;
}
Aggregations