use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RPCommunicationInterface method discoverRPSiteArrays.
@SuppressWarnings("unchecked")
private void discoverRPSiteArrays(ProtectionSystem rpSystem) throws RecoverPointCollectionException {
_log.info("BEGIN RecoverPointProtection.discoveryProtectionSystem()");
// Retrieve the storage device info from the database.
ProtectionSystem storageObj = rpSystem;
// Wait for any storage system discovery to complete
waitForStorageSystemDiscovery();
// Get the rp system's array mappings from the RP client
BiosCommandResult result = getRPArrayMappings(storageObj);
_log.info(String.format("discoverProtectionSystem(): after rpa array mappings with result: [%s] ", result.getCommandStatus()));
RPSiteArray rpSiteArray = null;
if (result.getCommandSuccess()) {
// Current implementation:
// 1. Clear out any of its entries regarding associations
// 2. For each RPSite object, there is an associated RP storage system
// 3. Find the storage system in the database
// 4. Fill in associations
List<URI> ids = _dbClient.queryByType(RPSiteArray.class, true);
for (URI id : ids) {
_log.info("discoverProtectionSystem(): reading RPSiteArray: " + id.toASCIIString());
rpSiteArray = _dbClient.queryObject(RPSiteArray.class, id);
if (rpSiteArray == null) {
continue;
}
if ((rpSiteArray.getRpProtectionSystem() != null) && (rpSiteArray.getRpProtectionSystem().equals(storageObj.getId()))) {
_log.info(String.format("discoverProtectionSystem(): removing RPSiteArray[%s](%s) " + "entry for Storage System [%s].", rpSiteArray.getLabel(), rpSiteArray.getId().toASCIIString(), rpSiteArray.getArraySerialNumber()));
_dbClient.markForDeletion(rpSiteArray);
} else if (rpSiteArray.getRpProtectionSystem() == null) {
_log.error("RPSiteArray " + id.toASCIIString() + " does not have a parent assigned, therefore it is an orphan.");
}
}
// Store any unmatched WWNs for logging purposes
StringBuffer unmatchedWWNs = new StringBuffer();
// Map the information from the RP client to information in our database
for (SiteArrays siteArray : (List<SiteArrays>) result.getObjectList().get(0)) {
for (String wwn : siteArray.getArrays()) {
// Find the array that corresponds to the wwn endpoint we found
URIQueryResultList storagePortList = new URIQueryResultList();
StoragePort storagePort = null;
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(WwnUtils.convertWWN(wwn, WwnUtils.FORMAT.COLON)), storagePortList);
List<URI> storagePortURIs = new ArrayList<URI>();
for (URI uri : storagePortList) {
storagePort = _dbClient.queryObject(StoragePort.class, uri);
if (storagePort != null && !storagePort.getInactive() && storagePort.getRegistrationStatus().equals(RegistrationStatus.REGISTERED.name())) {
// ignore cinder managed storage system's port
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storagePort.getStorageDevice());
if (!DiscoveredDataObject.Type.openstack.name().equals(system.getSystemType())) {
storagePortURIs.add(uri);
}
}
}
if (!storagePortURIs.isEmpty()) {
storagePort = _dbClient.queryObject(StoragePort.class, storagePortURIs).get(0);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storagePort.getStorageDevice());
rpSiteArray = new RPSiteArray();
rpSiteArray.setInactive(false);
rpSiteArray.setLabel(siteArray.getSite().getSiteName() + ":" + wwn);
rpSiteArray.setRpProtectionSystem(storageObj.getId());
rpSiteArray.setStorageSystem(storagePort.getStorageDevice());
rpSiteArray.setArraySerialNumber(storageSystem.getSerialNumber());
rpSiteArray.setRpInternalSiteName(siteArray.getSite().getInternalSiteName());
rpSiteArray.setRpSiteName(siteArray.getSite().getSiteName());
rpSiteArray.setId(URIUtil.createId(RPSiteArray.class));
_log.info(String.format("discoverProtectionSystem(): adding RPSiteArray[%s](%s) " + "entry for Storage System [%s].", rpSiteArray.getLabel(), rpSiteArray.getId().toASCIIString(), rpSiteArray.getArraySerialNumber()));
_dbClient.createObject(rpSiteArray);
} else {
unmatchedWWNs.append("\n" + wwn);
}
}
}
if (!StringUtils.isEmpty(unmatchedWWNs.toString())) {
_log.warn(String.format("Discovery of RecoverPoint Protection System [%s](%s) found the following endpoints, however " + "they could not be aligned with existing configured arrays. Note this is not an error and that some could be Host " + "endpoints but please ensure all arrays are registered before registering/running discovery of " + "RecoverPoint: [%s]", rpSystem.getLabel(), rpSystem.getId(), unmatchedWWNs));
}
} else {
_log.warn(String.format("RPA array mappings did not return a successful result, " + "please check network connectivity for RecoverPoint Protection System [%s](%s)."), rpSystem.getLabel(), rpSystem.getId());
}
_log.info("END RecoverPointProtection.discoveryProtectionSystem()");
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RPInsertion method injectColumnsDetails.
@Override
public void injectColumnsDetails(Stat statObj, DbClient client) throws Exception {
ProtectionSystem protectionObj = client.queryObject(ProtectionSystem.class, statObj.getResourceId());
// Given a protection system, find a volume protected by this protection system,
// and then extract the project and vpool
Volume protectedVolume = null;
URIQueryResultList resultList = new URIQueryResultList();
client.queryByConstraint(ContainmentConstraint.Factory.getProtectionSystemVolumesConstraint(protectionObj.getId()), resultList);
for (Iterator<URI> volumeItr = resultList.iterator(); volumeItr.hasNext(); ) {
Volume volume = client.queryObject(Volume.class, volumeItr.next());
if (volume.getProtectionController().equals(protectionObj.getId())) {
protectedVolume = volume;
break;
}
}
if (protectedVolume != null) {
_logger.info("Found volume " + protectedVolume.getWWN() + " protected by this protection controller. Get the Cos/Project/Tenant.");
statObj.setProject(protectedVolume.getProject().getURI());
statObj.setVirtualPool(protectedVolume.getVirtualPool());
statObj.setTenant(protectedVolume.getTenant().getURI());
} else {
statObj.setProject(null);
statObj.setVirtualPool(null);
statObj.setTenant(null);
throw new SMIPluginException("Cassandra Database Insertion Error. Cannot identify Project/CoS/Tenant for ProtectionSystem", -1);
}
}
use of com.emc.storageos.db.client.model.ProtectionSystem 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;
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method scheduleStorageSourcePoolConstraint.
/**
* Schedule storage based on the incoming storage pools for source volumes. (New version)
*
* @param varray varray requested for source
* @param protectionVarrays Neighborhood to protect this volume to.
* @param vpool vpool requested
* @param capabilities parameters
* @param candidatePools List of StoragePools already populated to choose from. RP+VPLEX.
* @param vpoolChangeVolume vpool change volume, if applicable
* @param preSelectedCandidateProtectionPoolsMap pre-populated map for tgt varray to storage pools, use null if not needed
* @return list of Recommendation objects to satisfy the request
*/
protected List<Recommendation> scheduleStorageSourcePoolConstraint(VirtualArray varray, List<VirtualArray> protectionVarrays, VirtualPool vpool, VirtualPoolCapabilityValuesWrapper capabilities, List<StoragePool> candidatePools, Project project, Volume vpoolChangeVolume, Map<VirtualArray, List<StoragePool>> preSelectedCandidateProtectionPoolsMap) {
// Initialize a list of recommendations to be returned.
List<Recommendation> recommendations = new ArrayList<Recommendation>();
String candidateSourceInternalSiteName = "";
placementStatus = new PlacementStatus();
// Attempt to use these pools for selection based on protection
StringBuffer sb = new StringBuffer("Determining if protection is possible from " + varray.getId() + " to: ");
for (VirtualArray protectionVarray : protectionVarrays) {
sb.append(protectionVarray.getId()).append(" ");
}
_log.info(sb.toString());
// BEGIN: Put the local varray first in the list. We want to give him pick of internal site name.
int index = -1;
for (VirtualArray targetVarray : protectionVarrays) {
if (targetVarray.getId().equals(varray.getId())) {
index = protectionVarrays.indexOf(targetVarray);
break;
}
}
if (index > 0) {
VirtualArray localVarray = protectionVarrays.get(index);
VirtualArray swapVarray = protectionVarrays.get(0);
protectionVarrays.set(0, localVarray);
protectionVarrays.set(index, swapVarray);
}
// END: Put the local varray first in the list. We want to give him pick of internal site name.
List<URI> protectionVarrayURIs = new ArrayList<URI>();
for (VirtualArray vArray : protectionVarrays) {
protectionVarrayURIs.add(vArray.getId());
placementStatus.getProcessedProtectionVArrays().put(vArray.getId(), false);
}
// Fetch the list of pools for the source journal if a journal virtual pool is specified to be used for journal volumes.
VirtualArray journalVarray = varray;
if (NullColumnValueGetter.isNotNullValue(vpool.getJournalVarray())) {
journalVarray = dbClient.queryObject(VirtualArray.class, URI.create(vpool.getJournalVarray()));
}
VirtualPool journalVpool = vpool;
if (NullColumnValueGetter.isNotNullValue(vpool.getJournalVpool())) {
journalVpool = dbClient.queryObject(VirtualPool.class, URI.create(vpool.getJournalVpool()));
}
// The attributes below will not change throughout the placement process
placementStatus.setSrcVArray(varray.getLabel());
placementStatus.setSrcVPool(vpool.getLabel());
BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
int totalRequestedCount = capabilities.getResourceCount();
int totalSatisfiedCount = 0;
int requestedCount = totalRequestedCount;
int satisfiedCount = 0;
boolean isChangeVpool = (vpoolChangeVolume != null);
RPProtectionRecommendation rpProtectionRecommendation = new RPProtectionRecommendation();
rpProtectionRecommendation.setVpoolChangeVolume(vpoolChangeVolume != null ? vpoolChangeVolume.getId() : null);
rpProtectionRecommendation.setVpoolChangeNewVpool(vpoolChangeVolume != null ? vpool.getId() : null);
rpProtectionRecommendation.setVpoolChangeProtectionAlreadyExists(vpoolChangeVolume != null ? vpoolChangeVolume.checkForRp() : false);
List<Recommendation> sourcePoolRecommendations = new ArrayList<Recommendation>();
if (isChangeVpool) {
Recommendation changeVpoolSourceRecommendation = new Recommendation();
URI existingStoragePoolId = null;
// valid source pool, the existing one. Get that pool and add it to the list.
if (RPHelper.isVPlexVolume(vpoolChangeVolume, dbClient)) {
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())) {
existingStoragePoolId = assocVol.getPool();
break;
}
}
} else {
existingStoragePoolId = vpoolChangeVolume.getPool();
}
// This is the existing active source backing volume
changeVpoolSourceRecommendation.setSourceStoragePool(existingStoragePoolId);
StoragePool pool = dbClient.queryObject(StoragePool.class, existingStoragePoolId);
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 {
// Recommendation analysis:
// Each recommendation returned will indicate the number of resources of specified size that it can accommodate in ascending order.
// Go through each recommendation, map to storage system from the recommendation to find connectivity
// If we get through the process and couldn't achieve full protection, we should try with the next pool in the list until
// we either find a successful solution or failure.
sourcePoolRecommendations = getRecommendedPools(rpProtectionRecommendation, varray, vpool, null, null, capabilities, RPHelper.SOURCE, null);
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());
}
}
for (Recommendation sourcePoolRecommendation : sourcePoolRecommendations) {
satisfiedCount = ((sourcePoolRecommendation.getResourceCount()) >= requestedCount) ? requestedCount : sourcePoolRecommendation.getResourceCount();
_log.info("Looking to place " + satisfiedCount + " resources...");
// Start with the top of the list of source pools, find a solution based on that.
// Given the candidatePools.get(0), what protection systems and internal sites protect it?
Set<ProtectionSystem> protectionSystems = new HashSet<ProtectionSystem>();
ProtectionSystem cgProtectionSystem = getCgProtectionSystem(capabilities.getBlockConsistencyGroup());
StoragePool sourcePool = dbClient.queryObject(StoragePool.class, sourcePoolRecommendation.getSourceStoragePool());
// used by other volumes in it.
if (cgProtectionSystem != null) {
_log.info(String.format("RP Placement : Narrowing down placement to use ProtectionSystem %s, " + "which is currently used by RecoverPoint consistency group %s.", cgProtectionSystem.getLabel(), cg));
protectionSystems.add(cgProtectionSystem);
} else {
protectionSystems = getProtectionSystemsForStoragePool(sourcePool, varray, VirtualPool.vPoolSpecifiesHighAvailability(vpool));
// Verify that the candidate pool can be protected
if (protectionSystems.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> protectionSystemsLst = sortProtectionSystems(protectionSystems);
for (ProtectionSystem candidateProtectionSystem : protectionSystemsLst) {
Calendar cgLastCreated = candidateProtectionSystem.getCgLastCreatedTime();
_log.info(String.format("RP Placement : Attempting to use ProtectionSystem %s, which was last used to create a CG on %s.", candidateProtectionSystem.getLabel(), cgLastCreated != null ? cgLastCreated.getTime().toString() : "N/A"));
List<String> associatedStorageSystems = new ArrayList<String>();
String internalSiteNameandAssocStorageSystem = getCgSourceInternalSiteNameAndAssociatedStorageSystem(capabilities.getBlockConsistencyGroup());
// source internal site.
if (internalSiteNameandAssocStorageSystem != null) {
_log.info(String.format("RP Placement : Narrowing down placement to use internal site %s for source, " + "which is currently used by RecoverPoint consistency group %s.", internalSiteNameandAssocStorageSystem, cg));
associatedStorageSystems.add(internalSiteNameandAssocStorageSystem);
} else {
associatedStorageSystems = getCandidateVisibleStorageSystems(sourcePool, candidateProtectionSystem, varray, protectionVarrays, VirtualPool.vPoolSpecifiesHighAvailability(vpool));
}
// make sure you check RP topology to see if the sites can protect that many targets
if (associatedStorageSystems.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(String.format("RP Placement: Protection System %s does not have an RP internal site connected to Storage pool %s ", candidateProtectionSystem.getLabel(), sourcePool.getLabel()));
continue;
}
for (String associatedStorageSystem : associatedStorageSystems) {
_log.info(String.format("RP Placement : Attempting to find solution using StorageSystem : %s for RP source", associatedStorageSystem));
rpProtectionRecommendation.setProtectionDevice(candidateProtectionSystem.getId());
_log.info(String.format("RP Placement : Build RP Source Recommendation..."));
RPRecommendation rpSourceRecommendation = buildSourceRecommendation(associatedStorageSystem, varray, vpool, candidateProtectionSystem, sourcePool, capabilities, satisfiedCount, placementStatus, vpoolChangeVolume, false);
if (rpSourceRecommendation == null) {
// No placement found for the associatedStorageSystem, so continue.
_log.warn(String.format("RP Placement : Could not create Source Recommendation using [%s], continuing...", associatedStorageSystem));
continue;
}
candidateSourceInternalSiteName = rpSourceRecommendation.getInternalSiteName();
String siteName = candidateProtectionSystem.getRpSiteNames().get(candidateSourceInternalSiteName);
_log.info(String.format("RP Placement : Choosing RP internal site %s %s for source", siteName, candidateSourceInternalSiteName));
// Build the HA recommendation if HA is specified
VirtualPoolCapabilityValuesWrapper haCapabilities = new VirtualPoolCapabilityValuesWrapper(capabilities);
haCapabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, satisfiedCount);
RPRecommendation haRecommendation = this.getHaRecommendation(varray, vpool, project, haCapabilities);
if (haRecommendation != null) {
rpSourceRecommendation.setHaRecommendation(haRecommendation);
}
// Build Source Journal Recommendation
RPRecommendation sourceJournalRecommendation = null;
if (rpProtectionRecommendation.getSourceJournalRecommendation() == null) {
_log.info(String.format("RP Placement : Build RP Source Journal Recommendation..."));
sourceJournalRecommendation = buildJournalRecommendation(rpProtectionRecommendation, candidateSourceInternalSiteName, vpool.getJournalSize(), journalVarray, journalVpool, candidateProtectionSystem, capabilities, totalRequestedCount, vpoolChangeVolume, false);
if (sourceJournalRecommendation == null) {
_log.warn(String.format("RP Placement : Could not create Source Journal Recommendation using [%s], continuing...", associatedStorageSystem));
continue;
}
}
rpProtectionRecommendation.getSourceRecommendations().add(rpSourceRecommendation);
rpProtectionRecommendation.setSourceJournalRecommendation(sourceJournalRecommendation);
// If we made it this far we know that our source virtual pool and associated source virtual array
// has a storage pool with enough capacity for the requested resources and which is accessible to an rp
// cluster site
rpProtectionRecommendation.setPlacementStepsCompleted(PlacementProgress.IDENTIFIED_SOLUTION_FOR_SOURCE);
if (placementStatus.isBestSolutionToDate(rpProtectionRecommendation)) {
placementStatus.setLatestInvalidRecommendation(rpProtectionRecommendation);
}
// TODO Joe: need this when we are creating multiple recommendations
placementStatus.setLatestInvalidRecommendation(null);
// Find a solution, given this vpool, and the target varrays
if (findSolution(rpProtectionRecommendation, rpSourceRecommendation, varray, vpool, protectionVarrays, capabilities, satisfiedCount, false, null, project)) {
// Found Source, Source Journal, Target, Target Journals...we're good to go.
totalSatisfiedCount += satisfiedCount;
requestedCount = requestedCount - totalSatisfiedCount;
if ((totalSatisfiedCount >= totalRequestedCount)) {
// Check to ensure the protection system can handle the new resources about to come down
if (!verifyPlacement(candidateProtectionSystem, rpProtectionRecommendation, rpProtectionRecommendation.getResourceCount())) {
// Did not pass placement verification, back out and try again...
rpProtectionRecommendation.getSourceRecommendations().remove(rpSourceRecommendation);
rpProtectionRecommendation.setSourceJournalRecommendation(null);
_log.warn(String.format("RP Placement : Placement could not be verified with " + "current resources, trying placement again...", associatedStorageSystem));
continue;
}
rpProtectionRecommendation.setResourceCount(totalSatisfiedCount);
recommendations.add(rpProtectionRecommendation);
return recommendations;
} else {
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 ProtectionSystem %s " + "and internal site %s", candidateProtectionSystem.getLabel(), candidateSourceInternalSiteName));
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
}
// we went through all the candidate pools and there are still some of the volumes that haven't been placed, then we failed to find
// a solution
_log.error("RP Placement : ViPR could not find matching storage pools that could be protected via RecoverPoint");
throw APIException.badRequests.cannotFindSolutionForRP(placementStatus.toString(dbClient));
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method protectionSystemsToString.
/**
* Convenience method to create a String of protection system labels/CG last created
* time stamps.
*
* @param protectionSystems The Collection of protection systems to create a String from.
* @return the String representation of the protection system Collection.
*/
private String protectionSystemsToString(Collection<ProtectionSystem> protectionSystems) {
List<String> temp = new ArrayList<String>();
StringBuffer buff = new StringBuffer();
for (ProtectionSystem ps : protectionSystems) {
buff.append(ps.getLabel());
buff.append(":");
buff.append(ps.getCgLastCreatedTime() != null ? ps.getCgLastCreatedTime().getTime().toString() : "No CGs created");
temp.add(buff.toString());
buff.delete(0, buff.length());
}
return StringUtils.join(temp, ", ");
}
Aggregations