Arik Hadas has uploaded a new change for review.

Change subject: core: improve active iso domain lookup
......................................................................

core: improve active iso domain lookup

The lookup for active iso domain at
IsoDomainListSyncronizer#findActiveISODomain access the DB twice: at
first to fetch all the domains in the given storage pool and then it
access the DB again to fetch a given domain within the same storate
pool. the second access seems to be redundant since the fetched domain
already exists in the list that was return from the first query, thus
the second query is removed.

Change-Id: I8859a85107f8c2e658c23d6a04b69d0201d086d5
Signed-off-by: Arik Hadas <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java
1 file changed, 4 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/17578/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java
index ded6d6b..7770d18 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java
@@ -749,20 +749,15 @@
      * @return Iso Guid of active Iso, and null if not.
      */
     public Guid findActiveISODomain(Guid storagePoolId) {
-        Guid isoGuid = null;
         List<StorageDomain> domains = 
getStorageDomainDAO().getAllForStoragePool(
                 storagePoolId);
         for (StorageDomain domain : domains) {
-            if (domain.getStorageDomainType() == StorageDomainType.ISO) {
-                StorageDomain sd = 
getStorageDomainDAO().getForStoragePool(domain.getId(),
-                        storagePoolId);
-                if (sd != null && sd.getStatus() == 
StorageDomainStatus.Active) {
-                    isoGuid = sd.getId();
-                    break;
-                }
+            if (domain.getStorageDomainType() == StorageDomainType.ISO &&
+                    domain.getStatus() == StorageDomainStatus.Active) {
+                return domain.getId();
             }
         }
-        return isoGuid;
+        return null;
     }
 
     private StorageDomainDAO getStorageDomainDAO() {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8859a85107f8c2e658c23d6a04b69d0201d086d5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to