summaryrefslogtreecommitdiff
path: root/cpp/src/qmf/ConsoleSession.cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-10-27 18:46:21 +0000
committerTed Ross <tross@apache.org>2010-10-27 18:46:21 +0000
commitf82036751808dcd479030203368e4980e8c0b38a (patch)
tree79d43ee35bb92d258ba64d383eeb5dabdeb2f85f /cpp/src/qmf/ConsoleSession.cpp
parent1d2d19beb5c351d9aff84e9fecfcc5d9093da14c (diff)
downloadqpid-python-f82036751808dcd479030203368e4980e8c0b38a.tar.gz
1) Fix a bug where AGENT_RESTART is repeatedly reported when detected once.
2) ConsoleSession::getAgents now lists only agents in the agent-filter. If the connected broker agent does not match the filter, it is removed from the list though it is still accessible using ConsoleSession::getConnectedBrokerAgent. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1028066 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qmf/ConsoleSession.cpp')
-rw-r--r--cpp/src/qmf/ConsoleSession.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/cpp/src/qmf/ConsoleSession.cpp b/cpp/src/qmf/ConsoleSession.cpp
index 868df302ce..6eb9b94bf8 100644
--- a/cpp/src/qmf/ConsoleSession.cpp
+++ b/cpp/src/qmf/ConsoleSession.cpp
@@ -59,7 +59,7 @@ Agent ConsoleSession::getConnectedBrokerAgent() const { return impl->getConnecte
ConsoleSessionImpl::ConsoleSessionImpl(Connection& c, const string& options) :
connection(c), domain("default"), maxAgentAgeMinutes(5), opened(false),
thread(0), threadCanceled(false),
- lastVisit(0), lastAgePass(0), schemaCache(new SchemaCache())
+ lastVisit(0), lastAgePass(0), connectedBrokerInAgentList(false), schemaCache(new SchemaCache())
{
if (!options.empty()) {
qpid::messaging::AddressParser parser(options);
@@ -97,9 +97,10 @@ void ConsoleSessionImpl::setAgentFilter(const string& predicate)
qpid::sys::Mutex::ScopedLock l(lock);
map<string, Agent> toDelete;
for (map<string, Agent>::iterator iter = agents.begin(); iter != agents.end(); iter++)
- if ((iter->second.getName() != connectedBrokerAgent.getName()) &&
- (!agentQuery.matchesPredicate(iter->second.getAttributes()))) {
+ if (!agentQuery.matchesPredicate(iter->second.getAttributes())) {
toDelete[iter->first] = iter->second;
+ if (iter->second.getName() == connectedBrokerAgent.getName())
+ connectedBrokerInAgentList = false;
}
for (map<string, Agent>::iterator iter = toDelete.begin(); iter != toDelete.end(); iter++) {
@@ -108,6 +109,11 @@ void ConsoleSessionImpl::setAgentFilter(const string& predicate)
eventImpl->setAgent(iter->second);
enqueueEventLH(eventImpl.release());
}
+
+ if (!connectedBrokerInAgentList && agentQuery.matchesPredicate(connectedBrokerAgent.getAttributes())) {
+ agents[connectedBrokerAgent.getName()] = connectedBrokerAgent;
+ connectedBrokerInAgentList = true;
+ }
}
//
@@ -376,19 +382,30 @@ void ConsoleSessionImpl::handleAgentUpdate(const string& agentName, const Varian
return;
Variant::Map attrs(iter->second.asMap());
+ iter = attrs.find("epoch");
+ if (iter != attrs.end())
+ epoch = iter->second.asUint32();
+
+ if (cid == "broker-locate") {
+ qpid::sys::Mutex::ScopedLock l(lock);
+ agent = Agent(new AgentImpl(agentName, epoch, *this));
+ connectedBrokerAgent = agent;
+ if (!agentQuery || agentQuery.matchesPredicate(attrs)) {
+ connectedBrokerInAgentList = true;
+ agents[agentName] = agent;
+ }
+ return;
+ }
+
//
// Check this agent against the agent filter. Exit if it doesn't match.
// (only if this isn't the connected broker agent)
//
- if ((cid != "broker-locate") && agentQuery && (!agentQuery.matchesPredicate(attrs)))
+ if (agentQuery && (!agentQuery.matchesPredicate(attrs)))
return;
QPID_LOG(trace, "RCVD AgentHeartbeat from an agent matching our filter: " << agentName);
- iter = attrs.find("epoch");
- if (iter != attrs.end())
- epoch = iter->second.asUint32();
-
{
qpid::sys::Mutex::ScopedLock l(lock);
map<string, Agent>::iterator aIter = agents.find(agentName);
@@ -421,6 +438,7 @@ void ConsoleSessionImpl::handleAgentUpdate(const string& agentName, const Varian
// The agent has restarted since the last time we heard from it.
// Enqueue a notification.
//
+ impl.setEpoch(epoch);
auto_ptr<ConsoleEventImpl> eventImpl(new ConsoleEventImpl(CONSOLE_AGENT_RESTART));
eventImpl->setAgent(agent);
enqueueEventLH(ConsoleEvent(eventImpl.release()));
@@ -440,9 +458,6 @@ void ConsoleSessionImpl::handleAgentUpdate(const string& agentName, const Varian
}
}
}
-
- if (cid == "broker-locate")
- connectedBrokerAgent = agent;
}
}