Search in sources :

Example 6 with ObjectLocalCache

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;
}
Also used : VPlexHighAvailabilityMatcher(com.emc.storageos.volumecontroller.impl.utils.attrmatchers.VPlexHighAvailabilityMatcher) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ObjectLocalCache(com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache) StringSet(com.emc.storageos.db.client.model.StringSet) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) HashSet(java.util.HashSet)

Example 7 with ObjectLocalCache

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;
}
Also used : ProvisioningAttributeMapBuilder(com.emc.storageos.volumecontroller.impl.utils.ProvisioningAttributeMapBuilder) StoragePool(com.emc.storageos.db.client.model.StoragePool) ObjectLocalCache(com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache) ArrayList(java.util.ArrayList) NeighborhoodsMatcher(com.emc.storageos.volumecontroller.impl.utils.attrmatchers.NeighborhoodsMatcher) BigDecimal(java.math.BigDecimal) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) CapacityResponse(com.emc.storageos.model.vpool.CapacityResponse) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet)

Example 8 with ObjectLocalCache

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;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ObjectLocalCache(com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache) CapacityMatcher(com.emc.storageos.volumecontroller.impl.utils.attrmatchers.CapacityMatcher)

Aggregations

ObjectLocalCache (com.emc.storageos.volumecontroller.impl.utils.ObjectLocalCache)8 StoragePool (com.emc.storageos.db.client.model.StoragePool)5 HashSet (java.util.HashSet)5 StringSet (com.emc.storageos.db.client.model.StringSet)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 StringMap (com.emc.storageos.db.client.model.StringMap)2 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)2 AttributeList (com.emc.storageos.model.varray.AttributeList)2 VArrayAttributeList (com.emc.storageos.model.varray.VArrayAttributeList)2 VirtualPoolAvailableAttributesResourceRep (com.emc.storageos.model.vpool.VirtualPoolAvailableAttributesResourceRep)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 CapacityMatcher (com.emc.storageos.volumecontroller.impl.utils.attrmatchers.CapacityMatcher)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1