use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointSchedulerTest method fireProtectionPlacementRulesCDPNoCGAvailability.
@Test
public void fireProtectionPlacementRulesCDPNoCGAvailability() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, SecurityException, NoSuchMethodException {
ProtectionSystem ps = this.buildProtectionSystemNoCGAvailability();
RPProtectionRecommendation ppm1 = new RPProtectionRecommendation();
fillRecommendationObject(ppm1, ps, "1", "1", nh1, nh1, pool1, pool1, 1);
RPProtectionRecommendation ppm2 = new RPProtectionRecommendation();
fillRecommendationObject(ppm2, ps, "1", "1", nh1, nh1, pool1, pool2, 1);
RPProtectionRecommendation ppm3 = new RPProtectionRecommendation();
fillRecommendationObject(ppm3, ps, "1", "1", nh1, nh1, pool2, pool1, 1);
RPProtectionRecommendation ppm4 = new RPProtectionRecommendation();
fillRecommendationObject(ppm4, ps, "1", "1", nh1, nh1, pool2, pool2, 1);
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm1, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm2, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm3, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm4, 1));
}
use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointSchedulerTest method fireProtectionPlacementRulesCDPMixedProtectionSystems.
@Test
public void fireProtectionPlacementRulesCDPMixedProtectionSystems() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, SecurityException, NoSuchMethodException {
ProtectionSystem ps1 = this.buildProtectionSystemWithCapacity();
ProtectionSystem ps2 = this.buildProtectionSystemNoCGAvailability();
RPProtectionRecommendation ppm1 = new RPProtectionRecommendation();
fillRecommendationObject(ppm1, ps1, "1", "1", nh1, nh1, pool1, pool1, 1);
RPProtectionRecommendation ppm2 = new RPProtectionRecommendation();
fillRecommendationObject(ppm2, ps2, "1", "1", nh2, nh2, poolA, poolB, 1);
RPProtectionRecommendation ppm3 = new RPProtectionRecommendation();
fillRecommendationObject(ppm3, ps2, "1", "1", nh2, nh2, poolA, poolA, 1);
RPProtectionRecommendation ppm4 = new RPProtectionRecommendation();
fillRecommendationObject(ppm4, ps2, "1", "1", nh2, nh2, poolB, poolB, 1);
assertTrue(invokeFireProtectionPlacementRules(ps1, ppm1, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps2, ppm2, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps2, ppm3, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps2, ppm4, 1));
}
use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointSchedulerTest method fireProtectionPlacementRulesCLRSite1NoCapacityMultiVolumeTest.
@Test
public void fireProtectionPlacementRulesCLRSite1NoCapacityMultiVolumeTest() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, SecurityException, NoSuchMethodException {
ProtectionSystem ps = buildProtectionSystemWithCapacity();
// set the remote site vol capacity to 1 less than full.
ps.getSiteVolumeCount().remove("1");
ps.getSiteVolumeCount().put("1", "510");
RPProtectionRecommendation ppm1 = new RPProtectionRecommendation();
fillRecommendationObject(ppm1, ps, "1", "2", nh1, nh2, pool1, poolA, 1);
RPProtectionRecommendation ppm2 = new RPProtectionRecommendation();
fillRecommendationObject(ppm2, ps, "1", "2", nh1, nh2, pool1, poolB, 1);
RPProtectionRecommendation ppm3 = new RPProtectionRecommendation();
fillRecommendationObject(ppm3, ps, "1", "2", nh1, nh2, pool2, poolA, 2);
RPProtectionRecommendation ppm4 = new RPProtectionRecommendation();
fillRecommendationObject(ppm4, ps, "1", "2", nh1, nh2, pool3, poolB, 4);
assertTrue(invokeFireProtectionPlacementRules(ps, ppm1, 1));
assertTrue(invokeFireProtectionPlacementRules(ps, ppm2, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm3, 2));
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm4, 4));
}
use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointSchedulerTest method fireProtectionPlacementRulesCLRSite1NoCapacityTest.
@Test
public void fireProtectionPlacementRulesCLRSite1NoCapacityTest() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, SecurityException, NoSuchMethodException {
ProtectionSystem ps = buildProtectionSystemWithCapacity();
// set the remote site vol capacity to 1 less than full.
ps.getSiteVolumeCount().remove("1");
ps.getSiteVolumeCount().put("1", "510");
RPProtectionRecommendation ppm1 = new RPProtectionRecommendation();
fillRecommendationObject(ppm1, ps, "1", "2", nh1, nh2, pool1, poolA, 1);
RPProtectionRecommendation ppm2 = new RPProtectionRecommendation();
fillRecommendationObject(ppm2, ps, "1", "2", nh1, nh2, pool1, poolB, 1);
RPProtectionRecommendation ppm3 = new RPProtectionRecommendation();
fillRecommendationObject(ppm3, ps, "1", "2", nh1, nh2, pool2, poolA, 2);
RPProtectionRecommendation ppm4 = new RPProtectionRecommendation();
fillRecommendationObject(ppm4, ps, "1", "2", nh1, nh2, pool3, poolB, 4);
assertTrue(invokeFireProtectionPlacementRules(ps, ppm1, 1));
assertTrue(invokeFireProtectionPlacementRules(ps, ppm2, 1));
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm3, 2));
assertTrue(!invokeFireProtectionPlacementRules(ps, ppm4, 4));
}
use of com.emc.storageos.volumecontroller.RPProtectionRecommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method findSolution.
/**
* Placement method that assembles recommendation objects based on the vpool and protection varrays.
* Recursive: peels off one protectionVarray to hopefully assemble one Protection object within the recommendation object, then calls
* itself
* with the remainder of the protectionVarrays. If it fails to find a Protection for that protectionVarray, it returns failure and puts
* the
* protectionVarray back on the list.
*
* @param rpProtectionRecommendation - Top level RP recommendation
* @param sourceRecommendation - Source Recommendation against which we need to find the solution for targets
* @param varray - Source Virtual Array
* @param vpool - Source Virtual Pool
* @param targetVarrays - List of protection Virtual Arrays
* @param capabilities - Virtual Pool capabilities
* @param requestedCount - Resource count desired
* @param isMetroPoint - Boolean indicating whether this is MetroPoint
* @param activeSourceRecommendation - Primary Recommendation in case of MetroPoint. This field is null except for when we are finding
* solution for MP standby
* @param project - Project
* @return - True if protection solution was found, false otherwise.
*/
private boolean findSolution(RPProtectionRecommendation rpProtectionRecommendation, RPRecommendation sourceRecommendation, VirtualArray varray, VirtualPool vpool, List<VirtualArray> targetVarrays, VirtualPoolCapabilityValuesWrapper capabilities, int requestedCount, boolean isMetroPoint, RPRecommendation activeSourceRecommendation, Project project) {
if (targetVarrays.isEmpty()) {
_log.info("RP Placement : Could not find target solution because there are no protection virtual arrays specified.");
return false;
}
// Find the virtual pool that applies to this protection virtual array
// We are recursively calling into "findSolution", so pop the next protectionVarray off the top of the
// passed in list of protectionVarrays. This protectionVarray will be removed from the list before
// recursively calling back into the method (in the case that we do not find a solution).
VirtualArray targetVarray = targetVarrays.get(0);
placementStatus.getProcessedProtectionVArrays().put(targetVarray.getId(), true);
// Find the correct target vpool. It is either implicitly the same as the source vpool or has been
// explicitly set by the user.
VpoolProtectionVarraySettings protectionSettings = RPHelper.getProtectionSettings(vpool, targetVarray, dbClient);
// If there was no vpool specified with the protection settings, use the base vpool for this varray.
VirtualPool targetVpool = vpool;
if (protectionSettings.getVirtualPool() != null) {
targetVpool = dbClient.queryObject(VirtualPool.class, protectionSettings.getVirtualPool());
}
_log.info("RP Placement : Determining placement on protection varray : " + targetVarray.getLabel());
// Find matching pools for the protection varray
VirtualPoolCapabilityValuesWrapper newCapabilities = new VirtualPoolCapabilityValuesWrapper(capabilities);
newCapabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, requestedCount);
List<Recommendation> targetPoolRecommendations = new ArrayList<Recommendation>();
// If MP remote target is specified, fetch the target recommendation from the active when looking at the standby side.
if (isMetroPoint && activeSourceRecommendation != null && isMetroPointProtectionSpecified(activeSourceRecommendation, ProtectionType.REMOTE)) {
StringBuffer unusedTargets = new StringBuffer();
Recommendation targetPoolRecommendation = new Recommendation();
for (RPRecommendation targetRec : activeSourceRecommendation.getTargetRecommendations()) {
if (targetVarray.getId().equals(targetRec.getVirtualArray())) {
targetPoolRecommendation.setSourceStoragePool(targetRec.getSourceStoragePool());
targetPoolRecommendation.setSourceStorageSystem(targetRec.getSourceStorageSystem());
targetPoolRecommendations.add(targetPoolRecommendation);
break;
} else {
unusedTargets.append(targetRec.getVirtualArray().toString());
unusedTargets.append(" ");
}
}
// we need to kick out and continue on.
if (targetPoolRecommendations.isEmpty()) {
_log.warn(String.format("RP Placement : Could not find a MetroPoint CRR Solution because the" + " Active and Standby Copies could not find a common Target varray. " + "Active Target varrays [ %s] - Standby Target varray [ %s ]. " + "Reason: This might not be a MetroPoint CRR config. Please check the vpool config and " + "the RecoverPoint Protection System for the connectivity of the varrays.", unusedTargets.toString(), targetVarray.getId()));
return false;
}
} else {
// Get target pool recommendations. Each recommendation also specifies the resource
// count that the pool can satisfy based on the size requested.
targetPoolRecommendations = getRecommendedPools(rpProtectionRecommendation, targetVarray, targetVpool, null, null, newCapabilities, RPHelper.TARGET, null);
if (targetPoolRecommendations.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());
}
}
// Find the correct target journal varray. It is either implicitly the same as the target varray or has been
// explicitly set by the user.
VirtualArray targetJournalVarray = targetVarray;
if (!NullColumnValueGetter.isNullURI(protectionSettings.getJournalVarray())) {
targetJournalVarray = dbClient.queryObject(VirtualArray.class, protectionSettings.getJournalVarray());
}
// Find the correct target journal vpool. It is either implicitly the same as the target vpool or has been
// explicitly set by the user.
VirtualPool targetJournalVpool = targetVpool;
if (!NullColumnValueGetter.isNullURI(protectionSettings.getJournalVpool())) {
targetJournalVpool = dbClient.queryObject(VirtualPool.class, protectionSettings.getJournalVpool());
}
Iterator<Recommendation> targetPoolRecommendationsIter = targetPoolRecommendations.iterator();
while (targetPoolRecommendationsIter.hasNext()) {
Recommendation targetPoolRecommendation = targetPoolRecommendationsIter.next();
StoragePool candidateTargetPool = dbClient.queryObject(StoragePool.class, targetPoolRecommendation.getSourceStoragePool());
List<String> associatedStorageSystems = getCandidateTargetVisibleStorageSystems(rpProtectionRecommendation.getProtectionDevice(), targetVarray, sourceRecommendation.getInternalSiteName(), candidateTargetPool, VirtualPool.vPoolSpecifiesHighAvailability(targetVpool));
if (associatedStorageSystems.isEmpty()) {
_log.info(String.format("RP Placement : Solution cannot be found using target pool %s" + " there is no connectivity to rp cluster sites.", candidateTargetPool.getLabel()));
continue;
}
// We want to find an internal site name that isn't already in the solution
for (String associatedStorageSystem : associatedStorageSystems) {
String targetInternalSiteName = ProtectionSystem.getAssociatedStorageSystemSiteName(associatedStorageSystem);
URI targetStorageSystemURI = ConnectivityUtil.findStorageSystemBySerialNumber(ProtectionSystem.getAssociatedStorageSystemSerialNumber(associatedStorageSystem), dbClient, StorageSystemType.BLOCK);
ProtectionType protectionType = null;
if (!sourceRecommendation.containsTargetInternalSiteName(targetInternalSiteName)) {
// MetroPoint has been specified so process the MetroPoint targets accordingly.
if (isMetroPoint) {
if (targetInternalSiteName.equals(sourceRecommendation.getInternalSiteName())) {
// A local protection candidate.
if (isMetroPointProtectionSpecified(sourceRecommendation, ProtectionType.LOCAL)) {
// so continue onto the next candidate RP site.
continue;
}
// Add the local protection
protectionType = ProtectionType.LOCAL;
} else {
if (isMetroPointProtectionSpecified(sourceRecommendation, ProtectionType.REMOTE)) {
// candidate RP site.
continue;
} else {
if (activeSourceRecommendation != null) {
String primaryTargetInternalSiteName = getMetroPointRemoteTargetRPSite(rpProtectionRecommendation);
if (primaryTargetInternalSiteName != null && !targetInternalSiteName.equals(primaryTargetInternalSiteName)) {
// site but the same as the primary target site.
continue;
}
}
// Add the remote protection
protectionType = ProtectionType.REMOTE;
}
}
}
}
// Check to make sure the RP site is connected to the varray
URI protectionSystemURI = rpProtectionRecommendation.getProtectionDevice();
if (!isRpSiteConnectedToVarray(targetStorageSystemURI, protectionSystemURI, targetInternalSiteName, targetVarray)) {
_log.info(String.format("RP Placement: Disqualified RP site [%s] because its initiators are not in a network " + "configured for use by the virtual array [%s]", targetInternalSiteName, targetVarray.getLabel()));
continue;
}
// Maybe make a topology check in here? Or is the source topology check enough?
StorageSystem targetStorageSystem = dbClient.queryObject(StorageSystem.class, targetStorageSystemURI);
ProtectionSystem ps = dbClient.queryObject(ProtectionSystem.class, protectionSystemURI);
String rpSiteName = (ps.getRpSiteNames() != null) ? ps.getRpSiteNames().get(targetInternalSiteName) : "";
_log.info(String.format("RP Placement : Choosing RP Site %s (%s) for target on varray [%s](%s)", rpSiteName, targetInternalSiteName, targetVarray.getLabel(), targetVarray.getId()));
// Construct the target recommendation object
_log.info(String.format("RP Placement : Build RP Target Recommendation..."));
RPRecommendation targetRecommendation = buildRpRecommendation(associatedStorageSystem, targetVarray, targetVpool, candidateTargetPool, newCapabilities, requestedCount, targetInternalSiteName, targetStorageSystemURI, targetStorageSystem.getSystemType(), ps);
if (targetRecommendation == null) {
// No Target Recommendation found, so continue.
_log.warn(String.format("RP Placement : Could not create Target Recommendation using [%s], continuing...", associatedStorageSystem));
continue;
}
_log.info(String.format("RP Placement : RP Target Recommendation %s %n", targetRecommendation.toString(dbClient, ps, 1)));
if (protectionType != null) {
targetRecommendation.setProtectionType(protectionType);
}
// First Determine if journal recommendation need to be computed. It might have already been done.
boolean isJournalPlacedForVarray = false;
for (RPRecommendation targetJournalRec : rpProtectionRecommendation.getTargetJournalRecommendations()) {
if (targetJournalRec.getVirtualArray().equals(targetJournalVarray.getId())) {
isJournalPlacedForVarray = true;
}
}
// Build the target journal recommendation
if (!isJournalPlacedForVarray) {
_log.info(String.format("RP Placement : Build RP Target Journal Recommendation..."));
RPRecommendation targetJournalRecommendation = buildJournalRecommendation(rpProtectionRecommendation, targetInternalSiteName, protectionSettings.getJournalSize(), targetJournalVarray, targetJournalVpool, ps, newCapabilities, capabilities.getResourceCount(), null, false);
if (targetJournalRecommendation == null) {
// No Target Journal Recommendation found, so continue.
_log.warn(String.format("RP Placement : Could not create Target Journal Recommendation using [%s], continuing...", associatedStorageSystem));
continue;
}
_log.info(String.format("RP Placement : RP Target Journal Recommendation %s %n", targetJournalRecommendation.toString(dbClient, ps, 1)));
rpProtectionRecommendation.getTargetJournalRecommendations().add(targetJournalRecommendation);
} else {
_log.info(String.format("RP Placement : RP Target Journal already placed."));
}
// the Target Recommendation.
if (sourceRecommendation.getTargetRecommendations() == null) {
sourceRecommendation.setTargetRecommendations(new ArrayList<RPRecommendation>());
}
sourceRecommendation.getTargetRecommendations().add(targetRecommendation);
// Set the placement status to reference either the primary or secondary.
PlacementStatus tmpPlacementStatus = placementStatus;
if (activeSourceRecommendation != null) {
tmpPlacementStatus = secondaryPlacementStatus;
}
// At this point we have found a target storage pool accessible to the protection vPool and protection vArray
// that can be protected by an rp cluster site that is part of the same rp system that can protect the source storage pool
rpProtectionRecommendation.setPlacementStepsCompleted(PlacementProgress.IDENTIFIED_SOLUTION_FOR_SUBSET_OF_TARGETS);
if (tmpPlacementStatus.isBestSolutionToDate(rpProtectionRecommendation)) {
tmpPlacementStatus.setLatestInvalidRecommendation(rpProtectionRecommendation);
}
if (isMetroPoint) {
if (rpProtectionRecommendation.getSourceRecommendations() != null && getProtectionVarrays(rpProtectionRecommendation).size() == targetVarrays.size()) {
finalizeTargetPlacement(rpProtectionRecommendation, tmpPlacementStatus);
return true;
}
} else if (targetVarrays.size() == 1) {
finalizeTargetPlacement(rpProtectionRecommendation, tmpPlacementStatus);
return true;
}
// Find a solution based on this recommendation object and the remaining target arrays
// Make a new protection varray list
List<VirtualArray> remainingVarrays = new ArrayList<VirtualArray>();
remainingVarrays.addAll(targetVarrays);
remainingVarrays.remove(targetVarray);
if (!remainingVarrays.isEmpty()) {
_log.info("RP placement: Calling find solution on the next virtual array : " + remainingVarrays.get(0).getLabel() + " Current virtual array: " + targetVarray.getLabel());
} else {
_log.info("RP Placement : Solution cannot be found, will try again with different pool combination");
return false;
}
if (!this.findSolution(rpProtectionRecommendation, sourceRecommendation, varray, vpool, remainingVarrays, newCapabilities, requestedCount, isMetroPoint, activeSourceRecommendation, project)) {
// Remove the current recommendation and try the next site name, pool, etc.
_log.info("RP Placement: Solution for remaining virtual arrays couldn't be found. " + "Trying different solution (if available) for varray: " + targetVarray.getLabel());
} else {
// We found a good solution
_log.info("RP Placement: Solution for remaining virtual arrays was found. Returning to caller. Virtual Array : " + targetVarray.getLabel());
return true;
}
}
}
// If we get here, the recommendation object never got a new protection object, and we just return false,
// which will move onto the next possibility (in the case of a recursive call)
_log.info("RP Placement : Solution cannot be found, will try again with different pool combination");
return false;
}
Aggregations