Tal Nisan has uploaded a new change for review.

Change subject: core: Replaced the check of whether a storage pool contains 
mixed type
......................................................................

core: Replaced the check of whether a storage pool contains mixed type

Replaced the check of whether a storage pool contains storage domains of
mixed types to use a designated query that fetches distinct storage types
instead of fetching all the storage domains and filtering by that, in that
way we are fetching less data and eliminating the use for logic in engine
to determine if the domain is mixed thus resulting in better performance

Change-Id: I86cf1512655865831de3cbd16c10a7bc243f08cd
Signed-off-by: Tal Nisan <tni...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
2 files changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/27138/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
index 2de5de6..3a61b68 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBase.java
@@ -216,7 +216,8 @@
         if (!isStorageDomainCompatibleWithDC(storageDomain)) {
             return false;
         }
-        if 
(!isMixedTypesAllowedInDC(getStoragePool().getcompatibility_version()) && 
isMixedTypeDC(storageDomain)) {
+        if (!isStorageDomainOfTypeIsoOrExport(storageDomain ) && 
!isMixedTypesAllowedInDC(getStoragePool().getcompatibility_version())
+                && isMixedTypeDC(storageDomain)) {
             return false;
         }
 
@@ -234,9 +235,9 @@
     public boolean isMixedTypeDC(StorageDomain storageDomain) {
         boolean isBlockDomain = storageDomain.getStorageType().isBlockDomain();
 
-        List<StorageDomain> poolDomains = 
getStorageDomainDAO().getAllForStoragePool(getStoragePoolId());
-        for (StorageDomain currSD : poolDomains) {
-            if (!isStorageDomainOfTypeIsoOrExport(currSD) && 
currSD.getStorageType().isBlockDomain() != isBlockDomain) {
+        List<StorageType> storageTypesOnPool = 
getStoragePoolDAO().getStorageTypesInPool(getStoragePoolId());
+        for (StorageType storageType : storageTypesOnPool) {
+            if (storageType.isBlockDomain() != isBlockDomain) {
                 
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_MIXED_STORAGE_TYPES_NOT_ALLOWED);
                 return true;
             }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
index b44ea13..9c3f8d1 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/storage/StorageHandlingCommandBaseTest.java
@@ -8,6 +8,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.junit.Before;
@@ -157,13 +158,11 @@
     private void testAddingMixedTypes(Version version, boolean 
addingMixedTypesShouldSucceed) {
         storagePool.setcompatibility_version(version);
 
-        StorageDomain existingStorageDomain = createValidStorageDomain();
-        existingStorageDomain.setStorageType(StorageType.NFS);
-        addDomainToPool(existingStorageDomain);
+        // This will make the storage pool show as if he already has an NFS 
domain attached
+        
when(storagePoolDAO.getStorageTypesInPool(storagePool.getId())).thenReturn(Collections.singletonList(StorageType.NFS));
 
         StorageDomain domainToAttach = createValidStorageDomain();
         
domainToAttach.setStorageFormat(cmd.getSupportedStorageFormatSet(version).iterator().next());
-        existingStorageDomain.setStorageType(StorageType.NFS);
         initCommand();
         assertTrue("Attaching an NFS domain to a pool with NFS domain with no 
mixed type allowed failed, version: " + version, 
cmd.checkDomainCanBeAttached(domainToAttach));
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I86cf1512655865831de3cbd16c10a7bc243f08cd
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Tal Nisan <tni...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to