use of org.ovirt.engine.core.common.businessentities.QuotaStorage 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.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaDaoTest method testQuotaStorageByQuotaGuidWithGeneralDefaultNoDefault.
/**
* Asserts that when {@link QuotaDao#getQuotaStorageByQuotaGuidWithGeneralDefault(Guid)} is called
* with a specific quota, all the relevant storages are returned
*/
@Test
public void testQuotaStorageByQuotaGuidWithGeneralDefaultNoDefault() {
List<QuotaStorage> quotaStorageList = dao.getQuotaStorageByQuotaGuidWithGeneralDefault(FixturesTool.QUOTA_SPECIFIC);
assertNotNull(quotaStorageList);
assertEquals("wrong number of quotas returned", 1, quotaStorageList.size());
for (QuotaStorage group : quotaStorageList) {
assertNotNull("Storage ID should not be null in specific mode", group.getStorageId());
assertNotNull("Storage name should not be null in specific mode", group.getStorageName());
}
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage 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.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaDaoTest method getSpecificQuotaStorage.
private static QuotaStorage getSpecificQuotaStorage(Guid quotaId) {
QuotaStorage quotaStorage = new QuotaStorage();
quotaStorage.setQuotaId(quotaId);
quotaStorage.setQuotaStorageId(Guid.newGuid());
quotaStorage.setStorageId(FixturesTool.STORAGE_DOMAIN_NFS_MASTER);
quotaStorage.setStorageSizeGB(10000L);
quotaStorage.setStorageSizeGBUsage(0d);
return quotaStorage;
}
use of org.ovirt.engine.core.common.businessentities.QuotaStorage in project ovirt-engine by oVirt.
the class QuotaDaoTest method testSpecificAndGeneralQuotaLimitations.
@Test
public void testSpecificAndGeneralQuotaLimitations() throws Exception {
// Set new Quota definition.
Quota quota = createGeneralQuota();
quota.setQuotaClusters(getQuotaCluster(getSpecificQuotaCluster(quota.getId())));
quota.setQuotaStorages(getQuotaStorage(null));
quota.setGlobalQuotaStorage(new QuotaStorage(null, null, null, 10000L, 0d));
dao.save(quota);
Quota quotaEntity = dao.getById(quota.getId());
assertNotNull(quotaEntity);
assertEquals(quota, quotaEntity);
}
Aggregations