diff options
| author | Selvam <selvam@gluster.com> | 2011-03-30 18:02:08 +0530 |
|---|---|---|
| committer | Selvam <selvam@gluster.com> | 2011-03-30 18:02:08 +0530 |
| commit | f30c67deb0b525911d1f3d891574e808ef3068b1 (patch) | |
| tree | e770801e9f225ecf7aeef40e0e3b8fef53c00cf1 /src/com.gluster.storage.management.core | |
| parent | 5c39a47fdd3987bb5eee35f7f7397ce127c8919e (diff) | |
Alerts section in volumes summary page
Diffstat (limited to 'src/com.gluster.storage.management.core')
7 files changed, 129 insertions, 7 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 fb40be8a..47697eb9 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 @@ -34,4 +34,5 @@ public class RESTConstants { // Running tasks resource public static final String RESOURCE_PATH_RUNNING_TASKS = "/cluster/runningtasks"; + public static final String RESOURCE_PATH_ALERTS = "/cluster/alerts"; } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java new file mode 100644 index 00000000..b2882102 --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java @@ -0,0 +1,51 @@ +package com.gluster.storage.management.core.model; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "alert") +public class Alert { + public enum ALERT_TYPES { CPU_ALERT, MEMORY_ALERT, DISK_ALERT }; + + public String[] ALERT_TYPE_STR = {"High CPU Usage", "High Memory Usage", "Low Disk Space"}; + + protected String id; + protected ALERT_TYPES type; + protected String reference; + protected String message; + + public String getAlertType( ALERT_TYPES alertType) { + return ALERT_TYPE_STR[alertType.ordinal()]; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ALERT_TYPES getType() { + return type; + } + + public void setType(ALERT_TYPES type) { + this.type = type; + } + + public String getReference() { + return reference; + } + + public void setReference(String reference) { + this.reference = reference; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertListResponse.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertListResponse.java new file mode 100644 index 00000000..bb3c754e --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertListResponse.java @@ -0,0 +1,36 @@ +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 = "response") +public class AlertListResponse extends AbstractResponse { + private List<Alert> alerts = new ArrayList<Alert>(); + + public AlertListResponse() { + + } + + public AlertListResponse(List<Alert> alerts) { + setAlerts(alerts); + } + + public void setAlerts(List<Alert> alerts) { + this.alerts = alerts; + } + + @XmlElementWrapper(name = "alerts") + @XmlElement(name = "alert", type=Alert.class) + public List<Alert> getAlerts() { + return this.alerts; + } + + @Override + public Object getData() { + return getAlerts(); + } +} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertStatus.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertStatus.java new file mode 100644 index 00000000..8c563f49 --- /dev/null +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/AlertStatus.java @@ -0,0 +1,13 @@ +package com.gluster.storage.management.core.model; + +public class AlertStatus { + protected String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java index 65d5ebea..1af57266 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Cluster.java @@ -29,6 +29,7 @@ public class Cluster extends Entity { List<Server> discoveredServers = new ArrayList<Server>(); List<Volume> volumes = new ArrayList<Volume>(); List<RunningTask> runningTasks = new ArrayList<RunningTask>(); + List<Alert> alerts = new ArrayList<Alert>(); public Cluster() { } @@ -97,4 +98,16 @@ public class Cluster extends Entity { public void setRunningTasks(List<RunningTask> runningTasks) { this.runningTasks = runningTasks; } + + public List<Alert> getAlerts() { + return alerts; + } + + public void setAlerts(List<Alert> alerts) { + this.alerts = alerts; + } + + public void addAlert(Alert alert) { + this.alerts.add(alert); + } }
\ No newline at end of file diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java index 1a9d63f6..32bd662e 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java @@ -22,10 +22,12 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class RunningTask { - + public enum TASK_TYPES { FORMAT_DISK, MIGRATE_DISK, VOLUME_REBALANCE }; + public String[] TASK_TYPE_STR = {"Format Disk", "Migrate Disk", "Volume Rebalance"}; + protected String id; - protected String type; // FormatDisk, MigrateDisk, VolumeRebalance - protected Object reference; + protected TASK_TYPES type; // FormatDisk, MigrateDisk, VolumeRebalance + protected String reference; protected String description; protected RunningTaskStatus status; // TODO redefine @@ -33,6 +35,10 @@ public class RunningTask { } + public String getTaskType(TASK_TYPES type) { + return TASK_TYPE_STR[type.ordinal()]; + } + public String getId() { return id; } @@ -41,19 +47,19 @@ public class RunningTask { this.id = id; } - public String getType() { + public TASK_TYPES getType() { return type; } - public void setType(String type) { + public void setType(TASK_TYPES type) { this.type = type; } - public Object getReference() { + public String getReference() { return reference; } - public void setReference(Object reference) { + public void setReference(String reference) { this.reference = reference; } diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java index 06d6efe1..c5fdb246 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Status.java @@ -27,6 +27,8 @@ public class Status { public static final int STATUS_CODE_SUCCESS = 0; public static final int STATUS_CODE_FAILURE = 1; public static final int STATUS_CODE_RUNNING = 2; + public static final int STATUS_CODE_PAUSE = 3; + public static final int STATUS_CODE_WARNING = 4; public static final Status STATUS_SUCCESS = new Status(STATUS_CODE_SUCCESS, "Success"); public static final Status STATUS_FAILURE = new Status(STATUS_CODE_FAILURE, "Failure"); |
