Liron Aravot has uploaded a new change for review.

Change subject: core: avoid connect to the same target multiple times
......................................................................

core: avoid connect to the same target multiple times

When querying for the storage server connections of a VG, there's no
need to return the same connection multiple times if the it's the same
to avoid multiple operations on engine and on vdsm side. As we currently
have one session for target, so this shouldn't cause to regression while
eliminating unneeded operations.

before:
-------
engine:
START, ConnectStorageServerVDSCommand connectionList =
[{ id: 1212f182-9593-4cef-8c98-a3e99bf29fa2... };
{ id: 1212f182-9593-4cef-8c98-a3e99bf29fa2... };
{ id: 1212f182-9593-4cef-8c98-a3e99bf29fa2, ... };]),

vdsm:
Run and protect: connectStorageServer, Return response: {'statuslist':
[{'status': 0, 'id': '1212f182-9593-4cef-8c98-a3e99bf29fa2'}, {'status':
0, 'id': '1212f182-9593-4cef-8c98-a3e99bf29fa2'}, {'status': 0, 'id':
'1212f182-9593-4cef-8c98-a3e99bf29fa2'}]}

after:
-------
engine:
connectionList = [{ id: 1212f182-9593-4cef-8c98-a3e99bf29fa2, ..};])

vdsm:
Run and protect: connectStorageServer, Return response: {'statuslist': [{'stat
us': 0, 'id': '1212f182-9593-4cef-8c98-a3e99bf29fa2'}]}

Change-Id: If40ef468dc4eca4237ad824dc81aa39a90cce017
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1111994
Signed-off-by: Liron Aravot <lara...@redhat.com>
---
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M packaging/dbscripts/storages_san_sp.sql
4 files changed, 31 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/35/29035/1

diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java
index 41a9844..0efece3 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java
@@ -358,6 +358,11 @@
      */
     protected static final String LUN_ID_FOR_DISK = "1IET_00180002";
 
+
+    protected static final String LUN_ID1= "1IET_00180001";
+
+    protected static final String LUN_ID2= "1IET_00180003";
+
     /**
      * Predefined boot LUN disk attached to VM_RHEL5_POOL_57
      */
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
index 3b05329..3b83ce1 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/StorageServerConnectionDAOTest.java
@@ -10,11 +10,14 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.EnumSet;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.commons.collections.CollectionUtils;
 import org.junit.Test;
+import 
org.ovirt.engine.core.common.businessentities.LUN_storage_server_connection_map;
 import org.ovirt.engine.core.common.businessentities.NfsVersion;
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
 import org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap;
@@ -206,17 +209,33 @@
         assertTrue("the connections loaded by the given dao function should 
match the connections loaded separately",
                 CollectionUtils.isEqualCollection(domainConnections, result));
     }
+
+    private Set<String> 
getLunConnections(List<LUN_storage_server_connection_map> lunConns) {
+        Set<String> conns = new HashSet<>();
+        for (LUN_storage_server_connection_map 
lun_storage_server_connection_map1 : lunConns) {
+            
conns.add(lun_storage_server_connection_map1.getstorage_server_connection());
+        }
+        return conns;
+    }
     /**
      * Retrieves all connections for the given volume group.
      *
      */
     @Test
     public void testgetAllForVolumeGroup() {
+        Set<String> lunConns1 = 
getLunConnections(dbFacade.getStorageServerConnectionLunMapDao().getAll(FixturesTool.LUN_ID1));
+        Set<String> lunConns2 = 
getLunConnections(dbFacade.getStorageServerConnectionLunMapDao().getAll(FixturesTool.LUN_ID2));
+        assertTrue("Both LUNs should have at least one mutual connection",
+                CollectionUtils.containsAny(lunConns1, lunConns2));
+
         List<StorageServerConnections> result =
                 dao.getAllForVolumeGroup(EXISTING_DOMAIN_STORAGE_NAME);
-
-        assertNotNull(result);
         assertFalse(result.isEmpty());
+        Set<String> connections  = new HashSet<>();
+        for (StorageServerConnections connection : result) {
+            assertFalse(connections.contains(connection.getid()));
+            connections.add(connection.getid());
+        }
     }
 
     /**
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index 7f010d1..e60c603 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -348,6 +348,10 @@
             <value>1IET_00180002</value>
             <value>fDMzhE-wx3s-zo3q-Qcxd-T0li-yoYU-QvVePk</value>
         </row>
+        <row>
+            <value>1IET_00180003</value>
+            <value>0cc146e8-e5ed-482c-8814-270bc48c297e</value>
+        </row>
     </table>
 
     <table name="tags">
diff --git a/packaging/dbscripts/storages_san_sp.sql 
b/packaging/dbscripts/storages_san_sp.sql
index f2e822e..3bbc752 100644
--- a/packaging/dbscripts/storages_san_sp.sql
+++ b/packaging/dbscripts/storages_san_sp.sql
@@ -517,7 +517,7 @@
 Create or replace FUNCTION 
Getstorage_server_connectionsByVolumeGroupId(v_volume_group_id VARCHAR(50)) 
RETURNS SETOF storage_server_connections STABLE
    AS $procedure$
 BEGIN
-   RETURN QUERY SELECT storage_server_connections.*
+   RETURN QUERY SELECT DISTINCT storage_server_connections.*
    FROM
    LUN_storage_server_connection_map  LUN_storage_server_connection_map
    INNER JOIN


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If40ef468dc4eca4237ad824dc81aa39a90cce017
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Aravot <lara...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to