use of com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache in project coprhd-controller by CoprHD.
the class PlacementTestUtils method runVPlexHighAvailabilityMatcher.
/**
* Runs the VPLEX high availability matcher
* @param vpool
* @param pools
* @return
*/
public static StringSet runVPlexHighAvailabilityMatcher(DbClientImpl dbClient, VirtualPool vpool, List<StoragePool> pools) {
Set<String> poolNames = new HashSet<String>();
for (StoragePool pool : pools) {
poolNames.add(pool.getLabel());
}
_log.info("Calling VPlexHighAvailabilityMatcher on pools: " + poolNames.toString());
VPlexHighAvailabilityMatcher matcher = new VPlexHighAvailabilityMatcher();
ObjectLocalCache cache = new ObjectLocalCache(dbClient);
matcher.setObjectCache(cache);
Map<String, Object> attributeMap = new HashMap<String, Object>();
attributeMap.put(Attributes.high_availability_type.name(), vpool.getHighAvailability());
attributeMap.put(Attributes.varrays.name(), vpool.getVirtualArrays());
attributeMap.put(Attributes.high_availability_varray.name(), null);
attributeMap.put(Attributes.high_availability_vpool.name(), null);
if (vpool.getHaVarrayVpoolMap() != null) {
for (Map.Entry<String, String> entry : vpool.getHaVarrayVpoolMap().entrySet()) {
attributeMap.put(Attributes.high_availability_varray.name(), entry.getKey());
attributeMap.put(Attributes.high_availability_vpool.name(), entry.getValue());
}
}
StringBuffer errorMessage = new StringBuffer();
List<StoragePool> matchedPools = matcher.matchStoragePoolsWithAttributeOn(pools, attributeMap, errorMessage);
StringSet result = new StringSet();
for (StoragePool matchedPool : matchedPools) {
result.add(matchedPool.getId().toString());
}
_log.info("Matched results: " + result.toString());
return result;
}
use of com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache in project coprhd-controller by CoprHD.
the class CapacityUtils method getCapacityForVirtualPoolAndVirtualArray.
public static CapacityResponse getCapacityForVirtualPoolAndVirtualArray(VirtualPool vPool, URI vArrayId, DbClient dbClient, CoordinatorClient coordinator) {
List<StoragePool> validPoolsOfvPool = VirtualPool.getValidStoragePools(vPool, dbClient, false);
List<StoragePool> invalidPoolsOfvPool = VirtualPool.getInvalidStoragePools(vPool, dbClient);
Map<String, Object> attributeMap = new ProvisioningAttributeMapBuilder(0L, vArrayId.toString(), 0L).buildMap();
NeighborhoodsMatcher matcher = new NeighborhoodsMatcher();
matcher.setCoordinatorClient(coordinator);
matcher.setObjectCache(new ObjectLocalCache(dbClient));
StringBuffer errorMessageForValidPools = new StringBuffer();
StringBuffer errorMessageForInValidPools = new StringBuffer();
validPoolsOfvPool = matcher.runMatchStoragePools(validPoolsOfvPool, attributeMap, errorMessageForValidPools);
invalidPoolsOfvPool = matcher.runMatchStoragePools(invalidPoolsOfvPool, attributeMap, errorMessageForInValidPools);
List<StoragePool> validPools = new ArrayList<StoragePool>();
for (StoragePool pool : validPoolsOfvPool) {
if (StoragePool.RegistrationStatus.REGISTERED.toString().equals(pool.getRegistrationStatus()) && CompatibilityStatus.COMPATIBLE.toString().equals(pool.getCompatibilityStatus()) && DiscoveryStatus.VISIBLE.toString().equals(pool.getDiscoveryStatus())) {
validPools.add(pool);
} else {
invalidPoolsOfvPool.add(pool);
}
}
Map<String, BigInteger> rawCapacityMetrics = getPoolCapacityMetrics(validPools, vPool, dbClient, coordinator);
Set<String> poolSet = new HashSet<String>();
for (StoragePool pool : validPools) {
poolSet.add(pool.getId().toString());
}
Capacity capacity = getVirtualPoolCapacityForPools(dbClient, vPool.getId(), VirtualPool.Type.valueOf(vPool.getType()), poolSet);
poolSet.clear();
for (StoragePool pool : invalidPoolsOfvPool) {
poolSet.add(pool.getId().toString());
}
Capacity invalidPoolCapacity = getVirtualPoolCapacityForPools(dbClient, vPool.getId(), VirtualPool.Type.valueOf(vPool.getType()), poolSet);
// Free Capacity is rounded down
BigInteger freeCapacity = rawCapacityMetrics.get(StorageMetrics.FREE.toString());
freeCapacity = freeCapacity.divide(kbToGB_BI);
long freeCapacityGb = freeCapacity.longValue();
BigInteger netFreeCapacity = rawCapacityMetrics.get(StorageMetrics.NET_FREE.toString());
netFreeCapacity = netFreeCapacity.divide(kbToGB_BI);
long netFreeCapacityGb = netFreeCapacity.longValue();
// 4) Check netFreeCapacity against Quota
if (vPool.getQuotaEnabled()) {
long netFreeQuota = vPool.getQuota() - (long) ((capacity._provisionedCapacity + invalidPoolCapacity._provisionedCapacity) / GB);
if (netFreeQuota < 0) {
netFreeCapacityGb = 0;
} else if (netFreeQuota < netFreeCapacityGb) {
netFreeCapacityGb = netFreeQuota;
}
}
// Used Capacity is rounded up.
BigDecimal[] result = new BigDecimal(capacity._usedCapacity + invalidPoolCapacity._usedCapacity).divideAndRemainder(new BigDecimal(GB));
long usedCapacityGb = result[0].longValue();
if (!result[1].equals(BigDecimal.ZERO)) {
usedCapacityGb += 1;
}
// Subscribed Capacity is rounded up.
result = new BigDecimal(capacity._provisionedCapacity + invalidPoolCapacity._provisionedCapacity).divideAndRemainder(new BigDecimal(GB));
long subscribedCapacityGb = result[0].longValue();
if (!result[1].equals(BigDecimal.ZERO)) {
subscribedCapacityGb += 1;
}
long totalCapacityGB = freeCapacityGb + usedCapacityGb;
CapacityResponse response = new CapacityResponse();
response.setFreeGb(Long.toString(freeCapacityGb));
response.setNetFreeGb(Long.toString(netFreeCapacityGb));
response.setProvissionedGb(Long.toString(subscribedCapacityGb));
response.setUsedGb(Long.toString(usedCapacityGb));
if (totalCapacityGB != 0) {
result = new BigDecimal(subscribedCapacityGb * 100).divideAndRemainder(new BigDecimal(totalCapacityGB));
int percentage = result[0].intValue();
if (!result[1].equals(BigDecimal.ZERO)) {
percentage += 1;
}
response.setPercentProvisioned(Integer.toString(percentage));
result = new BigDecimal(usedCapacityGb * 100).divideAndRemainder(new BigDecimal(totalCapacityGB));
percentage = result[0].intValue();
if (!result[1].equals(BigDecimal.ZERO)) {
percentage += 1;
}
response.setPercentUsed(Integer.toString(percentage));
}
return response;
}
use of com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache in project coprhd-controller by CoprHD.
the class StorageScheduler method getPoolMatchingCapacity.
/**
* Returns first storage pool from the passed list of candidate storage
* pools that has at least the passed free capacity.
* Note: do not change order of candidate pools.
*
* @param capacity The desired free capacity.
* @param resourceSize The desired resource size
* @param newResourceCount The desired number of resources
* @param candidatePools The list of candidate storage pools.
* @param isThinlyProvisioned Indication if this is thin provisioning (thin volume).
*
* @return A storage pool that have the passed free capacity.
*/
protected StoragePool getPoolMatchingCapacity(long capacity, long resourceSize, Integer newResourceCount, List<StoragePool> candidatePools, boolean isThinlyProvisioned, Long thinVolumePreAllocationResourceSize) {
StoragePool poolWithCapacity = null;
CapacityMatcher capacityMatcher = new CapacityMatcher();
capacityMatcher.setCoordinatorClient(_coordinator);
capacityMatcher.setObjectCache(new ObjectLocalCache(_dbClient, false));
Iterator<StoragePool> storagePoolsIter = candidatePools.iterator();
while (storagePoolsIter.hasNext()) {
StoragePool candidatePool = storagePoolsIter.next();
// First check if max Resources limit is violated for the pool
if (MaxResourcesMatcher.checkPoolMaximumResourcesApproached(candidatePool, _dbClient, newResourceCount)) {
continue;
}
// continue;
if (capacityMatcher.poolMatchesCapacity(candidatePool, capacity, resourceSize, false, isThinlyProvisioned, thinVolumePreAllocationResourceSize)) {
poolWithCapacity = candidatePool;
break;
}
}
return poolWithCapacity;
}
Aggregations