ofri masad has posted comments on this change.

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


Patch Set 3: (12 inline comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
Line 561:                 addInternalStorageParameters(consumptionParameters);
Line 562:                 addInternalVdsParameters(consumptionParameters);
Line 563:                 break;
Line 564:             }
Line 565:         } catch (ClassCastException e) {
Done
Line 566:             log.error("Command: " + this.getClass().getName()
Line 567:                     + ". Quota handling was expected - class does not 
implement the expected interface");
Line 568:         }
Line 569: 


Line 562:                 addInternalVdsParameters(consumptionParameters);
Line 563:                 break;
Line 564:             }
Line 565:         } catch (ClassCastException e) {
Line 566:             log.error("Command: " + this.getClass().getName()
Done
Line 567:                     + ". Quota handling was expected - class does not 
implement the expected interface");
Line 568:         }
Line 569: 
Line 570:         QuotaConsumptionParametersWrapper 
quotaConsumptionParametersWrapper;


Line 565:         } catch (ClassCastException e) {
Line 566:             log.error("Command: " + this.getClass().getName()
Line 567:                     + ". Quota handling was expected - class does not 
implement the expected interface");
Line 568:         }
Line 569: 
it will be used in QuotaManager.getInstance().consume()  (line 584)
Line 570:         QuotaConsumptionParametersWrapper 
quotaConsumptionParametersWrapper;
Line 571:         if (getStoragePool() != null) {
Line 572:             quotaConsumptionParametersWrapper = new 
QuotaConsumptionParametersWrapper(
Line 573:                     this.getStoragePool(), 
this.getReturnValue().getCanDoActionMessages(), this);


Line 567:                     + ". Quota handling was expected - class does not 
implement the expected interface");
Line 568:         }
Line 569: 
Line 570:         QuotaConsumptionParametersWrapper 
quotaConsumptionParametersWrapper;
Line 571:         if (getStoragePool() != null) {
since the && in line 518 is a logic && - if internalValidateAndSetQuota returns 
false then canDoAction will not run. i pass the getCanDoActionMessages() so 
that the QuotaManager could write the error messages into it.
Line 572:             quotaConsumptionParametersWrapper = new 
QuotaConsumptionParametersWrapper(
Line 573:                     this.getStoragePool(), 
this.getReturnValue().getCanDoActionMessages(), this);
Line 574:             
quotaConsumptionParametersWrapper.setParameters(consumptionParameters);
Line 575:         } else {


Line 579:             log.error("Command: " + this.getClass().getName()
Line 580:                     + ". Storage pool is not available for quota 
calculation. ");
Line 581:         }
Line 582: 
Line 583:         if (!consumptionParameters.isEmpty()) {
Done
Line 584:             // TODO - implemented in next patch - return 
QuotaManager.getInstance().consume(quotaConsumptionParametersWrapper);
Line 585:             return true;
Line 586:         } else {
Line 587:             return true;


Line 586:         } else {
Line 587:             return true;
Line 588:         }
Line 589:     }
Line 590: 
Done
Line 591:     private void 
addInternalVdsParameters(List<QuotaConsumptionParameter> consumptionParameters) 
{
Line 592:         List<QuotaVdsConsumptionParameter> vdsParameters;
Line 593:         vdsParameters = ((QuotaVdsDependent) 
this).getQuotaVdsConsumptionParameters();
Line 594:         if (null == vdsParameters || vdsParameters.isEmpty()) {


Line 597:         } else {
Line 598:             consumptionParameters.addAll(vdsParameters);
Line 599:         }
Line 600:     }
Line 601: 
Done
Line 602:     private void 
addInternalStorageParameters(List<QuotaConsumptionParameter> 
consumptionParameters) {
Line 603:         List<QuotaStorageConsumptionParameter> storageParameters;
Line 604:         storageParameters = ((QuotaStorageDependent) 
this).getQuotaStorageConsumptionParameters();
Line 605:         if (null == storageParameters || storageParameters.isEmpty()) 
{


Line 601: 
Line 602:     private void 
addInternalStorageParameters(List<QuotaConsumptionParameter> 
consumptionParameters) {
Line 603:         List<QuotaStorageConsumptionParameter> storageParameters;
Line 604:         storageParameters = ((QuotaStorageDependent) 
this).getQuotaStorageConsumptionParameters();
Line 605:         if (null == storageParameters || storageParameters.isEmpty()) 
{
Done
Line 606:             log.error("Command: " + this.getClass().getName()
Line 607:                     + ". Quota handling was expected - returned empty 
parameters");
Line 608:         } else {
Line 609:             consumptionParameters.addAll(storageParameters);


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


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParameter.java
Line 36: 
Line 37:     public void setQuotaAction(QuotaAction quotaAction) {
Line 38:         this.quotaAction = quotaAction;
Line 39:     }
Line 40: 
Done
Line 41:     public abstract QuotaConsumptionParameter clone();
Line 42: 
Line 43:     public void revert() {
Line 44:         quotaAction = QuotaAction.CONSUME.equals(quotaAction) ? 
QuotaAction.RELEASE : QuotaAction.CONSUME;


Line 38:         this.quotaAction = quotaAction;
Line 39:     }
Line 40: 
Line 41:     public abstract QuotaConsumptionParameter clone();
Line 42: 
Done
Line 43:     public void revert() {
Line 44:         quotaAction = QuotaAction.CONSUME.equals(quotaAction) ? 
QuotaAction.RELEASE : QuotaAction.CONSUME;
Line 45:     }
Line 46: 


....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParametersWrapper.java
Line 98:     }
Line 99: 
Line 100:     /**
Line 101:      * Revert the numbers of all requested cpu, memory and storage
Line 102:      */
Done
Line 103:     public void revert() {
Line 104:         for (QuotaConsumptionParameter parameter : 
this.getParameters()) {
Line 105:             parameter.revert();
Line 106:         }


--
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: 3
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