Better error handling for some corner cases

Make the exceptions more descriptive so admins can pinpoint the issue
easier.


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

Branch: refs/heads/marvin-refactor
Commit: 56559e88583ee44ac8be1def89077b3950c67ced
Parents: 72292b3
Author: Hugo Trippaers <[email protected]>
Authored: Fri Mar 29 11:55:00 2013 +0100
Committer: Prasanna Santhanam <[email protected]>
Committed: Sat Mar 30 22:21:53 2013 +0530

----------------------------------------------------------------------
 .../cloud/agent/manager/ClusteredAgentAttache.java |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/56559e88/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java 
b/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java
index a648740..7ddab11 100755
--- a/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java
+++ b/server/src/com/cloud/agent/manager/ClusteredAgentAttache.java
@@ -95,8 +95,13 @@ public class ClusteredAgentAttache extends 
ConnectedAgentAttache implements Rout
                 SynchronousListener synchronous = 
(SynchronousListener)listener;
                 String peerName = synchronous.getPeer();
                 if (peerName != null) {
-                    s_logger.debug(log(seq, "Forwarding to peer to cancel due 
to timeout"));
-                    s_clusteredAgentMgr.cancel(peerName, _id, seq, "Timed 
Out");
+                    if (s_clusteredAgentMgr != null) {
+                        s_logger.debug(log(seq, "Forwarding to peer to cancel 
due to timeout"));
+                        s_clusteredAgentMgr.cancel(peerName, _id, seq, "Timed 
Out");
+                    } else {
+                        s_logger.error("Unable to forward cancel, 
ClusteredAgentAttache is not properly initialized");
+                    }
+
                 }
             }
         }
@@ -159,6 +164,10 @@ public class ClusteredAgentAttache extends 
ConnectedAgentAttache implements Rout
             }
         } 
 
+        if (s_clusteredAgentMgr == null) {
+            throw new AgentUnavailableException("ClusteredAgentAttache not 
properly initialized", _id);
+        }
+
         int i = 0;
         SocketChannel ch = null;
         boolean error = true;

Reply via email to