ofri masad has posted comments on this change.

Change subject: core: Quota refactor - parameters
......................................................................


Patch Set 2: (11 inline comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
Line 539:         return returnValue;
Line 540:     }
Line 541: 
Line 542:     private boolean internalValidateAndSetQuota() {
Line 543:         if (isInternalExecution()) {
Taking your example, lets say that a VM has 3 disks. on "create snapshot" we 
iterate over the first two disks and set the quota. the third disk don't have 
sufficient storage on quota. Now we have to roll-back the first two disk (not 
only the quota calculation but the vds ans storage actions as well. That is why 
we always calculate the quota in the highest level.
Line 544:             return true;
Line 545:         }
Line 546: 
Line 547:         VdcActionType.QuotaDependency quotaDependency = 
this.getActionType().getQuotaDependency();


Line 543:         if (isInternalExecution()) {
Line 544:             return true;
Line 545:         }
Line 546: 
Line 547:         VdcActionType.QuotaDependency quotaDependency = 
this.getActionType().getQuotaDependency();
Done
Line 548:         List<QuotaConsumptionParameter> consumptionParameters = new 
ArrayList<QuotaConsumptionParameter>();
Line 549: 
Line 550:         try {
Line 551:             switch (quotaDependency) {


Line 569: 
Line 570:         QuotaConsumptionParameters quotaConsumptionParameters;
Line 571:         if (getStoragePool() != null) {
Line 572:             quotaConsumptionParameters = new 
QuotaConsumptionParameters(
Line 573:                     this.getStoragePool(), 
this.getStoragePool().getId(),
Done
Line 574:                     this.getReturnValue().getCanDoActionMessages(), 
this);
Line 575:             
quotaConsumptionParameters.setParameters(consumptionParameters);
Line 576:         } else {
Line 577:             quotaConsumptionParameters = new 
QuotaConsumptionParameters(


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/InvalidQuotaParametersException.java
Line 1: package org.ovirt.engine.core.bll.quota;
Line 2: 
Line 3: import org.ovirt.engine.core.compat.ApplicationException;
Line 4: 
Line 5: public class InvalidQuotaParametersException extends 
ApplicationException implements java.io.Serializable {
Done
Line 6:     private static final long serialVersionUID = -1759699263394287888L;
Line 7: 
Line 8:     public InvalidQuotaParametersException() {
Line 9:     }


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParameter.java
Line 43:     public void revert() {
Line 44:         this.action = Action.CONSUME.equals(action) ? Action.RELEASE : 
Action.CONSUME;
Line 45:     }
Line 46: 
Line 47:     public enum Action {
Done
Line 48:         CONSUME, RELEASE
Line 49:     }


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParameters.java
Line 10: public class QuotaConsumptionParameters {
Line 11: 
Line 12:     private List<QuotaConsumptionParameter> parameters;
Line 13: 
Line 14:     private org.ovirt.engine.core.common.businessentities.storage_pool 
storage_pool;
Done
Line 15:     private Guid storagePoolGuid;
Line 16:     private ArrayList<String> canDoActionMessages;
Line 17:     private AuditLogableBase auditLogable;
Line 18: 


Line 16:     private ArrayList<String> canDoActionMessages;
Line 17:     private AuditLogableBase auditLogable;
Line 18: 
Line 19:     public QuotaConsumptionParameters(storage_pool storage_pool,
Line 20:             Guid storagePoolGuid,
Done
Line 21:             ArrayList<String> canDoActionMessages,
Line 22:             AuditLogableBase auditLogable) {
Line 23:         this.storage_pool = storage_pool;
Line 24:         this.storagePoolGuid = storagePoolGuid;


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaStorageDependent.java
Line 15:      * Override this method in order to set the storage consumption 
parameters for the quota check.
Line 16:      * This method is called by CommandBase during the canDoAction 
check in order to make sure the
Line 17:      * command has sufficient quota resources in order to run.
Line 18:      *
Line 19:      * return null if the command does consume any storage resources.
in case your command inherits the implemented method - you can override it with 
return null; If you marked your command correctly in the VdcActionType, the 
method will not be called in the first place
Line 20:      *
Line 21:      * @return - list of storage consumption parameters. null if no 
consumption.
Line 22:      */
Line 23:     public List<QuotaStorageConsumptionParameter> 
getQuotaStorageConsumptionParameters();


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaVdsDependent.java
Line 4: import java.util.List;
Line 5: 
Line 6: /**
Line 7:  * Implement the QuotaVdsDependent interface to identify your command 
as one that dependent on
Line 8:  * Vds(vcpu and/or memory) Quota calculation in order to run. If a 
Command handles vcpus and memory -
Done
Line 9:  * it should be QuotaVdsDependent.
Line 10:  */
Line 11: public interface QuotaVdsDependent {
Line 12: 


Line 15:      * Override this method in order to set the vds consumption 
parameters for the quota check.
Line 16:      * This method is called by CommandBase during the canDoAction 
check in order to make sure the
Line 17:      * command has sufficient quota resources in order to run.
Line 18:      *
Line 19:      * return null if the command does consume any vds resources.
Done
Line 20:      *
Line 21:      * @return - list of vds consumption parameters. null if no 
consumption.
Line 22:      */
Line 23:     public List<QuotaVdsConsumptionParameter> 
getQuotaVdsConsumptionParameters();


Line 19:      * return null if the command does consume any vds resources.
Line 20:      *
Line 21:      * @return - list of vds consumption parameters. null if no 
consumption.
Line 22:      */
Line 23:     public List<QuotaVdsConsumptionParameter> 
getQuotaVdsConsumptionParameters();
Done


--
To view, visit http://gerrit.ovirt.org/8775
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iebfc85569ba1aa8bd840f7239f83b7f921a4bd8e
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: ofri masad <oma...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Doron Fediuck <dfedi...@redhat.com>
Gerrit-Reviewer: Gilad Chaplik <gchap...@redhat.com>
Gerrit-Reviewer: Laszlo Hornyak <lhorn...@redhat.com>
Gerrit-Reviewer: Michael Kublin <mkub...@redhat.com>
Gerrit-Reviewer: Sharad Mishra <snmis...@linux.vnet.ibm.com>
Gerrit-Reviewer: Yair Zaslavsky <yzasl...@redhat.com>
Gerrit-Reviewer: ofri masad <oma...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to