cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [3/5] git commit: publish alerts from a single place
Date Mon, 17 Sep 2012 03:11:15 GMT
publish alerts from a single place


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/5ae868d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/5ae868d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/5ae868d0

Branch: refs/heads/events-framework
Commit: 5ae868d0f926e5f2b1e97a68eab098cb5be70135
Parents: 9c40bb4
Author: Murali Reddy <Murali.Reddy@citrix.com>
Authored: Mon Sep 17 01:57:07 2012 +0530
Committer: Murali Reddy <Murali.Reddy@citrix.com>
Committed: Mon Sep 17 01:57:07 2012 +0530

----------------------------------------------------------------------
 server/src/com/cloud/alert/AlertManagerImpl.java |   64 +++++++++++++++++
 server/src/com/cloud/event/AlertGenerator.java   |    7 ++
 2 files changed, 71 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ae868d0/server/src/com/cloud/alert/AlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java
index 9c0cbb3..2a01c38 100755
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -59,6 +59,7 @@ import com.cloud.dc.dao.ClusterDao;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.DataCenterIpAddressDao;
 import com.cloud.dc.dao.HostPodDao;
+import com.cloud.event.AlertGenerator;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
@@ -261,6 +262,10 @@ public class AlertManagerImpl implements AlertManager {
 
     @Override
     public void sendAlert(short alertType, long dataCenterId, Long podId, String subject,
String body) {
+
+        // publish alert
+        AlertGenerator.publishAlert(getAlertType(alertType), dataCenterId, podId, subject,
body);
+
         // TODO:  queue up these messages and send them as one set of issues once a certain
number of issues is reached?  If that's the case,
         //         shouldn't we have a type/severity as part of the API so that severe errors
get sent right away?
         try {
@@ -272,6 +277,65 @@ public class AlertManagerImpl implements AlertManager {
         }
     }
 
+    private String getAlertType(short alertType) {
+        if (alertType == ALERT_TYPE_MEMORY) {
+            return "ALERT.MEMORY";
+        } else if (alertType == ALERT_TYPE_CPU) {
+            return "ALERT.MEMORY";
+        } else if (alertType == ALERT_TYPE_STORAGE) {
+            return "ALERT.STORAGE";
+        } else if (alertType == ALERT_TYPE_STORAGE_ALLOCATED) {
+            return "ALERT.STORAGE.ALLOCATED";
+        } else if (alertType == ALERT_TYPE_VIRTUAL_NETWORK_PUBLIC_IP) {
+            return "ALERT.NETWORK.PUBLICIP";
+        } else if (alertType == ALERT_TYPE_PRIVATE_IP) {
+            return "ALERT.NETWORK.PRIVATEIP";
+        } else if (alertType == ALERT_TYPE_SECONDARY_STORAGE) {
+            return "ALERT.STORAGE.SECONDARY";
+        } else if (alertType == ALERT_TYPE_HOST) {
+            return "ALERT.COMPUTE.HOST";
+        } else if (alertType == ALERT_TYPE_USERVM) {
+            return "ALERT.USERVM";
+        } else if (alertType == ALERT_TYPE_DOMAIN_ROUTER) {
+            return "ALERT.SERVICE.DOMAINROUTER";
+        } else if (alertType == ALERT_TYPE_CONSOLE_PROXY) {
+            return "ALERT.SERVICE.CONSOLEPROXY";
+        } else if (alertType == ALERT_TYPE_ROUTING) {
+            return "ALERT.NETWORK.ROUTING";
+        } else if (alertType == ALERT_TYPE_STORAGE_MISC) {
+            return "ALERT.STORAGE.MISC";
+        } else if (alertType == ALERT_TYPE_USAGE_SERVER) {
+            return "ALERT.USAGE";
+        } else if (alertType == ALERT_TYPE_MANAGMENT_NODE) {
+            return "ALERT.MANAGEMENT";
+        } else if (alertType == ALERT_TYPE_DOMAIN_ROUTER_MIGRATE) {
+            return "ALERT.NETWORK.DOMAINROUTERMIGRATE";
+        } else if (alertType == ALERT_TYPE_CONSOLE_PROXY_MIGRATE) {
+            return "ALERT.SERVICE.CONSOLEPROXYMIGRATE";
+        } else if (alertType == ALERT_TYPE_USERVM_MIGRATE) {
+            return "ALERT.USERVM.MIGRATE";
+        } else if (alertType == ALERT_TYPE_VLAN) {
+            return "ALERT.NETWORK.VLAN";
+        } else if (alertType == ALERT_TYPE_SSVM) {
+            return "ALERT.SERVICE.SSVM";
+        } else if (alertType == ALERT_TYPE_USAGE_SERVER_RESULT) {
+            return "ALERT.USAGE.RESULT";
+        } else if (alertType == ALERT_TYPE_STORAGE_DELETE) {
+            return "ALERT.STORAGE.DELETE";
+        } else if (alertType == ALERT_TYPE_UPDATE_RESOURCE_COUNT) {
+            return "ALERT.RESOURCE.COUNT";
+        } else if (alertType == ALERT_TYPE_USAGE_SANITY_RESULT) {
+            return "ALERT.USAGE.SANITY";
+        } else if (alertType == ALERT_TYPE_DIRECT_ATTACHED_PUBLIC_IP) {
+            return "ALERT.NETWORK.DIRECTPUBLICIP";
+        } else if (alertType == ALERT_TYPE_LOCAL_STORAGE) {
+            return "ALERT.STORAGE.LOCAL";
+        } else if (alertType == ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED) {
+            return "ALERT.RESOURCE.EXCEED";
+        }
+        return "UNKNOWN";
+    }
+
     @Override @DB
     public void recalculateCapacity() {
         // FIXME: the right way to do this is to register a listener (see RouterStatsListener,
VMSyncListener)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5ae868d0/server/src/com/cloud/event/AlertGenerator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/AlertGenerator.java b/server/src/com/cloud/event/AlertGenerator.java
new file mode 100644
index 0000000..ad5a1cf
--- /dev/null
+++ b/server/src/com/cloud/event/AlertGenerator.java
@@ -0,0 +1,7 @@
+package com.cloud.event;
+
+public class AlertGenerator {
+
+    public static void publishAlert(String alertType, long dataCenterId, Long podId, String
subject, String body) {
+    }
+}


Mime
View raw message