ofri masad has uploaded a new change for review.

Change subject: core: Fix getQuotaConsumptionParameters redundant calls
......................................................................

core: Fix getQuotaConsumptionParameters redundant calls

The getQuotaConsumptionParameters method was called 3 time during the
command lifetime.

A field holding the consumptionParameters was added and the value is
saved after the first call.

Change-Id: Ic64c7bd3352df49f61902bf4f749c7475e402bcc
Bug-Url: https://bugzilla.redhat.com/882810
Signed-off-by: Ofri Masad <oma...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
1 file changed, 17 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/56/9656/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
index 20bd121..b0f09d5 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
@@ -545,26 +545,29 @@
         }
     }
 
+    private List<QuotaConsumptionParameter> consumptionParameters;
+
     private List<QuotaConsumptionParameter> getQuotaConsumptionParameters() {
-        List<QuotaConsumptionParameter> consumptionParameters;
 
         // This a double marking mechanism which was created to ensure Quota 
dependencies would not be inherited
         // by descendants commands. Each Command is both marked by the 
QuotaDependency and implements the required
         // Interfaces (NONE does not implement any of the two interfaces).
         // The enum markings prevent Quota dependencies unintentional 
inheritance.
-        switch (getActionType().getQuotaDependency()) {
-            case NONE:
-                return null;
-            case STORAGE:
-                consumptionParameters = 
getThisQuotaStorageDependent().getQuotaStorageConsumptionParameters();
-                break;
-            case VDS_GROUP:
-                consumptionParameters = 
getThisQuotaVdsDependent().getQuotaVdsConsumptionParameters();
-                break;
-            default:
-                consumptionParameters = 
getThisQuotaStorageDependent().getQuotaStorageConsumptionParameters();
-                
consumptionParameters.addAll(getThisQuotaVdsDependent().getQuotaVdsConsumptionParameters());
-                break;
+        if (consumptionParameters == null) {
+            switch (getActionType().getQuotaDependency()) {
+                case NONE:
+                    return null;
+                case STORAGE:
+                    consumptionParameters = 
getThisQuotaStorageDependent().getQuotaStorageConsumptionParameters();
+                    break;
+                case VDS_GROUP:
+                    consumptionParameters = 
getThisQuotaVdsDependent().getQuotaVdsConsumptionParameters();
+                    break;
+                default:
+                    consumptionParameters = 
getThisQuotaStorageDependent().getQuotaStorageConsumptionParameters();
+                    
consumptionParameters.addAll(getThisQuotaVdsDependent().getQuotaVdsConsumptionParameters());
+                    break;
+            }
         }
         return consumptionParameters;
     }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic64c7bd3352df49f61902bf4f749c7475e402bcc
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: 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