Tal Nisan has uploaded a new change for review.

Change subject: core, restapi: Replaced system stats query fields with 
constancts
......................................................................

core, restapi: Replaced system stats query fields with constancts

Replaced the hard coded String fields returning in GetSystemStatistics
query to constants, also changed the call to this query in the REST to use
the contstants when parsing the result

Change-Id: I1a2e3fc22c4c8228ec9362d1fb2a608c4db4746c
Signed-off-by: Tal Nisan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSystemStatisticsQuery.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/QueryConstants.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java
3 files changed, 40 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/12143/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSystemStatisticsQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSystemStatisticsQuery.java
index 98b0435..08143f1 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSystemStatisticsQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetSystemStatisticsQuery.java
@@ -4,6 +4,7 @@
 import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
+import org.ovirt.engine.core.common.constants.gluster.QueryConstants;
 import org.ovirt.engine.core.common.queries.GetSystemStatisticsQueryParameters;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
 
@@ -93,17 +94,17 @@
         int active_storage_domains = 
DbFacade.getInstance().getSystemStatisticsValue("ASD",
                 (Integer.toString(StorageDomainStatus.Active.getValue())));
 
-        res.put("total_vms", total_vms);
-        res.put("active_vms", active_vms);
-        res.put("down_vms", down_vms);
-        res.put("total_vds", total_vds);
-        res.put("active_vds", active_vds);
-        res.put("maintenance_vds", maintenance_vds);
-        res.put("down_vds", down_vds);
-        res.put("total_users", total_users);
-        res.put("active_users", active_users);
-        res.put("total_storage_domains", total_storage_domains);
-        res.put("active_storage_domains", active_storage_domains);
+        res.put(QueryConstants.SYSTEM_STATS_TOTAL_VMS_FIELD, total_vms);
+        res.put(QueryConstants.SYSTEM_STATS_ACTIVE_VMS_FIELD, active_vms);
+        res.put(QueryConstants.SYSTEM_STATS_DOWN_VMS_FIELD, down_vms);
+        res.put(QueryConstants.SYSTEM_STATS_TOTAL_HOSTS_FIELD, total_vds);
+        res.put(QueryConstants.SYSTEM_STATS_ACTIVE_HOSTS_FIELD, active_vds);
+        res.put(QueryConstants.SYSTEM_STATS_MAINTENANCE_HOSTS_FIELD, 
maintenance_vds);
+        res.put(QueryConstants.SYSTEM_STATS_DOWN_HOSTS_FIELD, down_vds);
+        res.put(QueryConstants.SYSTEM_STATS_TOTAL_USERS_FIELD, total_users);
+        res.put(QueryConstants.SYSTEM_STATS_ACTIVE_USERS_FIELD, active_users);
+        res.put(QueryConstants.SYSTEM_STATS_TOTAL_STORAGE_DOMAINS_FIELD, 
total_storage_domains);
+        res.put(QueryConstants.SYSTEM_STATS_ACTIVE_STORAGE_DOMAINS_FIELD, 
active_storage_domains);
 
         return res;
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/QueryConstants.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/QueryConstants.java
new file mode 100644
index 0000000..ef7385e
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/constants/gluster/QueryConstants.java
@@ -0,0 +1,19 @@
+package org.ovirt.engine.core.common.constants.gluster;
+
+public class QueryConstants {
+    private QueryConstants() {
+    }
+
+    public static final String SYSTEM_STATS_TOTAL_VMS_FIELD = "total_vms";
+    public static final String SYSTEM_STATS_ACTIVE_VMS_FIELD = "active_vms";
+    public static final String SYSTEM_STATS_DOWN_VMS_FIELD = "down_vms";
+    public static final String SYSTEM_STATS_TOTAL_HOSTS_FIELD = "total_vds";
+    public static final String SYSTEM_STATS_ACTIVE_HOSTS_FIELD = "active_vds";
+    public static final String SYSTEM_STATS_MAINTENANCE_HOSTS_FIELD = 
"maintenance_vds";
+    public static final String SYSTEM_STATS_DOWN_HOSTS_FIELD = "down_vds";
+    public static final String SYSTEM_STATS_TOTAL_USERS_FIELD = "total_users";
+    public static final String SYSTEM_STATS_ACTIVE_USERS_FIELD = 
"active_users";
+    public static final String SYSTEM_STATS_TOTAL_STORAGE_DOMAINS_FIELD = 
"total_storage_domains";
+    public static final String SYSTEM_STATS_ACTIVE_STORAGE_DOMAINS_FIELD = 
"active_storage_domains";
+
+}
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java
index 4791e79..8e6f9a7 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendApiResource.java
@@ -59,6 +59,7 @@
 import org.ovirt.engine.api.restapi.util.VersionHelper;
 import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.constants.gluster.QueryConstants;
 import org.ovirt.engine.core.common.mode.ApplicationMode;
 import org.ovirt.engine.core.common.queries.ConfigurationValues;
 import org.ovirt.engine.core.common.queries.GetSystemStatisticsQueryParameters;
@@ -404,20 +405,20 @@
             ApiSummary summary = new ApiSummary();
 
             summary.setVMs(new VMs());
-            summary.getVMs().setTotal(get(stats, "total_vms"));
-            summary.getVMs().setActive(get(stats, "active_vms"));
+            summary.getVMs().setTotal(get(stats, 
QueryConstants.SYSTEM_STATS_TOTAL_VMS_FIELD));
+            summary.getVMs().setActive(get(stats, 
QueryConstants.SYSTEM_STATS_ACTIVE_VMS_FIELD));
 
             summary.setHosts(new Hosts());
-            summary.getHosts().setTotal(get(stats, "total_vds"));
-            summary.getHosts().setActive(get(stats, "active_vds"));
+            summary.getHosts().setTotal(get(stats, 
QueryConstants.SYSTEM_STATS_TOTAL_HOSTS_FIELD));
+            summary.getHosts().setActive(get(stats, 
QueryConstants.SYSTEM_STATS_ACTIVE_HOSTS_FIELD));
 
             summary.setUsers(new Users());
-            summary.getUsers().setTotal(get(stats, "total_users"));
-            summary.getUsers().setActive(get(stats, "active_users"));
+            summary.getUsers().setTotal(get(stats, 
QueryConstants.SYSTEM_STATS_TOTAL_USERS_FIELD));
+            summary.getUsers().setActive(get(stats, 
QueryConstants.SYSTEM_STATS_ACTIVE_USERS_FIELD));
 
             summary.setStorageDomains(new StorageDomains());
-            summary.getStorageDomains().setTotal(get(stats, 
"total_storage_domains"));
-            summary.getStorageDomains().setActive(get(stats, 
"active_storage_domains"));
+            summary.getStorageDomains().setTotal(get(stats, 
QueryConstants.SYSTEM_STATS_TOTAL_STORAGE_DOMAINS_FIELD));
+            summary.getStorageDomains().setActive(get(stats, 
QueryConstants.SYSTEM_STATS_ACTIVE_STORAGE_DOMAINS_FIELD));
 
             api.setSummary(summary);
         }


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

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

Reply via email to