summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.core
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-07-12 23:16:54 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-07-18 00:02:42 +0530
commit4290f5519fb7480df6c5919583efc1f7feebf4b3 (patch)
tree5930ba1eb58235ec12b897c300f7fd7bef9694d1 /src/com.gluster.storage.management.core
parent194d5787da03f843a4eb81f304d6f30057bb5be2 (diff)
Story #38 - CPU Usage graph
Diffstat (limited to 'src/com.gluster.storage.management.core')
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java6
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java73
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java69
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java84
4 files changed, 232 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
index 455ecc11..d4b0e43a 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java
@@ -42,6 +42,7 @@ public class RESTConstants {
public static final String RESOURCE_SERVERS = "servers";
public static final String RESOURCE_TASKS = "tasks";
public static final String RESOURCE_KEYS = "keys";
+ public static final String RESOURCE_STATISTICS = "statistics";
public static final String TASK_START = "start";
public static final String TASK_PAUSE = "pause";
@@ -98,6 +99,11 @@ public class RESTConstants {
public static final String QUERY_PARAM_DOWNLOAD = "download";
public static final String QUERY_PARAM_SERVER_NAME = "serverName";
public static final String QUERY_PARAM_DETAILS = "details";
+ public static final String QUERY_PARAM_TYPE = "type";
+
+ public static final String STATISTICS_TYPE_CPU = "cpu";
+ public static final String STATISTICS_TYPE_NETWORK = "network";
+ public static final String STATISTICS_TYPE_MEMORY = "memory";
public static final String FORMAT_XML = "xml";
public static final String FORMAT_JSON = "json";
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java
new file mode 100644
index 00000000..042af256
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStats.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com>
+ * This file is part of Gluster Management Console.
+ *
+ * Gluster Management Console is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gluster Management Console is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
+package com.gluster.storage.management.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ */
+@XmlRootElement(name="xport")
+public class ServerStats {
+ private StatsMetadata metadata;
+ private List<ServerStatsRow> rows;
+
+ public ServerStats() {
+ }
+
+ public ServerStats(ServerStats newStats) {
+ copyFrom(newStats);
+ }
+
+ public void setRows(List<ServerStatsRow> rows) {
+ this.rows = rows;
+ }
+
+ @XmlElementWrapper(name="data")
+ @XmlElement(name="row", type=ServerStatsRow.class)
+ public List<ServerStatsRow> getRows() {
+ return rows;
+ }
+
+ public void setMetadata(StatsMetadata metadata) {
+ this.metadata = metadata;
+ }
+
+ @XmlElement(name="meta")
+ public StatsMetadata getMetadata() {
+ return metadata;
+ }
+
+ public void copyFrom(ServerStats newStats) {
+ setMetadata(newStats.getMetadata());
+
+ List<ServerStatsRow> newRows = newStats.getRows();
+ int rowCount = newRows.size();
+
+ rows = new ArrayList<ServerStatsRow>(rowCount);
+ for(ServerStatsRow newRow : newRows) {
+ rows.add(new ServerStatsRow(newRow));
+ }
+ }
+} \ No newline at end of file
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java
new file mode 100644
index 00000000..0088cef6
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/ServerStatsRow.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com>
+ * This file is part of Gluster Management Console.
+ *
+ * Gluster Management Console is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gluster Management Console is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
+package com.gluster.storage.management.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ */
+@XmlRootElement(name="row")
+public class ServerStatsRow {
+ private Long timestamp;
+ private List<Double> usageData;
+
+ public ServerStatsRow() {
+ }
+
+ public ServerStatsRow(ServerStatsRow newRow) {
+ copyFrom(newRow);
+ }
+
+ private void copyFrom(ServerStatsRow newRow) {
+ setTimestamp(newRow.getTimestamp());
+
+ List<Double> myData = new ArrayList<Double>(newRow.getUsageData().size());
+ for(Double dataElement : newRow.getUsageData()) {
+ myData.add(dataElement);
+ }
+ setUsageData(myData);
+ }
+
+ @XmlElement(name="t")
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public void setUsageData(List<Double> usageData) {
+ this.usageData = usageData;
+ }
+
+ @XmlElement(name="v")
+ public List<Double> getUsageData() {
+ return usageData;
+ }
+}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java
new file mode 100644
index 00000000..22b42671
--- /dev/null
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/StatsMetadata.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com>
+ * This file is part of Gluster Management Console.
+ *
+ * Gluster Management Console is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gluster Management Console is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
+package com.gluster.storage.management.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ *
+ */
+@XmlRootElement(name="meta")
+public class StatsMetadata {
+ private Long startTimestamp;
+ private Long endTimestamp;
+ private Integer step;
+ private Integer rowCount;
+ private List<String> legend = new ArrayList<String>();
+
+ @XmlElement(name="start")
+ public Long getStartTimestamp() {
+ return startTimestamp;
+ }
+
+ public void setStartTimestamp(Long startTimestamp) {
+ this.startTimestamp = startTimestamp;
+ }
+
+ @XmlElement(name="end")
+ public Long getEndTimestamp() {
+ return endTimestamp;
+ }
+
+ public void setEndTimestamp(Long endTimestamp) {
+ this.endTimestamp = endTimestamp;
+ }
+
+ @XmlElement(name="step")
+ public Integer getStep() {
+ return step;
+ }
+
+ public void setStep(Integer step) {
+ this.step = step;
+ }
+
+ @XmlElement(name="rows")
+ public Integer getRowCount() {
+ return rowCount;
+ }
+
+ public void setRowCount(Integer rowCount) {
+ this.rowCount = rowCount;
+ }
+
+ @XmlElementWrapper(name="legend")
+ @XmlElement(name="entry", type=String.class)
+ public List<String> getLegend() {
+ return legend;
+ }
+
+ public void setLegend(List<String> legend) {
+ this.legend = legend;
+ }
+}