summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcpp/bindings/qmf/tests/python_console.py11
-rwxr-xr-xcpp/bindings/qmf/tests/ruby_console_test.rb15
-rw-r--r--cpp/src/qmf.mk2
-rw-r--r--cpp/src/qmf/engine/BrokerProxyImpl.cpp19
-rw-r--r--cpp/src/qmf/engine/BrokerProxyImpl.h2
-rw-r--r--cpp/src/qmf/engine/QueryImpl.h2
6 files changed, 46 insertions, 5 deletions
diff --git a/cpp/bindings/qmf/tests/python_console.py b/cpp/bindings/qmf/tests/python_console.py
index bcd3063fe3..e7fa78f3a2 100755
--- a/cpp/bindings/qmf/tests/python_console.py
+++ b/cpp/bindings/qmf/tests/python_console.py
@@ -140,6 +140,17 @@ class QmfInteropTests(TestBase010):
self.assertEqual(result.status, 0)
self.assertEqual(result.userid, "guest")
+ def test_D_get_by_object_id(self):
+ self.startQmf()
+ qmf = self.qmf
+
+ parents = qmf.getObjects(_class="parent")
+ self.assertEqual(len(parents), 1)
+ parent = parents[0]
+
+ newList = qmf.getObjects(_objectId=parent.getObjectId())
+ self.assertEqual(len(newList), 1)
+
def getProperty(self, msg, name):
for h in msg.headers:
if hasattr(h, name): return getattr(h, name)
diff --git a/cpp/bindings/qmf/tests/ruby_console_test.rb b/cpp/bindings/qmf/tests/ruby_console_test.rb
index b72c8e3806..e0440367c5 100755
--- a/cpp/bindings/qmf/tests/ruby_console_test.rb
+++ b/cpp/bindings/qmf/tests/ruby_console_test.rb
@@ -186,6 +186,21 @@ class ConsoleTest < ConsoleTestBase
assert_equal(result.args.userid, "anonymous")
end
+ def test_D_get_by_object_id
+ parent = @qmfc.object(:class => "parent")
+ assert(parent, "Number of parent objects")
+
+ list = @qmfc.objects(:object_id => parent.object_id)
+ assert_equal(list.size, 1)
+
+ bad_oid = Qmf::ObjectId.new
+ list = @qmfc.objects(:object_id => bad_oid)
+ assert_equal(list.size, 0)
+
+ # TODO: test a bad_oid that has an agent-bank that is not associated with an attached agent.
+
+ end
+
end
app = ConsoleTest.new
diff --git a/cpp/src/qmf.mk b/cpp/src/qmf.mk
index 2d034cf7c4..96a977f3cd 100644
--- a/cpp/src/qmf.mk
+++ b/cpp/src/qmf.mk
@@ -106,7 +106,7 @@ QMF_REVISION = 0
QMF_AGE = 0
QMF_ENGINE_CURRENT = 1
-QMF_ENGINE_REVISION = 0
+QMF_ENGINE_REVISION = 1
QMF_ENGINE_AGE = 0
libqmf_la_LDFLAGS = -version-info $(QMF_CURRENT):$(QMF_REVISION):$(QMF_AGE)
diff --git a/cpp/src/qmf/engine/BrokerProxyImpl.cpp b/cpp/src/qmf/engine/BrokerProxyImpl.cpp
index 1a2b3e6555..0a1769f891 100644
--- a/cpp/src/qmf/engine/BrokerProxyImpl.cpp
+++ b/cpp/src/qmf/engine/BrokerProxyImpl.cpp
@@ -206,19 +206,31 @@ void BrokerProxyImpl::sendQuery(const Query& query, void* context, const AgentPr
{
SequenceContext::Ptr queryContext(new QueryContext(*this, context));
Mutex::ScopedLock _lock(lock);
+ bool sent = false;
if (agent != 0) {
- sendGetRequestLH(queryContext, query, agent);
+ if (sendGetRequestLH(queryContext, query, agent))
+ sent = true;
} else {
// TODO (optimization) only send queries to agents that have the requested class+package
for (map<uint32_t, AgentProxyPtr>::const_iterator iter = agentList.begin();
iter != agentList.end(); iter++) {
- sendGetRequestLH(queryContext, query, iter->second.get());
+ if (sendGetRequestLH(queryContext, query, iter->second.get()))
+ sent = true;
}
}
+
+ if (!sent) {
+ queryContext->reserve();
+ queryContext->release();
+ }
}
-void BrokerProxyImpl::sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent)
+bool BrokerProxyImpl::sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent)
{
+ if (query.impl->singleAgent()) {
+ if (query.impl->agentBank() != agent->getAgentBank())
+ return false;
+ }
stringstream key;
Buffer outBuffer(outputBuffer, MA_BUFFER_SIZE);
uint32_t sequence(seqMgr.reserve(queryContext));
@@ -229,6 +241,7 @@ void BrokerProxyImpl::sendGetRequestLH(SequenceContext::Ptr queryContext, const
key << "agent.1." << agent->impl->agentBank;
sendBufferLH(outBuffer, QMF_EXCHANGE, key.str());
QPID_LOG(trace, "SENT GetQuery seq=" << sequence << " key=" << key.str());
+ return true;
}
string BrokerProxyImpl::encodeMethodArguments(const SchemaMethod* schema, const Value* argmap, Buffer& buffer)
diff --git a/cpp/src/qmf/engine/BrokerProxyImpl.h b/cpp/src/qmf/engine/BrokerProxyImpl.h
index 798a5fdc76..b651b52345 100644
--- a/cpp/src/qmf/engine/BrokerProxyImpl.h
+++ b/cpp/src/qmf/engine/BrokerProxyImpl.h
@@ -139,7 +139,7 @@ namespace engine {
uint32_t agentCount() const;
const AgentProxy* getAgent(uint32_t idx) const;
void sendQuery(const Query& query, void* context, const AgentProxy* agent);
- void sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent);
+ bool sendGetRequestLH(SequenceContext::Ptr queryContext, const Query& query, const AgentProxy* agent);
std::string encodeMethodArguments(const SchemaMethod* schema, const Value* args, qpid::framing::Buffer& buffer);
void sendMethodRequest(ObjectId* oid, const SchemaObjectClass* cls, const std::string& method, const Value* args, void* context);
diff --git a/cpp/src/qmf/engine/QueryImpl.h b/cpp/src/qmf/engine/QueryImpl.h
index 2c64c6739c..8ebe0d932f 100644
--- a/cpp/src/qmf/engine/QueryImpl.h
+++ b/cpp/src/qmf/engine/QueryImpl.h
@@ -85,6 +85,8 @@ namespace engine {
bool getDecreasing() const { return orderDecreasing; }
void encode(qpid::framing::Buffer& buffer) const;
+ bool singleAgent() const { return oid.get() != 0; }
+ uint32_t agentBank() const { return singleAgent() ? oid->getAgentBank() : 0; }
std::string packageName;
std::string className;