use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.
the class ManagedCapacityImpl method getManagedCapacity.
public ManagedResourcesCapacity getManagedCapacity() throws InterruptedException {
log.info("Getting provisioning managed capacity");
double total = 0;
StringBuilder logMessage = new StringBuilder("");
logMessage.append('\n');
logMessage.append("------------------------------------------------------------------------\n");
logMessage.append("| | | |\n");
logMessage.append("| RESOURCE | MANAGED_QTY | TOTAL CAPACITY |\n");
logMessage.append("| | | |\n");
logMessage.append("------------------------------------------------------------------------\n");
ManagedResourcesCapacity resources = getManagedCapacity(dbClient);
List<ManagedResourceCapacity> capacities = resources.getResourceCapacityList();
for (ManagedResourcesCapacity.ManagedResourceCapacity cap : capacities) {
total += cap.getResourceCapacity();
logMessage.append("| | | |\n");
logMessage.append(String.format("| %13s | %10d | %30s |%n", cap.getType(), cap.getNumResources(), Double.toString(cap.getResourceCapacity())));
logMessage.append("| | | |\n");
}
logMessage.append("| | | |\n");
logMessage.append("------------------------------------------------------------------------\n");
logMessage.append("| | | |\n");
logMessage.append(String.format("| TOTAL | | %30s |%n", Double.toString(total)));
logMessage.append("| | | |\n");
logMessage.append("------------------------------------------------------------------------\n");
logMessage.append('\n');
log.info(logMessage.toString());
return resources;
}
use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.
the class ManagedCapacityImpl method getManagedCapacity.
public static ManagedResourcesCapacity getManagedCapacity(DbClient dbClient) throws InterruptedException {
ManagedResourcesCapacity resourcesCapacity = new ManagedResourcesCapacity();
ManagedResourcesCapacity.ManagedResourceCapacity manCap;
CustomQueryUtility.AggregatedValue aggr = null;
if (Thread.currentThread().interrupted()) {
throw new InterruptedException();
}
manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
manCap.setType(ManagedResourcesCapacity.CapacityResourceType.VOLUME);
aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, Volume.class, "allocatedCapacity");
manCap.setNumResources(aggr.getCount());
manCap.setResourceCapacity(aggr.getValue());
resourcesCapacity.getResourceCapacityList().add(manCap);
if (Thread.currentThread().interrupted()) {
throw new InterruptedException();
}
manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
manCap.setType(ManagedResourcesCapacity.CapacityResourceType.FILESHARE);
aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, FileShare.class, "usedCapacity");
manCap.setNumResources(aggr.getCount());
manCap.setResourceCapacity(aggr.getValue());
resourcesCapacity.getResourceCapacityList().add(manCap);
if (Thread.currentThread().interrupted()) {
throw new InterruptedException();
}
manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
manCap.setType(ManagedResourcesCapacity.CapacityResourceType.POOL);
aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, StoragePool.class, "freeCapacity");
manCap.setNumResources(aggr.getCount());
double capacity = aggr.getValue();
// We must consider storage systems with sharedStorageCapacity == true (e.g. Ceph),
// because each their pool reports total storage free capacity.
// We get all such systems and subtract its pool size multiplied by (pools count - 1) from total capacity.
// Get all StoragePools where storageDevice is a StorageSystem where sharedStorageCapacity is true
Joiner j = new Joiner(dbClient).join(StorageSystem.class, "ss").match("sharedStorageCapacity", true).join("ss", StoragePool.class, "sp", "storageDevice").go();
Map<StorageSystem, Collection<URI>> ssToPoolMap = j.pushList("ss").pushUris("sp").map();
// From the joiner, get the StorageSystems (which is a small amount of objects) and the SPs (which is large, so get URIs and use query)
for (Entry<StorageSystem, Collection<URI>> ssToPoolEntry : ssToPoolMap.entrySet()) {
Collection<URI> poolURIs = ssToPoolEntry.getValue();
int extraPoolCount = poolURIs.size() - 1;
if (extraPoolCount <= 0) {
// Do nothing if none of the only pool belongs to Storage System
continue;
}
StoragePool pool = dbClient.queryObject(StoragePool.class, poolURIs.iterator().next());
capacity -= extraPoolCount * pool.getFreeCapacity();
}
manCap.setResourceCapacity(capacity * KB);
resourcesCapacity.getResourceCapacityList().add(manCap);
if (Thread.currentThread().interrupted()) {
throw new InterruptedException();
}
manCap = new ManagedResourcesCapacity.ManagedResourceCapacity();
manCap.setType(ManagedResourcesCapacity.CapacityResourceType.BUCKET);
aggr = CustomQueryUtility.aggregatedPrimitiveField(dbClient, Bucket.class, "hardQuota");
manCap.setNumResources(aggr.getCount());
manCap.setResourceCapacity(aggr.getValue());
resourcesCapacity.getResourceCapacityList().add(manCap);
if (Thread.currentThread().interrupted()) {
throw new InterruptedException();
}
return resourcesCapacity;
}
use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.
the class HealthMonitorService method getStorageStats.
/**
* Get the current capacity for object, file and block storage.
*
* @brief Show storage capacity
* @prereq none
* @return Storage stats for controller (file & block) and object.
*/
@GET
@Path("/storage")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public StorageStats getStorageStats() {
_log.info("Getting storage stats");
StorageStats.ControllerStorageStats controllerStats = null;
if (_licenseManager.isProductLicensed(LicenseType.CONTROLLER)) {
ManagedResourcesCapacity resourceCapacities = _licenseManager.getControllerCapacity();
controllerStats = new StorageStats.ControllerStorageStats();
for (ManagedResourceCapacity cap : resourceCapacities.getResourceCapacityList()) {
switch(cap.getType()) {
case VOLUME:
controllerStats.setBlockCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
break;
case FILESHARE:
controllerStats.setFileCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
break;
case POOL:
controllerStats.setFreeManagedCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
break;
case BUCKET:
controllerStats.setObjectCapacityKB(cap.getResourceCapacity() / StatConstants.CAPACITY_CONVERSION_VALUE);
break;
}
}
}
return new StorageStats(controllerStats);
}
use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.
the class LicenseManagerImpl method getTotalControllerCapacity.
/**
* Gets controller total managed capacity.
* sum of volume managed + file managed + free managed storage pool
* This is mainly used to check capacity against licensed capacity amount.
*/
private double getTotalControllerCapacity() throws InternalServerErrorException {
_log.info("Getting controller total capacity");
ManagedResourcesCapacity resourceCapacities = getControllerCapacity();
double total = 0;
for (ManagedResourceCapacity cap : resourceCapacities.getResourceCapacityList()) {
_log.debug("{} capacity is {}", cap.getType(), cap.getResourceCapacity());
total += cap.getResourceCapacity();
}
_log.info("Controller total capacity is {}", total);
return total;
}
use of com.emc.storageos.model.vpool.ManagedResourcesCapacity in project coprhd-controller by CoprHD.
the class CapacityService method getCapacityDataResource.
private ManagedResourcesCapacity getCapacityDataResource() throws Exception {
ManagedResourcesCapacity capacities = new ManagedResourcesCapacity();
for (CapacityResourceType capType : CapacityResourceType.values()) {
ManagedCapacityImpl.CapacityPropertyListTypes resourceType = ManagedCapacityImpl.mapCapacityType(capType);
List<URI> dataResourcesURI = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getConstraint(PropertyListDataObject.class, "resourceType", resourceType.toString()));
if (dataResourcesURI.isEmpty()) {
_log.warn("Failed to find capacity of type {} in the database, recompute", resourceType);
throw new Exception("Failed to find capacity in the database");
}
PropertyListDataObject resource = _dbClient.queryObject(PropertyListDataObject.class, dataResourcesURI.get(0));
ManagedResourceCapacity mCap = map(resource, ManagedResourceCapacity.class);
capacities.getResourceCapacityList().add(mCap);
}
return capacities;
}
Aggregations