use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method createMetroPointRecommendations.
/**
* Creates recommendations for MetroPoint. This consists of single recommendations that include
* the both the primary and secondary HA clusters and their associated RP protection details.
*
* @param srcVarray the source virtual array.
* @param tgtVarrays the target protection virtual arrays.
* @param srcVpool the source virtual pool.
* @param haVarray the HA (second cluster) virtual array.
* @param haVpool the HA (second cluster) virtual array.
* @param project the project.
* @param capabilities the capability params.
* @param candidatePrimaryPools candidate source pools to use for the primary cluster.
* @param candidateSecondaryPools candidate source pools to use for the primary cluster.
* @return list of Recommendation objects to satisfy the request
*/
private List<Recommendation> createMetroPointRecommendations(VirtualArray srcVarray, List<VirtualArray> tgtVarrays, VirtualPool srcVpool, VirtualArray haVarray, VirtualPool haVpool, Project project, VirtualPoolCapabilityValuesWrapper capabilities, List<StoragePool> candidatePrimaryPools, List<StoragePool> candidateSecondaryPools, Volume vpoolChangeVolume) {
// Initialize a list of recommendations to be returned.
List<Recommendation> recommendations = new ArrayList<Recommendation>();
RPProtectionRecommendation rpProtectionRecommendaton = null;
// Get all the matching pools for each target virtual array. If the target varray's
// vpool specifies HA, we will only look for VPLEX connected storage pools.
Map<VirtualArray, List<StoragePool>> tgtVarrayStoragePoolsMap = getVplexTargetMatchingPools(tgtVarrays, srcVpool, project, capabilities, vpoolChangeVolume);
rpProtectionRecommendaton = createRPProtectionRecommendationForMetroPoint(srcVarray, tgtVarrays, srcVpool, haVarray, haVpool, capabilities, candidatePrimaryPools, candidateSecondaryPools, tgtVarrayStoragePoolsMap, vpoolChangeVolume, project);
_log.info(String.format("Produced %s recommendations for MetroPoint placement.", rpProtectionRecommendaton.getResourceCount()));
recommendations.add(rpProtectionRecommendaton);
return recommendations;
}
use of com.emc.storageos.volumecontroller.Recommendation 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.Recommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method placeAlreadyRecommendedPool.
/**
* Checks if existing recommendations for pools can satisfy requested resource count in addition to what it already satisfies.
*
* @param sizeInBytes - Size requested in bytes
* @param requestedCount - Resource count requested
* @param sizeInKB - Size in KB
* @param recs - Existing recommendations
* @return List of recommendations that can satisfy already satisfied count # of resources plus new count
*/
private List<Recommendation> placeAlreadyRecommendedPool(long sizeInBytes, long requestedCount, long sizeInKB, List<RPRecommendation> recs) {
List<Recommendation> recommendations = new ArrayList<Recommendation>();
StringBuffer buff = new StringBuffer();
for (Recommendation rec : recs) {
StoragePool existingTargetPool = dbClient.queryObject(StoragePool.class, rec.getSourceStoragePool());
int count = Math.abs((int) (existingTargetPool.getFreeCapacity() / (sizeInKB)));
buff.append(String.format("%nRP Placement (Already placed) : # of resources of size %sGB that pool %s can accomodate: %d", SizeUtil.translateSize(sizeInBytes, SizeUtil.SIZE_GB).toString(), existingTargetPool.getLabel(), count));
if (count >= requestedCount + rec.getResourceCount()) {
recommendations.add(rec);
}
}
_log.info(buff.toString());
return recommendations;
}
use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method printPoolRecommendations.
/**
* Display storage pool information from recommendation
*
* @param poolRecommendations Sorted Storage Pools
*/
private void printPoolRecommendations(List<Recommendation> poolRecommendations) {
StringBuffer buf = new StringBuffer();
buf.append(String.format("%n Recommended Pools: %n"));
for (Recommendation poolRec : poolRecommendations) {
StoragePool pool = dbClient.queryObject(StoragePool.class, poolRec.getSourceStoragePool());
buf.append(String.format("Storage Pool : [%s] - Free Capacity : [%s] KB %n", pool.getLabel(), pool.getFreeCapacity()));
}
buf.append(String.format("---------------------------------------- %n"));
_log.info(buf.toString());
}
use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method initResources.
/**
* Initialize common resources
*/
private void initResources() {
// initialize the storage pool -> storage systems map
this.storagePoolStorageSystemCache = new HashMap<String, List<String>>();
// Reset the HA Recommendations
this.srcHaRecommendation = new RPRecommendation();
this.tgtHaRecommendation = new HashMap<URI, Recommendation>();
this.tgtVarrayHasHaVpool = new HashMap<VirtualArray, Boolean>();
}
Aggregations