cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: updated refs/heads/master to 4e0e741
Date Mon, 14 Oct 2013 17:51:18 GMT
Updated Branches:
  refs/heads/master 29d922814 -> 4e0e7410e


Store agent hostname in attache, print it in logs wherever possible. This
was discussed on the mailing list as a useful debugging tool, currently
the log prints the DB id of the agent, which makes admins have to look
it up to know where the Command was run.


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

Branch: refs/heads/master
Commit: 4e0e7410e99c7f57cde934af1fef9b27d0ae1e66
Parents: 29d9228
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Mon Oct 14 11:46:01 2013 -0600
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Mon Oct 14 11:46:01 2013 -0600

----------------------------------------------------------------------
 core/src/com/cloud/agent/transport/Request.java     | 16 +++++++++++++++-
 .../src/com/cloud/agent/manager/AgentAttache.java   | 15 ++++++++++-----
 .../com/cloud/agent/manager/AgentManagerImpl.java   |  8 ++++----
 .../cloud/agent/manager/ClusteredAgentAttache.java  |  8 ++++----
 .../agent/manager/ClusteredAgentManagerImpl.java    |  7 ++++---
 .../agent/manager/ClusteredDirectAgentAttache.java  |  4 ++--
 .../cloud/agent/manager/ConnectedAgentAttache.java  |  6 +++---
 .../com/cloud/agent/manager/DirectAgentAttache.java | 14 +++++++-------
 .../src/com/cloud/agent/manager/DummyAttache.java   |  4 ++--
 9 files changed, 51 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/core/src/com/cloud/agent/transport/Request.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/transport/Request.java b/core/src/com/cloud/agent/transport/Request.java
index 31076c0..cbeb112 100755
--- a/core/src/com/cloud/agent/transport/Request.java
+++ b/core/src/com/cloud/agent/transport/Request.java
@@ -108,6 +108,7 @@ public class Request {
     protected long      _agentId;
     protected Command[] _cmds;
     protected String    _content;
+    protected String    _agentName;
 
     protected Request() {
     }
@@ -142,6 +143,11 @@ public class Request {
         setFromServer(fromServer);
     }
 
+    public Request(long agentId, String agentName, long mgmtId, Command[] cmds, boolean stopOnError,
boolean fromServer) {
+        this(agentId, mgmtId, cmds, stopOnError, fromServer);
+        setAgentName(agentName);
+    }
+
     public void setSequence(long seq) {
         _seq = seq;
     }
@@ -174,6 +180,10 @@ public class Request {
         _flags |= (stopOnError ? FLAG_STOP_ON_ERROR : 0);
     }
 
+    private final void setAgentName(String agentName) {
+        _agentName = agentName;
+    }
+
     private final void setInSequence(boolean inSequence) {
         _flags |= (inSequence ? FLAG_IN_SEQUENCE : 0);
     }
@@ -422,7 +432,11 @@ public class Request {
 
         buf.append(msg);
         buf.append(" { ").append(getType());
-        buf.append(", MgmtId: ").append(_mgmtId).append(", via: ").append(_via);
+        if (_agentName != null) {
+            buf.append(", MgmtId: ").append(_mgmtId).append(", via: ").append(_via).append("("
+ _agentName + ")");
+        } else {
+            buf.append(", MgmtId: ").append(_mgmtId).append(", via: ").append(_via);
+        }
         buf.append(", Ver: ").append(_ver.toString());
         buf.append(", Flags: ").append(Integer.toBinaryString(getFlags())).append(", ");
         buf.append(content);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
index 5b1007b..ff35255 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java
@@ -101,6 +101,7 @@ public abstract class AgentAttache {
     };
 
     protected final long _id;
+    protected String _name = null;
     protected final ConcurrentHashMap<Long, Listener> _waitForList;
     protected final LinkedList<Request> _requests;
     protected Long _currentSequence;
@@ -121,9 +122,9 @@ public abstract class AgentAttache {
         Arrays.sort(s_commandsNotAllowedInConnectingMode);
     }
 
-
-    protected AgentAttache(AgentManagerImpl agentMgr, final long id, boolean maintenance)
{
+    protected AgentAttache(AgentManagerImpl agentMgr, final long id, final String name, boolean
maintenance) {
         _id = id;
+        _name = name;
         _waitForList = new ConcurrentHashMap<Long, Listener>();
         _currentSequence = null;
         _maintenance = maintenance;
@@ -164,7 +165,7 @@ public abstract class AgentAttache {
         if (_maintenance) {
             for (final Command cmd : cmds) {
                 if (Arrays.binarySearch(s_commandsAllowedInMaintenanceMode, cmd.getClass().toString())
< 0) {
-                    throw new AgentUnavailableException("Unable to send " + cmd.getClass().toString()
+ " because agent is in maintenance mode", _id);
+                    throw new AgentUnavailableException("Unable to send " + cmd.getClass().toString()
+ " because agent " + _name + " is in maintenance mode", _id);
                 }
             }
         }
@@ -172,7 +173,7 @@ public abstract class AgentAttache {
         if (_status == Status.Connecting) {
             for (final Command cmd : cmds) {
                 if (Arrays.binarySearch(s_commandsNotAllowedInConnectingMode, cmd.getClass().toString())
>= 0) {
-                    throw new AgentUnavailableException("Unable to send " + cmd.getClass().toString()
+ " because agent is in connecting mode", _id);
+                    throw new AgentUnavailableException("Unable to send " + cmd.getClass().toString()
+ " because agent " + _name + " is in connecting mode", _id);
                 }
             }
         }
@@ -242,6 +243,10 @@ public abstract class AgentAttache {
         return _id;
     }
 
+    public String getName() {
+            return _name;
+    }
+
     public int getQueueSize() {
         return _requests.size();
     }
@@ -350,7 +355,7 @@ public abstract class AgentAttache {
         synchronized(this) {
             try {
                 if (isClosed()) {
-                    throw new AgentUnavailableException("The link to the agent has been closed",
_id);
+                    throw new AgentUnavailableException("The link to the agent " + _name
+ " has been closed", _id);
                 }
 
                 if (req.executeInSequence() && _currentSequence != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
index 4202015..6804dc1 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -384,7 +384,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager,
Handl
             throw new AgentUnavailableException("agent not logged into this management server",
hostId);
         }
 
-        Request req = new Request(hostId, _nodeId, cmds, commands.stopOnError(), true);
+        Request req = new Request(hostId, agent.getName(), _nodeId, cmds, commands.stopOnError(),
true);
         req.setSequence(agent.getNextSequence());
         Answer[] answers = agent.send(req, timeout);
         notifyAnswersToMonitors(hostId, req.getSequence(), answers);
@@ -437,7 +437,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager,
Handl
         if (cmds.length == 0) {
             throw new AgentUnavailableException("Empty command set for agent " + agent.getId(),
agent.getId());
         }
-        Request req = new Request(hostId, _nodeId, cmds, commands.stopOnError(), true);
+        Request req = new Request(hostId, agent.getName(), _nodeId, cmds, commands.stopOnError(),
true);
         req.setSequence(agent.getNextSequence());
 
         agent.send(req, listener);
@@ -679,7 +679,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager,
Handl
 //        }
 
         s_logger.debug("create DirectAgentAttache for " + host.getId());
-        DirectAgentAttache attache = new DirectAgentAttache(this, host.getId(), resource,
host.isInMaintenanceStates(), this);
+        DirectAgentAttache attache = new DirectAgentAttache(this, host.getId(), host.getName(),
resource, host.isInMaintenanceStates(), this);
 
         AgentAttache old = null;
         synchronized (_agents) {
@@ -969,7 +969,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager,
Handl
 
     protected AgentAttache createAttacheForConnect(HostVO host, Link link) throws ConnectionException
{
         s_logger.debug("create ConnectedAgentAttache for " + host.getId());
-        AgentAttache attache = new ConnectedAgentAttache(this, host.getId(), link, host.isInMaintenanceStates());
+        AgentAttache attache = new ConnectedAgentAttache(this, host.getId(), host.getName(),
link, host.isInMaintenanceStates());
         link.attach(attache);
 
         AgentAttache old = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java
index 058a904..5bcde6b 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java
@@ -50,14 +50,14 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements
Rout
         s_clusteredAgentMgr = agentMgr;
     }
 
-    public ClusteredAgentAttache(AgentManagerImpl agentMgr, long id) {
-        super(agentMgr, id, null, false);
+    public ClusteredAgentAttache(AgentManagerImpl agentMgr, long id, String name) {
+        super(agentMgr, id, name, null, false);
         _forward = true;
         _transferRequests = new LinkedList<Request>();
     }
 
-    public ClusteredAgentAttache(AgentManagerImpl agentMgr, long id, Link link, boolean maintenance)
{
-        super(agentMgr, id, link, maintenance);
+    public ClusteredAgentAttache(AgentManagerImpl agentMgr, long id, String name, Link link,
boolean maintenance) {
+        super(agentMgr, id, name, link, maintenance);
         _forward = link == null;
         _transferRequests = new LinkedList<Request>();
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index 2b9e541..07fa73c 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -246,7 +246,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements
Clust
 
     protected AgentAttache createAttache(long id) {
         s_logger.debug("create forwarding ClusteredAgentAttache for " + id);
-        final AgentAttache attache = new ClusteredAgentAttache(this, id);
+        HostVO host = _hostDao.findById(id);
+        final AgentAttache attache = new ClusteredAgentAttache(this, id, host.getName());
         AgentAttache old = null;
         synchronized (_agents) {
             old = _agents.get(id);
@@ -261,7 +262,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements
Clust
     @Override
     protected AgentAttache createAttacheForConnect(HostVO host, Link link) {
         s_logger.debug("create ClusteredAgentAttache for " + host.getId());
-        final AgentAttache attache = new ClusteredAgentAttache(this, host.getId(), link,
host.isInMaintenanceStates());
+        final AgentAttache attache = new ClusteredAgentAttache(this, host.getId(), host.getName(),
link, host.isInMaintenanceStates());
         link.attach(attache);
         AgentAttache old = null;
         synchronized (_agents) {
@@ -280,7 +281,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements
Clust
 //            return new DummyAttache(this, host.getId(), false);
 //        }
         s_logger.debug("create ClusteredDirectAgentAttache for " + host.getId());
-        final DirectAgentAttache attache = new ClusteredDirectAgentAttache(this, host.getId(),
_nodeId, resource, host.isInMaintenanceStates(), this);
+        final DirectAgentAttache attache = new ClusteredDirectAgentAttache(this, host.getId(),
host.getName(), _nodeId, resource, host.isInMaintenanceStates(), this);
         AgentAttache old = null;
         synchronized (_agents) {
             old = _agents.get(host.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java
b/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java
index 9012433..692f6ad 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredDirectAgentAttache.java
@@ -28,8 +28,8 @@ public class ClusteredDirectAgentAttache extends DirectAgentAttache implements
R
     private final ClusteredAgentManagerImpl _mgr;
     private final long _nodeId;
 
-    public ClusteredDirectAgentAttache(AgentManagerImpl agentMgr, long id, long mgmtId, ServerResource
resource, boolean maintenance, ClusteredAgentManagerImpl mgr) {
-        super(agentMgr, id, resource, maintenance, mgr);
+    public ClusteredDirectAgentAttache(AgentManagerImpl agentMgr, long id, String name, long
mgmtId, ServerResource resource, boolean maintenance, ClusteredAgentManagerImpl mgr) {
+        super(agentMgr, id, name, resource, maintenance, mgr);
         _mgr = mgr;
         _nodeId = mgmtId;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java
index e5d2867..8ee47d5 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java
@@ -33,8 +33,8 @@ public class ConnectedAgentAttache extends AgentAttache {
 
     protected Link _link;
 
-    public ConnectedAgentAttache(AgentManagerImpl agentMgr, final long id, final Link link,
boolean maintenance) {
-        super(agentMgr, id, maintenance);
+    public ConnectedAgentAttache(AgentManagerImpl agentMgr, final long id, final String name,
final Link link, boolean maintenance) {
+        super(agentMgr, id, name, maintenance);
         _link = link;
     }
 
@@ -83,7 +83,7 @@ public class ConnectedAgentAttache extends AgentAttache {
             assert _link == null : "Duh...Says you....Forgot to call disconnect()!";
             synchronized (this) {
                 if (_link != null) {
-                    s_logger.warn("Lost attache " + _id);
+                    s_logger.warn("Lost attache " + _id + "(" + _name + ")");
                     disconnect(Status.Alert);
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
index 2808c6a..7d3f765 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java
@@ -44,8 +44,8 @@ public class DirectAgentAttache extends AgentAttache {
     AgentManagerImpl _mgr;
     long _seq = 0;
 
-    public DirectAgentAttache(AgentManagerImpl agentMgr, long id, ServerResource resource,
boolean maintenance, AgentManagerImpl mgr) {
-        super(agentMgr, id, maintenance);
+    public DirectAgentAttache(AgentManagerImpl agentMgr, long id, String name, ServerResource
resource, boolean maintenance, AgentManagerImpl mgr) {
+        super(agentMgr, id, name, maintenance);
         _resource = resource;
         _mgr = mgr;
     }
@@ -53,7 +53,7 @@ public class DirectAgentAttache extends AgentAttache {
     @Override
     public void disconnect(Status state) {
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Processing disconnect " + _id);
+            s_logger.debug("Processing disconnect " + _id + "(" + _name + ")");
         }
 
         for (ScheduledFuture<?> future : _futures) {
@@ -119,7 +119,7 @@ public class DirectAgentAttache extends AgentAttache {
             assert _resource == null : "Come on now....If you're going to dabble in agent
code, you better know how to close out our resources. Ever considered why there's a method
called disconnect()?";
             synchronized (this) {
                 if (_resource != null) {
-                    s_logger.warn("Lost attache for " + _id);
+                    s_logger.warn("Lost attache for " + _id + "(" + _name + ")");
                     disconnect(Status.Alert);
                 }
             }
@@ -137,12 +137,12 @@ public class DirectAgentAttache extends AgentAttache {
                 if (resource != null) {
                     PingCommand cmd = resource.getCurrentStatus(_id);
                     if (cmd == null) {
-                        s_logger.warn("Unable to get current status on " + _id);
+                        s_logger.warn("Unable to get current status on " + _id + "(" + _name
+ ")");
                         _mgr.disconnectWithInvestigation(DirectAgentAttache.this, Event.AgentDisconnected);
                         return;
                     }
                     if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("Ping from " + _id);
+                        s_logger.debug("Ping from " + _id + "(" + _name + ")");
                     }
                     long seq = _seq++;
 
@@ -152,7 +152,7 @@ public class DirectAgentAttache extends AgentAttache {
 
                     _mgr.handleCommands(DirectAgentAttache.this, seq, new Command[]{cmd});
                 } else {
-                    s_logger.debug("Unable to send ping because agent is disconnected " +
_id);
+                    s_logger.debug("Unable to send ping because agent is disconnected " +
_id + "(" + _name + ")");
                 }
             } catch (Exception e) {
                 s_logger.warn("Unable to complete the ping task", e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e0e7410/engine/orchestration/src/com/cloud/agent/manager/DummyAttache.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/DummyAttache.java b/engine/orchestration/src/com/cloud/agent/manager/DummyAttache.java
index 182c1b8..2c76848 100755
--- a/engine/orchestration/src/com/cloud/agent/manager/DummyAttache.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/DummyAttache.java
@@ -23,8 +23,8 @@ import com.cloud.host.Status;
 
 public class DummyAttache extends AgentAttache {
 
-	public DummyAttache(AgentManagerImpl agentMgr, long id, boolean maintenance) {
-		super(agentMgr, id, maintenance);
+	public DummyAttache(AgentManagerImpl agentMgr, long id, String name, boolean maintenance)
{
+		super(agentMgr, id, name, maintenance);
 	}
 
 


Mime
View raw message