Dhandapani Gopal has uploaded a new change for review.

Change subject: engine: Get Gluster Volume Profile Info Query
......................................................................

engine: Get Gluster Volume Profile Info Query

- New entity classes for Gluster Volume Profile Info
- New XmlRpc class for Profile Info
- New bll and vds query
- New Junit test for the query

Change-Id: Ic47eb168bd4bcd5f3297a7e89a5ef46e643ed73e
Signed-off-by: Dhandapani <[email protected]>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQuery.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterQueriesCommandBase.java
A 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQueryTest.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BlockStats.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BrickProfileDetails.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/FopStats.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeProfileInfo.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/ProfileStatsType.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StatsInfo.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/gluster/GlusterVolumeQueriesParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeProfileInfoVDSParameters.java
M backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
A 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterVolumeProfileInfoVDSCommand.java
A 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterVolumeProfileInfoReturnForXmlRpc.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
21 files changed, 679 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/8646/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQuery.java
new file mode 100644
index 0000000..355055e
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQuery.java
@@ -0,0 +1,47 @@
+package org.ovirt.engine.core.bll.gluster;
+
+import org.ovirt.engine.core.bll.utils.ClusterUtils;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.interfaces.VDSBrokerFrontend;
+import 
org.ovirt.engine.core.common.queries.gluster.GlusterVolumeQueriesParameters;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeProfileInfoVDSParameters;
+import org.ovirt.engine.core.compat.Guid;
+
+
+/**
+ * Query to fetch gluster volume profile info for the given the volume
+ */
+public class GetGlusterVolumeProfileInfoQuery<P extends 
GlusterVolumeQueriesParameters> extends GlusterQueriesCommandBase<P> {
+
+    public GetGlusterVolumeProfileInfoQuery(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected void executeQueryCommand() {
+        VDSReturnValue returnValue =
+                
getBackendResourceManager().RunVdsCommand(VDSCommandType.GetGlusterVolumeProfileInfo,
+                        new 
GlusterVolumeProfileInfoVDSParameters(getParameters().getClusterId(),
+                                getUpServerId(getParameters().getClusterId()),
+                                
getGlusterVolumeName(getParameters().getVolumeId())));
+        getQueryReturnValue().setReturnValue(returnValue.getReturnValue());
+    }
+
+    private Guid getUpServerId(Guid clusterId) {
+        VDS vds = getClusterUtils().getUpServer(clusterId);
+        if (vds == null) {
+            throw new RuntimeException("No up server found");
+        }
+        return vds.getId();
+    }
+
+    protected ClusterUtils getClusterUtils() {
+        return ClusterUtils.getInstance();
+    }
+
+    protected VDSBrokerFrontend getBackendResourceManager() {
+        return getBackend().getResourceManager();
+    }
+}
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 1569320..4d31981 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
@@ -2,6 +2,7 @@
 
 import org.ovirt.engine.core.bll.QueriesCommandBase;
 import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 import org.ovirt.engine.core.dao.gluster.GlusterBrickDao;
 import org.ovirt.engine.core.dao.gluster.GlusterVolumeDao;
@@ -19,4 +20,8 @@
     protected GlusterBrickDao getGlusterBrickDao() {
         return DbFacade.getInstance().getGlusterBrickDao();
     }
+
+    protected String getGlusterVolumeName(Guid volumeId) {
+        return getGlusterVolumeDao().getById(volumeId).getName();
+    }
 }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQueryTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQueryTest.java
new file mode 100644
index 0000000..73b916e
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GetGlusterVolumeProfileInfoQueryTest.java
@@ -0,0 +1,146 @@
+package org.ovirt.engine.core.bll.gluster;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.ovirt.engine.core.bll.AbstractQueryTest;
+import org.ovirt.engine.core.bll.utils.ClusterUtils;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
+import org.ovirt.engine.core.common.businessentities.gluster.BlockStats;
+import 
org.ovirt.engine.core.common.businessentities.gluster.BrickProfileDetails;
+import org.ovirt.engine.core.common.businessentities.gluster.FopStats;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeProfileInfo;
+import org.ovirt.engine.core.common.businessentities.gluster.StatsInfo;
+import org.ovirt.engine.core.common.interfaces.VDSBrokerFrontend;
+import 
org.ovirt.engine.core.common.queries.gluster.GlusterVolumeQueriesParameters;
+import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
+import org.ovirt.engine.core.common.vdscommands.VDSParametersBase;
+import org.ovirt.engine.core.common.vdscommands.VDSReturnValue;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dao.VdsDAO;
+import org.ovirt.engine.core.dao.gluster.GlusterVolumeDao;
+
+@RunWith(MockitoJUnitRunner.class)
+public class GetGlusterVolumeProfileInfoQueryTest extends
+        AbstractQueryTest<GlusterVolumeQueriesParameters, 
GetGlusterVolumeProfileInfoQuery<GlusterVolumeQueriesParameters>> {
+
+    private static final Guid CLUSTER_ID = new 
Guid("b399944a-81ab-4ec5-8266-e19ba7c3c9d1");
+    private static final Guid VOLUME_ID = new 
Guid("b399944a-81ab-4ec5-8266-e19ba7c3c943");
+    private GlusterVolumeProfileInfo expectedProfileInfo;
+    private GlusterVolumeQueriesParameters params;
+
+    @Mock
+    private VDSBrokerFrontend vdsBrokerFrontend;
+
+    @Mock
+    private VdsDAO vdsDao;
+
+    @Mock
+    private ClusterUtils clusterUtils;
+
+    @Mock
+    private GlusterVolumeDao volumeDao;
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        mockVdsDbFacadeAndDao();
+        setupExpectedGlusterVolumeOptionInfo();
+        setupMock();
+    }
+
+    private VDS getVds(VDSStatus status) {
+        VDS vds = new VDS();
+        vds.setId(new Guid());
+        vds.setvds_name("gfs1");
+        vds.setvds_group_id(CLUSTER_ID);
+        vds.setstatus(status);
+        return vds;
+    }
+
+    public void mockVdsDbFacadeAndDao() {
+        
doReturn(Collections.singletonList(getVds(VDSStatus.Up))).when(vdsDao).getAllForVdsGroupWithStatus(CLUSTER_ID,
+                VDSStatus.Up);
+        doReturn(volumeDao).when(getQuery()).getGlusterVolumeDao();
+        doReturn(clusterUtils).when(getQuery()).getClusterUtils();
+        
doReturn(getVds(VDSStatus.Up)).when(clusterUtils).getUpServer(CLUSTER_ID);
+        doReturn(vdsDao).when(clusterUtils).getVdsDao();
+        doReturn("test-vol").when(getQuery()).getGlusterVolumeName(VOLUME_ID);
+    }
+
+    private void setupMock() {
+        
doReturn(vdsBrokerFrontend).when(getQuery()).getBackendResourceManager();
+        VDSReturnValue returnValue = new VDSReturnValue();
+        returnValue.setSucceeded(true);
+        returnValue.setReturnValue(expectedProfileInfo);
+        
doReturn(returnValue).when(vdsBrokerFrontend).RunVdsCommand(eq(VDSCommandType.GetGlusterVolumeProfileInfo),
+                any(VDSParametersBase.class));
+    }
+
+    private void setupExpectedGlusterVolumeOptionInfo() {
+        params = new GlusterVolumeQueriesParameters(CLUSTER_ID, VOLUME_ID);
+        expectedProfileInfo = new GlusterVolumeProfileInfo();
+        expectedProfileInfo.setVolumeId(VOLUME_ID);
+        expectedProfileInfo.setBrickProfileDetails(getBrickProfileDetails());
+    }
+
+    private List<BrickProfileDetails> getBrickProfileDetails() {
+        BrickProfileDetails profileDetails = new BrickProfileDetails();
+        profileDetails.setBrickId(new Guid());
+        profileDetails.setStatsInfo(getStatsInfo());
+        return Collections.singletonList(profileDetails);
+    }
+
+    private List<StatsInfo> getStatsInfo() {
+        StatsInfo statInfo = new StatsInfo();
+        statInfo.setDuration(2);
+        statInfo.setTotalRead(0);
+        statInfo.setTotalWrite(0);
+        statInfo.setBlockStats(getBlockStats());
+        statInfo.setFopStats(getFopStats());
+        return Collections.singletonList(statInfo);
+    }
+
+    private List<FopStats> getFopStats() {
+        FopStats fopStats = new FopStats();
+        fopStats.setAvgLatency(78.12500);
+        fopStats.setName("STATFS");
+        fopStats.setHits(2);
+        fopStats.setMinLatency(39.00000);
+        fopStats.setMaxLatency(143.00000);
+        return Collections.singletonList(fopStats);
+    }
+
+    private List<BlockStats> getBlockStats() {
+        BlockStats blockStats = new BlockStats();
+        blockStats.setSize(128);
+        blockStats.setBlockRead(558);
+        blockStats.setBlockWrite(12345);
+        return Collections.singletonList(blockStats);
+    }
+
+    @Test
+    public void testExecuteQueryCommand() {
+        
doReturn(params.getClusterId()).when(getQueryParameters()).getClusterId();
+        
doReturn(params.getVolumeId()).when(getQueryParameters()).getVolumeId();
+        getQuery().executeQueryCommand();
+        GlusterVolumeProfileInfo glusterVolumeProfileInfo =
+                (GlusterVolumeProfileInfo) 
getQuery().getQueryReturnValue().getReturnValue();
+
+        assertNotNull(glusterVolumeProfileInfo);
+        assertEquals(expectedProfileInfo, glusterVolumeProfileInfo);
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BlockStats.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BlockStats.java
new file mode 100644
index 0000000..da106d5
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BlockStats.java
@@ -0,0 +1,36 @@
+package org.ovirt.engine.core.common.businessentities.gluster;
+
+import java.io.Serializable;
+
+public class BlockStats implements Serializable {
+
+    private static final long serialVersionUID = 4858404369835014372L;
+    private double size;
+    private double blockRead;
+    private double blockWrite;
+
+    public double getSize() {
+        return size;
+    }
+
+    public void setSize(double size) {
+        this.size = size;
+    }
+
+    public double getBlockRead() {
+        return blockRead;
+    }
+
+    public void setBlockRead(double blockRead) {
+        this.blockRead = blockRead;
+    }
+
+    public double getBlockWrite() {
+        return blockWrite;
+    }
+
+    public void setBlockWrite(double blockWrite) {
+        this.blockWrite = blockWrite;
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BrickProfileDetails.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BrickProfileDetails.java
new file mode 100644
index 0000000..bf49e8a
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/BrickProfileDetails.java
@@ -0,0 +1,33 @@
+package org.ovirt.engine.core.common.businessentities.gluster;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.ovirt.engine.core.compat.Guid;
+
+public class BrickProfileDetails implements Serializable {
+
+    private static final long serialVersionUID = 3609367118733238971L;
+
+    private Guid brickId;
+    private List<StatsInfo> statsInfo;
+
+    public BrickProfileDetails() {
+    }
+
+    public Guid getBrickId() {
+        return brickId;
+    }
+
+    public void setBrickId(Guid brickId) {
+        this.brickId = brickId;
+    }
+
+    public List<StatsInfo> getStatsInfo() {
+        return statsInfo;
+    }
+
+    public void setStatsInfo(List<StatsInfo> statsInfo) {
+        this.statsInfo = statsInfo;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/FopStats.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/FopStats.java
new file mode 100644
index 0000000..d076800
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/FopStats.java
@@ -0,0 +1,53 @@
+package org.ovirt.engine.core.common.businessentities.gluster;
+
+import java.io.Serializable;
+
+public class FopStats implements Serializable {
+
+    private static final long serialVersionUID = 3705558577202227092L;
+    private String name;
+    private int hits;
+    private double avgLatency;
+    private double minLatency;
+    private double maxLatency;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getHits() {
+        return hits;
+    }
+
+    public void setHits(int hits) {
+        this.hits = hits;
+    }
+
+    public double getAvgLatency() {
+        return avgLatency;
+    }
+
+    public void setAvgLatency(double avgLatency) {
+        this.avgLatency = avgLatency;
+    }
+
+    public double getMinLatency() {
+        return minLatency;
+    }
+
+    public void setMinLatency(double minLatency) {
+        this.minLatency = minLatency;
+    }
+
+    public double getMaxLatency() {
+        return maxLatency;
+    }
+
+    public void setMaxLatency(double maxLatency) {
+        this.maxLatency = maxLatency;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeProfileInfo.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeProfileInfo.java
new file mode 100644
index 0000000..1bc1c06
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/GlusterVolumeProfileInfo.java
@@ -0,0 +1,37 @@
+package org.ovirt.engine.core.common.businessentities.gluster;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.ovirt.engine.core.compat.Guid;
+
+/**
+ * Class representing information of a Gluster Volume Profile Info
+ *
+ */
+public class GlusterVolumeProfileInfo implements Serializable {
+
+    private static final long serialVersionUID = -768822766895441186L;
+    private Guid volumeId;
+    private List<BrickProfileDetails> brickProfileDetails;
+
+    public GlusterVolumeProfileInfo() {
+    }
+
+    public Guid getVolumeId() {
+        return volumeId;
+    }
+
+    public void setVolumeId(Guid volumeId) {
+        this.volumeId = volumeId;
+    }
+
+    public List<BrickProfileDetails> getBrickProfileDetails() {
+        return brickProfileDetails;
+    }
+
+    public void setBrickProfileDetails(List<BrickProfileDetails> 
brickProfileDetails) {
+        this.brickProfileDetails = brickProfileDetails;
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/ProfileStatsType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/ProfileStatsType.java
new file mode 100644
index 0000000..d430d80
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/ProfileStatsType.java
@@ -0,0 +1,13 @@
+package org.ovirt.engine.core.common.businessentities.gluster;
+
+public enum ProfileStatsType {
+    /**
+     * Gluster Volume Profile Cumulative Stats
+     */
+    CUMULATIVE,
+
+    /**
+     * Gluster Volume Profile Interval Stats
+     */
+    INTERVAL;
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StatsInfo.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StatsInfo.java
new file mode 100644
index 0000000..d1221c5
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StatsInfo.java
@@ -0,0 +1,64 @@
+package org.ovirt.engine.core.common.businessentities.gluster;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class StatsInfo implements Serializable {
+
+    private static final long serialVersionUID = 3609367118733238971L;
+
+    private List<BlockStats> blockStats;
+    private List<FopStats> fopStats;
+    private int duration;
+    private int totalRead;
+    private int totalWrite;
+    private ProfileStatsType profileStatsType;
+
+    public List<BlockStats> getBlockStats() {
+        return blockStats;
+    }
+
+    public void setBlockStats(List<BlockStats> blockStats) {
+        this.blockStats = blockStats;
+    }
+
+    public List<FopStats> getFopStats() {
+        return fopStats;
+    }
+
+    public void setFopStats(List<FopStats> fopStats) {
+        this.fopStats = fopStats;
+    }
+
+    public int getDuration() {
+        return duration;
+    }
+
+    public void setDuration(int duration) {
+        this.duration = duration;
+    }
+
+    public int getTotalRead() {
+        return totalRead;
+    }
+
+    public void setTotalRead(int totalRead) {
+        this.totalRead = totalRead;
+    }
+
+    public int getTotalWrite() {
+        return totalWrite;
+    }
+
+    public void setTotalWrite(int totalWrite) {
+        this.totalWrite = totalWrite;
+    }
+
+    public ProfileStatsType getProfileStatsType() {
+        return profileStatsType;
+    }
+
+    public void setProfileStatsType(ProfileStatsType profileStatsType) {
+        this.profileStatsType = profileStatsType;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
index 5ee4de9..cf72fda 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
@@ -340,8 +340,9 @@
     GlusterVolumeReplaceBrickStartFailed(4142),
     GlusterVolumeProfileStartFailed(4158),
     GlusterVolumeProfileStopFailed(4159),
-    GlusterHostRemoveFailed(4406),
+    GlusterVolumeProfileInfoFailed(4160),
     GlusterAddHostFailed(4404),
+    GlusterHostRemoveFailed(4406),
     GlusterPeerListFailed(4407),
 
     UnicodeArgumentException(4900),
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 a1c5bee..befee1c 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
@@ -278,6 +278,7 @@
     GetServerSSHKeyFingerprint,
     GetGlusterServers,
     GetAddedGlusterServers,
+    GetGlusterVolumeProfileInfo,
 
     // Default type instead of having to null check
     Unknown(VdcQueryAuthType.User);
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/gluster/GlusterVolumeQueriesParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/gluster/GlusterVolumeQueriesParameters.java
new file mode 100644
index 0000000..a516fd0
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/gluster/GlusterVolumeQueriesParameters.java
@@ -0,0 +1,27 @@
+package org.ovirt.engine.core.common.queries.gluster;
+
+import org.ovirt.engine.core.compat.Guid;
+
+/**
+ * Parameter class with volume id as parameter which extends from 
GlusterParameters. <br>
+ * This will be used by gluster volume profile info command.
+ */
+public class GlusterVolumeQueriesParameters extends GlusterParameters {
+
+    private static final long serialVersionUID = 199106704417008718L;
+    private Guid volumeId;
+
+    public GlusterVolumeQueriesParameters(Guid clusterId, Guid volumeId) {
+        super(clusterId);
+        setVolumeId(volumeId);
+    }
+
+    public Guid getVolumeId() {
+        return volumeId;
+    }
+
+    public void setVolumeId(Guid volumeId) {
+        this.volumeId = volumeId;
+    }
+
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
index 57f63ea..27050db 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java
@@ -140,6 +140,7 @@
     GlusterServersList("org.ovirt.engine.core.vdsbroker.gluster"),
     StartGlusterVolumeProfile("org.ovirt.engine.core.vdsbroker.gluster"),
     StopGlusterVolumeProfile("org.ovirt.engine.core.vdsbroker.gluster"),
+    GetGlusterVolumeProfileInfo("org.ovirt.engine.core.vdsbroker.gluster"),
     ;
 
     String packageName;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeProfileInfoVDSParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeProfileInfoVDSParameters.java
new file mode 100644
index 0000000..789e74c
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/GlusterVolumeProfileInfoVDSParameters.java
@@ -0,0 +1,21 @@
+package org.ovirt.engine.core.common.vdscommands.gluster;
+
+import org.ovirt.engine.core.compat.Guid;
+
+/**
+ * VDS parameter class with serverId, clusterId and volume name as parameter. 
<br>
+ * This will be used directly by Gluster Volume Profile Info Query.
+ */
+public class GlusterVolumeProfileInfoVDSParameters extends 
GlusterVolumeVDSParameters {
+    private final Guid clusterId;
+
+    public GlusterVolumeProfileInfoVDSParameters(Guid clusterId, Guid 
serverId, String volumeName) {
+        super(serverId, volumeName);
+        this.clusterId = clusterId;
+    }
+
+    public Guid getClusterId() {
+        return clusterId;
+    }
+
+}
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
index 87984c3..225678a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/VdsmErrors.properties
@@ -324,6 +324,7 @@
 GlusterPeerListFailed=Gluster Peer List Failed
 GlusterVolumeProfileStartFailed=Gluster Volume Profile Start Failed
 GlusterVolumeProfileStopFailed=Gluster Volume Profile Stop Failed
+GlusterVolumeProfileInfoFailed=Gluster Volume Profile Info Failed
 
 CANT_RECONSTRUCT_WHEN_A_DOMAIN_IN_POOL_IS_LOCKED=Can't reconstruct the Master 
Domain when the Data Center contains Domains in Locked state.\nPlease wait 
until the operation for these Domains ends before trying to reconstruct the 
Master Domain again.
 NO_IMPLEMENTATION=Not implemented
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
index 2402b57..73b50b3 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/AbstractGlusterBrokerCommand.java
@@ -33,6 +33,7 @@
         case GlusterPeerListFailed:
         case GlusterVolumeProfileStartFailed:
         case GlusterVolumeProfileStopFailed:
+        case GlusterVolumeProfileInfoFailed:
             // Capture error from gluster command and record failure
             getVDSReturnValue().setVdsError(new VDSError(returnStatus, 
getReturnStatus().mMessage));
             getVDSReturnValue().setSucceeded(false);
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterVolumeProfileInfoVDSCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterVolumeProfileInfoVDSCommand.java
new file mode 100644
index 0000000..037c13c
--- /dev/null
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetGlusterVolumeProfileInfoVDSCommand.java
@@ -0,0 +1,25 @@
+package org.ovirt.engine.core.vdsbroker.gluster;
+
+import 
org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeProfileInfoVDSParameters;
+import 
org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeProfileInfoReturnForXmlRpc;
+import org.ovirt.engine.core.vdsbroker.vdsbroker.StatusForXmlRpc;
+
+public class GetGlusterVolumeProfileInfoVDSCommand<P extends 
GlusterVolumeProfileInfoVDSParameters> extends AbstractGlusterBrokerCommand<P> {
+    private GlusterVolumeProfileInfoReturnForXmlRpc result;
+
+    public GetGlusterVolumeProfileInfoVDSCommand(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected StatusForXmlRpc getReturnStatus() {
+        return result.getmStatus();
+    }
+
+    @Override
+    protected void ExecuteVdsBrokerCommand() {
+        result = 
getBroker().glusterVolumeProfileInfo(getParameters().getClusterId(), 
getParameters().getVolumeName());
+        ProceedProxyReturnValue();
+        setReturnValue(result.getGlusterVolumeProfileInfo());
+    }
+}
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterVolumeProfileInfoReturnForXmlRpc.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterVolumeProfileInfoReturnForXmlRpc.java
new file mode 100644
index 0000000..d900929
--- /dev/null
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/GlusterVolumeProfileInfoReturnForXmlRpc.java
@@ -0,0 +1,147 @@
+package org.ovirt.engine.core.vdsbroker.irsbroker;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.ovirt.engine.core.common.businessentities.gluster.BlockStats;
+import 
org.ovirt.engine.core.common.businessentities.gluster.BrickProfileDetails;
+import org.ovirt.engine.core.common.businessentities.gluster.FopStats;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
+import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeProfileInfo;
+import org.ovirt.engine.core.common.businessentities.gluster.ProfileStatsType;
+import org.ovirt.engine.core.common.businessentities.gluster.StatsInfo;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.ovirt.engine.core.dao.gluster.GlusterVolumeDao;
+import org.ovirt.engine.core.vdsbroker.vdsbroker.StatusForXmlRpc;
+
+@SuppressWarnings("unchecked")
+public final class GlusterVolumeProfileInfoReturnForXmlRpc extends 
StatusReturnForXmlRpc {
+
+    private static final String STATUS = "status";
+    private static final String PROFILE_INFO = "profileInfo";
+    private static final String VOLUME_NAME = "volumeName";
+    private static final String BRICKS = "bricks";
+    private static final String BRICK = "brick";
+    private static final String CUMULATIVE_STATS = "cumulativeStats";
+    private static final String BLOCK_STATS = "blockStats";
+    private static final String FOP_STATS = "fopStats";
+    private static final String DURATION = "duration";
+    private static final String TOTAL_READ = "totalRead";
+    private static final String TOTAL_WRITE = "totalWrite";
+    private static final String INTERVAL_STATS = "intervalStats";
+    private static final String SIZE = "size";
+    private static final String READ = "read";
+    private static final String WRITE = "write";
+    private static final String NAME = "name";
+    private static final String HITS = "hits";
+    private static final String LATENCY_AVG = "latencyAvg";
+    private static final String LATENCY_MIN = "latencyMin";
+    private static final String LATENCY_MAX = "latencyMax";
+
+    private StatusForXmlRpc mStatus;
+
+    public StatusForXmlRpc getmStatus() {
+        return mStatus;
+    }
+
+    public void setmStatus(StatusForXmlRpc mStatus) {
+        this.mStatus = mStatus;
+    }
+
+    private GlusterVolumeProfileInfo glusterVolumeProfileInfo = new 
GlusterVolumeProfileInfo();
+
+    public GlusterVolumeProfileInfo getGlusterVolumeProfileInfo() {
+        return glusterVolumeProfileInfo;
+    }
+
+    public GlusterVolumeProfileInfoReturnForXmlRpc(Guid clusterId, Map<String, 
Object> innerMap) {
+        super(innerMap);
+        mStatus = new StatusForXmlRpc((Map<String, Object>) 
innerMap.get(STATUS));
+
+        Map<String, Object> profileInfo = (Map<String, Object>) 
innerMap.get(PROFILE_INFO);
+        if (profileInfo != null) {
+            String volumeName = (String) profileInfo.get(VOLUME_NAME);
+            GlusterVolumeEntity volume = 
getGlusterVolumeDao().getByName(clusterId, volumeName);
+
+            glusterVolumeProfileInfo.setVolumeId(volume.getId());
+            
glusterVolumeProfileInfo.setBrickProfileDetails(prepareBrickProfileDetails(volume,
+                    (Object[]) profileInfo.get(BRICKS)));
+        }
+    }
+
+    private List<BrickProfileDetails> 
prepareBrickProfileDetails(GlusterVolumeEntity volume,
+            Object[] brickProfileDetails) {
+        List<BrickProfileDetails> brickProfileDetailsList = new 
ArrayList<BrickProfileDetails>();
+        for (Object brickProfileObj : brickProfileDetails) {
+            BrickProfileDetails brickProfileDetail = new BrickProfileDetails();
+            Map<String, Object> brickProfile = (Map<String, Object>) 
brickProfileObj;
+            brickProfileDetail.setBrickId(getBrickId(volume.getBricks(), 
(String) brickProfile.get(BRICK)));
+
+            List<StatsInfo> statsInfo = new ArrayList<StatsInfo>();
+            statsInfo.add(getStatInfo((Map<String, Object>) 
brickProfile.get(CUMULATIVE_STATS), CUMULATIVE_STATS));
+            statsInfo.add(getStatInfo((Map<String, Object>) 
brickProfile.get(INTERVAL_STATS), INTERVAL_STATS));
+            brickProfileDetail.setStatsInfo(statsInfo);
+            brickProfileDetailsList.add(brickProfileDetail);
+        }
+        return brickProfileDetailsList;
+    }
+
+    private StatsInfo getStatInfo(Map<String, Object> statsInfoMap, String 
statType) {
+        StatsInfo statsInfo = new StatsInfo();
+        statsInfo.setDuration(Integer.valueOf((String) 
statsInfoMap.get(DURATION)));
+        statsInfo.setTotalWrite(Integer.valueOf((String) 
statsInfoMap.get(TOTAL_WRITE)));
+        statsInfo.setTotalRead(Integer.valueOf((String) 
statsInfoMap.get(TOTAL_READ)));
+        statsInfo.setBlockStats(getBlockStats((Object[]) 
statsInfoMap.get(BLOCK_STATS)));
+        statsInfo.setFopStats(getFopStats((Object[]) 
statsInfoMap.get(FOP_STATS)));
+        statsInfo.setProfileStatsType((statType.equals(CUMULATIVE_STATS) ? 
ProfileStatsType.CUMULATIVE
+                : ProfileStatsType.INTERVAL));
+        return statsInfo;
+    }
+
+    private List<FopStats> getFopStats(Object[] fopStatsObjects) {
+        List<FopStats> fopStatsList = new ArrayList<FopStats>();
+        for (Object fopStatsObj : fopStatsObjects) {
+            FopStats fopStats = new FopStats();
+            Map<String, Object> fopStatsMap = (Map<String, Object>) 
fopStatsObj;
+            fopStats.setHits(Integer.valueOf((String) fopStatsMap.get(HITS)));
+            fopStats.setName((String) fopStatsMap.get(NAME));
+            fopStats.setMinLatency(Double.valueOf((String) 
fopStatsMap.get(LATENCY_MIN)));
+            fopStats.setMaxLatency(Double.valueOf((String) 
fopStatsMap.get(LATENCY_MAX)));
+            fopStats.setAvgLatency(Double.valueOf((String) 
fopStatsMap.get(LATENCY_AVG)));
+            fopStatsList.add(fopStats);
+        }
+        return fopStatsList;
+    }
+
+    private List<BlockStats> getBlockStats(Object[] blockStatsObjects) {
+        List<BlockStats> blockStatsList = new ArrayList<BlockStats>();
+        for (Object blockStatsObj : blockStatsObjects) {
+            BlockStats blockStats = new BlockStats();
+            Map<String, Object> blockStatsMap = (Map<String, Object>) 
blockStatsObj;
+            blockStats.setSize(Double.valueOf((String) 
blockStatsMap.get(SIZE)));
+            blockStats.setBlockRead(Double.valueOf((String) 
blockStatsMap.get(READ)));
+            blockStats.setBlockWrite(Double.valueOf((String) 
blockStatsMap.get(WRITE)));
+            blockStatsList.add(blockStats);
+        }
+        return blockStatsList;
+    }
+
+    private Guid getBrickId(List<GlusterBrickEntity> bricksList, String 
qualifiedBrickName) {
+        for (GlusterBrickEntity brick : bricksList) {
+            // Compare the brickname with the existing volume brick
+            if (brick.getQualifiedName().equals(qualifiedBrickName)) {
+                return brick.getId();
+            }
+        }
+        // It is possible that the brick is not found, in cases where user has 
added more bricks to the volume directly
+        // using gluster CLI (and this change has not been synced yet by the 
GlusterManager).
+        return null;
+    }
+
+    protected GlusterVolumeDao getGlusterVolumeDao() {
+        return DbFacade.getInstance().getGlusterVolumeDao();
+    }
+}
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
index 557eedb..574cfb3 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java
@@ -4,8 +4,10 @@
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
 
+import org.ovirt.engine.core.compat.Guid;
 import 
org.ovirt.engine.core.vdsbroker.irsbroker.GlusterServersListReturnForXmlRpc;
 import 
org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeOptionsInfoReturnForXmlRpc;
+import 
org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeProfileInfoReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.irsbroker.IsoListReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.xmlrpc.XmlRpcStruct;
@@ -240,4 +242,6 @@
 
     StatusOnlyReturnForXmlRpc glusterVolumeProfileStop(String volumeName);
 
+    GlusterVolumeProfileInfoReturnForXmlRpc glusterVolumeProfileInfo(Guid 
clusterId, String volumeName);
+
 }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
index 15c9708..85faff0 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java
@@ -235,4 +235,6 @@
 
     public Map<String, Object> glusterVolumeProfileStop(String volumeName);
 
+    public Map<String, Object> glusterVolumeProfileInfo(String volumeName);
+
 }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
index 198503e..f0514cc 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java
@@ -6,8 +6,10 @@
 import java.util.concurrent.FutureTask;
 
 import org.apache.commons.httpclient.HttpClient;
+import org.ovirt.engine.core.compat.Guid;
 import 
org.ovirt.engine.core.vdsbroker.irsbroker.GlusterServersListReturnForXmlRpc;
 import 
org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeOptionsInfoReturnForXmlRpc;
+import 
org.ovirt.engine.core.vdsbroker.irsbroker.GlusterVolumeProfileInfoReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.irsbroker.IsoListReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc;
 import org.ovirt.engine.core.vdsbroker.xmlrpc.XmlRpcRunTimeException;
@@ -1167,4 +1169,15 @@
         }
     }
 
+    @Override
+    public GlusterVolumeProfileInfoReturnForXmlRpc 
glusterVolumeProfileInfo(Guid clusterId, String volumeName) {
+        try {
+            Map<String, Object> xmlRpcReturnValue = 
vdsServer.glusterVolumeProfileInfo(volumeName);
+            GlusterVolumeProfileInfoReturnForXmlRpc wrapper =
+                    new GlusterVolumeProfileInfoReturnForXmlRpc(clusterId, 
xmlRpcReturnValue);
+            return wrapper;
+        } catch (UndeclaredThrowableException ute) {
+            throw new XmlRpcRunTimeException(ute);
+        }
+    }
 }


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

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

Reply via email to