use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaDaoImpl method getAllQuotaIncludingConsumption.
/**
* Get all the full quotas. Including consumption data. This call is very heavy and should be used really and with
* caution. It was created to support cache initialization
*
* @return all quota in DB (including consumption calculation)
*/
@Override
public List<Quota> getAllQuotaIncludingConsumption() {
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
// get thin quota (only basic quota meta data)
List<Quota> allThinQuota = getCallsHandler().executeReadList("getAllThinQuota", getQuotaMetaDataFromResultSet(), parameterSource);
if (!allThinQuota.isEmpty()) {
Map<Guid, Quota> allQuotaMap = new HashMap<>();
for (Quota quota : allThinQuota) {
allQuotaMap.put(quota.getId(), quota);
}
List<QuotaStorage> quotaStorageList = getAllQuotaStorageIncludingConsumption();
List<QuotaCluster> quotaClusterList = getAllQuotaClusterIncludingConsumption();
for (QuotaStorage quotaStorage : quotaStorageList) {
Quota quota = allQuotaMap.get(quotaStorage.getQuotaId());
if (quota != null) {
if (quotaStorage.getStorageId() == null || quotaStorage.getStorageId().equals(Guid.Empty)) {
quota.setGlobalQuotaStorage(quotaStorage);
} else {
if (quota.getQuotaStorages() == null) {
quota.setQuotaStorages(new ArrayList<>());
}
quota.getQuotaStorages().add(quotaStorage);
}
}
}
for (QuotaCluster quotaCluster : quotaClusterList) {
Quota quota = allQuotaMap.get(quotaCluster.getQuotaId());
if (quota != null) {
if (quotaCluster.getClusterId() == null || quotaCluster.getClusterId().equals(Guid.Empty)) {
quota.setGlobalQuotaCluster(quotaCluster);
} else {
if (quota.getQuotaClusters() == null) {
quota.setQuotaClusters(new ArrayList<>());
}
quota.getQuotaClusters().add(quotaCluster);
}
}
}
}
// The thin quota were all filled
return allThinQuota;
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaDaoTest method testFetchSpecificQuotaUsageForGlobalCluster.
/**
* Test scenario when there is a specific limitation on the storage pool, and we check limitation on the entire
* storage pool.<BR/>
* The value that should be returned, is the specific limitations and the specific usage on the storage pool.
*/
@Test
public void testFetchSpecificQuotaUsageForGlobalCluster() throws Exception {
List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByClusterGuid(null, FixturesTool.QUOTA_SPECIFIC);
QuotaCluster quotaCluster = quotaClusterList.get(0);
assertEquals(2, quotaClusterList.size());
assertNotNull(quotaCluster);
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaDaoTest method setQuotaGlobalLimitations.
private static void setQuotaGlobalLimitations(Quota quota) {
QuotaStorage quotaStorage = new QuotaStorage();
QuotaCluster quotaCluster = new QuotaCluster();
// Set Quota storage capacity definition.
quotaStorage.setStorageSizeGB(10000L);
quotaStorage.setStorageSizeGBUsage(0d);
// Set Quota cluster virtual memory definition.
quotaCluster.setMemSizeMB(16000000L);
quotaCluster.setMemSizeMBUsage(0L);
// Set Quota cluster virtual CPU definition.
quotaCluster.setVirtualCpu(2880);
quotaCluster.setVirtualCpuUsage(0);
quota.setGlobalQuotaStorage(quotaStorage);
quota.setGlobalQuotaCluster(quotaCluster);
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaDaoTest method testFetchGlobalQuotaUsageForSpecificCluster.
/**
* Test scenario when there is a global limitation on the storage pool, and we check if there is enough resources on a
* specific vds group.<BR/>
* The returned value from the query, should be the global limitation and the global usage on the storage pool.
*/
@Test
public void testFetchGlobalQuotaUsageForSpecificCluster() throws Exception {
List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByClusterGuid(FixturesTool.CLUSTER_RHEL6_ISCSI, FixturesTool.QUOTA_GENERAL);
QuotaCluster quotaCluster = quotaClusterList.get(0);
assertNotNull(quotaCluster);
assertEquals(1, quotaClusterList.size());
assertTrue(quotaCluster.getMemSizeMBUsage() > 0);
assertTrue(quotaCluster.getVirtualCpuUsage() > 0);
// Check if the global variable returns when null is initialization.
assertEquals(Integer.valueOf(100), quotaCluster.getVirtualCpu());
}
use of org.ovirt.engine.core.common.businessentities.QuotaCluster in project ovirt-engine by oVirt.
the class QuotaDaoTest method testFetchSpecificQuotaUsageForSpecificCluster.
/**
* Test scenario when there is a specific limitation on the storage pool, and we check if there is enough resources on a
* specific vds group.<BR/>
* The returned value from the query, should be the specific limitation and the specific usage on the vds group.
*/
@Test
public void testFetchSpecificQuotaUsageForSpecificCluster() throws Exception {
List<QuotaCluster> quotaClusterList = dao.getQuotaClusterByClusterGuid(FixturesTool.CLUSTER_RHEL6_ISCSI, FixturesTool.QUOTA_SPECIFIC);
QuotaCluster quotaCluster = quotaClusterList.get(0);
assertNotNull(quotaCluster);
assertEquals(1, quotaClusterList.size());
// Check if the global variable returns when null is initialization.
assertEquals(Integer.valueOf(10), quotaCluster.getVirtualCpu());
}
Aggregations