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/9a5bf78c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9a5bf78c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9a5bf78c

Branch: refs/heads/bvt
Commit: 9a5bf78c3ee156daf5527a4faf70375fc3a5fa47
Parents: 95fce11
Author: Hugo Trippaers <htrippa...@schubergphilis.com>
Authored: Fri Mar 29 11:55:00 2013 +0100
Committer: Hugo Trippaers <htrippa...@schubergphilis.com>
Committed: Fri Mar 29 12:06:03 2013 +0100

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9a5bf78c/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..058a904 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