anmolbabu has uploaded a new change for review.

Change subject: engine: geo-rep config entries
......................................................................

engine: geo-rep config entries

This patch fixes the issues of :
1. geo-rep config descriptions being not available
   in geo-rep session config list.
2. use_meta_volume not available in config list

Change-Id: I5d1defdf69cb256a2a872a82a5e54dc6abf6d77b
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1219830
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1224697
Signed-off-by: Anmol Babu <anb...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeGeoRepConfigListQuery.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDao.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoDbFacadeImpl.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoTest.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M packaging/dbscripts/gluster_georep_sp.sql
A 
packaging/dbscripts/upgrade/03_05_1490_insert_and_update_config_description.sql
7 files changed, 74 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/86/42286/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeGeoRepConfigListQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeGeoRepConfigListQuery.java
index 0cd831d..0c2e02e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeGeoRepConfigListQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeGeoRepConfigListQuery.java
@@ -1,5 +1,8 @@
 package org.ovirt.engine.core.bll.gluster;
 
+import java.util.List;
+
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionConfiguration;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
 
 public class GetGlusterVolumeGeoRepConfigListQuery<P extends 
IdQueryParameters> extends GlusterQueriesCommandBase<P> {
@@ -10,7 +13,9 @@
 
     @Override
     protected void executeQueryCommand() {
-        
getQueryReturnValue().setReturnValue(getGeoRepDao().getGeoRepSessionConfig(getParameters().getId()));
+        List<GlusterGeoRepSessionConfiguration> configs = 
getGeoRepDao().getGeoRepSessionConfig(getParameters().getId());
+        
configs.addAll(getGeoRepDao().getGlusterGeoRepSessionUnSetConfig(getParameters().getId()));
+        getQueryReturnValue().setReturnValue(configs);
     }
 
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDao.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDao.java
index 9a1a6f6..7a3998a 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDao.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDao.java
@@ -54,6 +54,8 @@
 
     public List<GlusterGeoRepSessionConfiguration> getGeoRepSessionConfig(Guid 
sessionId);
 
+    public List<GlusterGeoRepSessionConfiguration> 
getGlusterGeoRepSessionUnSetConfig(Guid sessionId);
+
     public GlusterGeoRepSessionConfiguration getGeoRepSessionConfigByKey(Guid 
sessionId, String configKey);
 
     public List<GlusterGeoRepSession> getAllSessions();
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoDbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoDbFacadeImpl.java
index 6a31ee4..556e9a0 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoDbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoDbFacadeImpl.java
@@ -28,6 +28,7 @@
     private static final RowMapper<GlusterGeoRepSession> 
georepSessionRowMapper = new GeoRepSessionRowMapper();
     private static final RowMapper<GlusterGeoRepSessionConfiguration> 
georepSessionConfigRowMapper = new GeoRepSessionConfigRowMapper();
     private static final RowMapper<GlusterGeoRepSessionDetails> 
georepSessionDetailsRowMapper = new GeoRepSessionDetailsRowMapper();
+    private static final RowMapper<GlusterGeoRepSessionConfiguration> 
geoRepSessionConfigMasterRowMapper = new GeoRepSessionConfigMasterRowMapper();
 
     public GlusterGeoRepDaoDbFacadeImpl() {
         super("GlusterGeoRepSession");
@@ -53,14 +54,30 @@
         }
     }
 
-    private static final class GeoRepSessionConfigRowMapper implements 
RowMapper<GlusterGeoRepSessionConfiguration> {
+    private static final class GeoRepSessionConfigRowMapper extends 
GeoRepSessionConfigMasterRowMapper implements 
RowMapper<GlusterGeoRepSessionConfiguration> {
+        @Override
+        public GlusterGeoRepSessionConfiguration mapRow(ResultSet rs, int 
rowNum)
+                throws SQLException {
+            GlusterGeoRepSessionConfiguration entity = super.mapRow(rs, 
rowNum);
+            entity.setId(getGuidDefaultEmpty(rs, "session_id"));
+            entity.setValue(rs.getString("config_value"));
+            return entity;
+        }
+    }
+
+    private static class GeoRepSessionConfigMasterRowMapper implements 
RowMapper<GlusterGeoRepSessionConfiguration> {
+        private Guid sessionId;
+
+        public void setSessionId(Guid sessionId) {
+            this.sessionId = sessionId;
+        }
+
         @Override
         public GlusterGeoRepSessionConfiguration mapRow(ResultSet rs, int 
rowNum)
                 throws SQLException {
             GlusterGeoRepSessionConfiguration entity = new 
GlusterGeoRepSessionConfiguration();
-            entity.setId(getGuidDefaultEmpty(rs, "session_id"));
+            entity.setId(sessionId);
             entity.setKey(rs.getString("config_key"));
-            entity.setValue(rs.getString("config_value"));
             entity.setDescription(rs.getString("config_description"));
             entity.setAllowedValues(rs.getString("config_possible_values") != 
null ? Arrays.asList(rs.getString("config_possible_values")
                     .split(";"))
@@ -163,6 +180,12 @@
     }
 
     @Override
+    public List<GlusterGeoRepSessionConfiguration> 
getGlusterGeoRepSessionUnSetConfig(Guid sessionId) {
+        
((GeoRepSessionConfigMasterRowMapper)geoRepSessionConfigMasterRowMapper).setSessionId(sessionId);
+        return 
getCallsHandler().executeReadList("GetGlusterGeoRepSessionUnSetConfig", 
geoRepSessionConfigMasterRowMapper, createIdParameterMapper(sessionId));
+    }
+
+    @Override
     public GlusterGeoRepSessionConfiguration getGeoRepSessionConfigByKey(Guid 
sessionId, String configKey) {
         return 
getCallsHandler().executeRead("GetGlusterGeoRepSessionConfigByKey", 
georepSessionConfigRowMapper,
                 createIdParameterMapper(sessionId).addValue("config_key", 
configKey));
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoTest.java
index aadcbaf..aa1b901 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/gluster/GlusterGeoRepDaoTest.java
@@ -136,6 +136,14 @@
     }
 
     @Test
+    public void testGetGlusterGeoRepSessionUnSetConfig() {
+        GlusterGeoRepSessionConfiguration sessionConfig = 
getGlusterGeoRepSessionConfig();
+        dao.saveConfig(sessionConfig);
+        List<GlusterGeoRepSessionConfiguration> unsetSessionConfig = 
dao.getGlusterGeoRepSessionUnSetConfig(FixturesTool.GLUSTER_GEOREP_SESSION_ID);
+        assertEquals("use_meta_volume", unsetSessionConfig.get(0).getKey());
+    }
+
+    @Test
     public void testUpdateConfig() {
         GlusterGeoRepSessionConfiguration sessionConfig = 
getGlusterGeoRepSessionConfig();
         dao.saveConfig(sessionConfig);
@@ -172,5 +180,4 @@
         assertNotNull(session);
         assertEquals(FixturesTool.GLUSTER_GEOREP_SESSION_ID, session.getId());
     }
-
 }
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index fdcd6d1..e5d5eee 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -7402,6 +7402,13 @@
              <value></value>
              <value>geo_replication</value>
          </row>
+         <row>
+             <value>use_meta_volume</value>
+             <value>Meta volume for the geo-replication session</value>
+             <value>3.5</value>
+             <value>true;false</value>
+             <value>geo_replication</value>
+         </row>
      </table>
 
      <table name="storage_device">
diff --git a/packaging/dbscripts/gluster_georep_sp.sql 
b/packaging/dbscripts/gluster_georep_sp.sql
index b25c9cc..9e05f59 100644
--- a/packaging/dbscripts/gluster_georep_sp.sql
+++ b/packaging/dbscripts/gluster_georep_sp.sql
@@ -229,6 +229,17 @@
 END; $procedure$
 LANGUAGE plpgsql;
 
+Create or replace FUNCTION GetGlusterGeoRepSessionUnSetConfig(v_session_id 
UUID)
+RETURNS SETOF gluster_config_master STABLE
+AS $procedure$
+BEGIN
+    RETURN QUERY SELECT *
+    FROM  gluster_config_master
+    WHERE gluster_config_master.config_feature = 'geo_replication' AND 
gluster_config_master.config_key NOT IN
+    (SELECT config_key from gluster_georep_config WHERE 
gluster_georep_config.session_id = v_session_id);
+END; $procedure$
+LANGUAGE plpgsql;
+
 Create or replace FUNCTION GetGlusterGeoRepSessionConfigByKey(v_session_id 
UUID,
                                                               v_config_key 
VARCHAR(50))
 RETURNS SETOF gluster_geo_rep_config_view STABLE
diff --git 
a/packaging/dbscripts/upgrade/03_05_1490_insert_and_update_config_description.sql
 
b/packaging/dbscripts/upgrade/03_05_1490_insert_and_update_config_description.sql
new file mode 100644
index 0000000..1314d0e
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_05_1490_insert_and_update_config_description.sql
@@ -0,0 +1,14 @@
+INSERT INTO gluster_config_master(config_key, config_description, 
minimum_supported_cluster, config_possible_values, config_feature)
+ values('use_meta_volume', 'Meta volume for the geo-replication session', 
'3.5', 'true;false', 'geo_replication');
+
+UPDATE gluster_config_master SET
+  config_key=
+  (CASE config_key
+      WHEN 'log-file' THEN 'log_file'
+      WHEN 'gluster-log-file' THEN 'gluster_log_file'
+      WHEN 'ignore-deletes' THEN 'ignore_deletes'
+      WHEN 'ssh-command' THEN 'ssh_command'
+      ELSE config_key
+  END);
+
+UPDATE gluster_config_master SET config_possible_values='true;false' WHERE 
config_key='ignore_deletes';


-- 
To view, visit https://gerrit.ovirt.org/42286
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d1defdf69cb256a2a872a82a5e54dc6abf6d77b
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5-gluster
Gerrit-Owner: anmolbabu <anb...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to