ofri masad has posted comments on this change.
Change subject: core: Quota refactor - QuotaManager step 2
......................................................................
Patch Set 5: (6 inline comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaManager.java
Line 29: public class QuotaManager {
Line 30: private final static QuotaManager INSTANCE = new QuotaManager();
Line 31: private final static ReentrantReadWriteLock lock = new
ReentrantReadWriteLock();
Line 32: private final static Log log =
LogFactory.getLog(QuotaManager.class);
Line 33: private final static DecimalFormat percentageFormatter = new
DecimalFormat("#.##");
Done
Line 34: private final static QuotaManagerAuditLogger AUDIT_LOGGER =
QuotaManagerAuditLogger.getInstance();
Line 35: private final ConcurrentHashMap<Guid, Map<Guid, Quota>>
storagePoolQuotaMap =
Line 36: new ConcurrentHashMap<Guid, Map<Guid, Quota>>();
Line 37: private final ConcurrentHashMap<Guid, Quota> directQuotaMap = new
ConcurrentHashMap<Guid, Quota>();
Line 764: boolean hardEnforcement =
Line 765:
QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(parameters.getStorage_pool().getQuotaEnforcementType());
Line 766:
Line 767: // if one of the main objects of the parameters is null
Line 768: if (null == parameters.getCanDoActionMessages()
Done
Line 769: || null == parameters.getAuditLogable()
Line 770: || null == parameters.getParameters()){
Line 771: // if in hard enforcement - return false
Line 772: if (hardEnforcement) {
Line 831: private boolean
checkAndCompleteStoragePool(QuotaConsumptionParametersWrapper parameters) {
Line 832: // if storage_pool is null
Line 833: if (parameters.getStorage_pool() == null){
Line 834: log.debug("Null storage pool was passed to
'QuotaManager.validateAndSetStorageQuota()'");
Line 835: // if no quota was passed
Done
Line 836: if (parameters.getParameters().isEmpty() ||
parameters.getParameters().get(0).getQuotaGuid() == null) {
Line 837:
parameters.getCanDoActionMessages().add(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_IS_NOT_VALID.toString());
Line 838: return false;
Line 839: }
Line 836: if (parameters.getParameters().isEmpty() ||
parameters.getParameters().get(0).getQuotaGuid() == null) {
Line 837:
parameters.getCanDoActionMessages().add(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_IS_NOT_VALID.toString());
Line 838: return false;
Line 839: }
Line 840: // try to get storage pool from quota
Done
Line 841: storage_pool storage_pool =
getStoragePoolByQuota(parameters.getParameters().get(0).getQuotaGuid());
Line 842: if (null != storage_pool) {
Line 843: parameters.setStorage_pool(storage_pool);
Line 844: } else {
Line 854: // vds group id which is handled by this quota
Line 855: private boolean
checkVdsGroupMatchQuota(QuotaConsumptionParametersWrapper parameters,
QuotaConsumptionParameter param) {
Line 856: Quota quota = param.getQuota();
Line 857:
Line 858: // make sure vds group is in the quota
Done
Line 859: if (param instanceof QuotaVdsConsumptionParameter) {
Line 860: QuotaVdsConsumptionParameter paramVds =
(QuotaVdsConsumptionParameter) param;
Line 861:
Line 862: if (paramVds.getVdsGroupId() == null) {
Line 936: // cache in direct quota map
Line 937: Quota quota = getQuotaDAO().getById(quotaId);
Line 938: directQuotaMap.put(quotaId, quota);
Line 939: // cache in storage-pool->quota map
Line 940:
storagePoolQuotaMap.putIfAbsent(quota.getStoragePoolId(), new HashMap<Guid,
Quota>());
Done
Line 941:
storagePoolQuotaMap.get(quota.getStoragePoolId()).put(quotaId, quota);
Line 942: }
Line 943: return directQuotaMap.get(quotaId);
Line 944: }
--
To view, visit http://gerrit.ovirt.org/8777
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I15314d6269d1f5f43de17c36a6ae91ba874c8a58
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: ofri masad <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Doron Fediuck <[email protected]>
Gerrit-Reviewer: Gilad Chaplik <[email protected]>
Gerrit-Reviewer: Laszlo Hornyak <[email protected]>
Gerrit-Reviewer: Michael Kublin <[email protected]>
Gerrit-Reviewer: Sharad Mishra <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: ofri masad <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches