Shubhendu Tripathi has uploaded a new change for review.

Change subject: gluster: BLL query to get volume snapshot configurations
......................................................................

gluster: BLL query to get volume snapshot configurations

Introduced BLL query to get the gluster volume snapshot configuration
parameter details.
If sync job is not yet executed and data not available in DB, it gets
the details from gluster using a VDS call.

Change-Id: I4374b51297549731bc6c93c8a72b033ca64fdfef
Signed-off-by: Shubhendu Tripathi <[email protected]>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotConfigParam.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
4 files changed, 92 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/36292/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java
new file mode 100644
index 0000000..f8987a7
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeSnapshotConfigQuery.java
@@ -0,0 +1,76 @@
+package org.ovirt.engine.core.bll.gluster;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotConfigInfo;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfigParam;
+import 
org.ovirt.engine.core.common.queries.gluster.GlusterVolumeQueriesParameters;
+import org.ovirt.engine.core.common.utils.Pair;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotConfigVDSParameters;
+import org.ovirt.engine.core.compat.Guid;
+
+public class GetGlusterVolumeSnapshotConfigQuery<P extends 
GlusterVolumeQueriesParameters> extends GlusterQueriesCommandBase<P> {
+    public GetGlusterVolumeSnapshotConfigQuery(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    public void executeQueryCommand() {
+        Guid clusterId = getParameters().getClusterId();
+        Guid volumeId = getParameters().getVolumeId();
+        List<GlusterVolumeSnapshotConfigParam> configs =
+                
getGlusterVolumeSnapshotConfigDao().getGlusterVolumeSnapshotConfigByClusterId(clusterId);
+
+        List<GlusterVolumeSnapshotConfigParam> clusterCfgs = new 
ArrayList<GlusterVolumeSnapshotConfigParam>();
+        List<GlusterVolumeSnapshotConfigParam> volumeCfgs = new 
ArrayList<GlusterVolumeSnapshotConfigParam>();
+        if (configs != null && configs.size() > 0) {
+            for (GlusterVolumeSnapshotConfigParam config : configs) {
+                if (Guid.isNullOrEmpty(config.getVolumeId())) {
+                    clusterCfgs.add(config);
+                } else if (volumeId != null && 
config.getVolumeId().equals(volumeId)) {
+                    volumeCfgs.add(config);
+                }
+            }
+            getQueryReturnValue().setReturnValue(new 
Pair<List<GlusterVolumeSnapshotConfigParam>, 
List<GlusterVolumeSnapshotConfigParam>>(clusterCfgs,
+                    volumeCfgs));
+        } else {
+
+            String volumeName = volumeId == null ? "" : 
getGlusterVolumeDao().getById(volumeId).getName();
+            Guid serverId = getRandomUpServerId(clusterId);
+            VDSReturnValue returnValue = 
runVdsCommand(VDSCommandType.GetGlusterVolumeSnapshotConfigInfo,
+                    new GlusterVolumeSnapshotConfigVDSParameters(clusterId, 
serverId, volumeName));
+            if (returnValue.getSucceeded()) {
+                GlusterSnapshotConfigInfo fetchedConfigInfo = 
(GlusterSnapshotConfigInfo) returnValue.getReturnValue();
+                if (fetchedConfigInfo != null) {
+                    clusterCfgs.add(new 
GlusterVolumeSnapshotConfigParam(clusterId,
+                            volumeId,
+                            "snap-max-hard-limit",
+                            
fetchedConfigInfo.getSystemSnapMaxHardLimit().toString()));
+                    clusterCfgs.add(new 
GlusterVolumeSnapshotConfigParam(clusterId,
+                            volumeId,
+                            "snap-max-soft-limit",
+                            
fetchedConfigInfo.getSystemSoftLimitPcnt().toString()));
+                    clusterCfgs.add(new 
GlusterVolumeSnapshotConfigParam(clusterId,
+                            volumeId,
+                            "auto-delete",
+                            
fetchedConfigInfo.isAutoDeleteEnabled().toString()));
+                    List<GlusterSnapshotConfigInfo.VolumeSnapshotConfigInfo> 
fetchedVolumeCfgs =
+                            fetchedConfigInfo.getVolumeConfigList();
+                    if (volumeId != null && fetchedVolumeCfgs != null) {
+                        // There would be a single entry in the list for 
specific volume
+                        // so its safe to get the first entry and 
configuration from it
+                        volumeCfgs.add(new 
GlusterVolumeSnapshotConfigParam(clusterId,
+                                volumeId,
+                                "snap-max-hard-limit",
+                                
fetchedVolumeCfgs.get(0).getVolumeSnapMaxHardLimit().toString()));
+                    }
+                }
+            }
+            getQueryReturnValue().setReturnValue(new 
Pair<List<GlusterVolumeSnapshotConfigParam>, 
List<GlusterVolumeSnapshotConfigParam>>(clusterCfgs,
+                    volumeCfgs));
+        }
+    }
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java
index fc5949d..e9c261d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java
@@ -18,6 +18,7 @@
 import org.ovirt.engine.core.dao.gluster.GlusterHooksDao;
 import org.ovirt.engine.core.dao.gluster.GlusterServerServiceDao;
 import org.ovirt.engine.core.dao.gluster.GlusterVolumeDao;
+import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotConfigDao;
 import org.ovirt.engine.core.dao.gluster.GlusterVolumeSnapshotDao;
 
 public abstract class GlusterQueriesCommandBase<P extends 
VdcQueryParametersBase> extends QueriesCommandBase<P> {
@@ -66,6 +67,10 @@
         return DbFacade.getInstance().getGlusterVolumeSnapshotDao();
     }
 
+    protected GlusterVolumeSnapshotConfigDao 
getGlusterVolumeSnapshotConfigDao() {
+        return DbFacade.getInstance().getGlusterVolumeSnapshotConfigDao();
+    }
+
     protected Guid getUpServerId(Guid clusterId) {
         VDS vds = getClusterUtils().getUpServer(clusterId);
         if (vds == null) {
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotConfigParam.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotConfigParam.java
index 831df33..ddfbe55 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotConfigParam.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeSnapshotConfigParam.java
@@ -10,6 +10,16 @@
     private String paramName;
     private String paramValue;
 
+    public GlusterVolumeSnapshotConfigParam() {
+    }
+
+    public GlusterVolumeSnapshotConfigParam(Guid clusterId, Guid volumeId, 
String paramName, String paramValue) {
+        this.clusterId = clusterId;
+        this.volumeId = volumeId;
+        this.paramName = paramName;
+        this.paramValue = paramValue;
+    }
+
     public Guid getClusterId() {
         return this.clusterId;
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
index 54d5b7f..1db4b8b 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
@@ -339,6 +339,7 @@
     GetGlusterVolumeByTaskId,
     GetGlusterVolumeSnapshotsByVolumeId,
     GetGlusterVolumeSnapshotsCountByVolumeId,
+    GetGlusterVolumeSnapshotConfig,
 
     GetDefaultConfigurationVersion(VdcQueryAuthType.User),
     OsRepository(VdcQueryAuthType.User),


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

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

Reply via email to