qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgiu...@apache.org
Subject svn commit: r937506 - in /qpid/trunk/qpid/cpp: bindings/qmf/ruby/ bindings/qmf/tests/ src/qmf/engine/
Date Fri, 23 Apr 2010 20:27:28 GMT
Author: kgiusti
Date: Fri Apr 23 20:27:27 2010
New Revision: 937506

URL: http://svn.apache.org/viewvc?rev=937506&view=rev
Log:
QPID-2546: implement event support for ruby wrapper. Python pending...

Modified:
    qpid/trunk/qpid/cpp/bindings/qmf/ruby/qmf.rb
    qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
    qpid/trunk/qpid/cpp/bindings/qmf/tests/test_base.rb
    qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp
    qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h
    qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp
    qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.h
    qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.cpp
    qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.h

Modified: qpid/trunk/qpid/cpp/bindings/qmf/ruby/qmf.rb
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf/ruby/qmf.rb?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf/ruby/qmf.rb (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf/ruby/qmf.rb Fri Apr 23 20:27:27 2010
@@ -339,7 +339,7 @@ module Qmf
         @impl = Qmfengine::Event.new(@event_class.impl)
       elsif kwargs.include?(:impl)
         @impl = Qmfengine::Event.new(kwargs[:impl])
-        @event_class = SchemaEventClass.new(nil, nil, :impl => @impl.getClass)
+        @event_class = SchemaEventClass.new(nil, nil, nil, :impl => @impl.getClass)
       end
     end
 
@@ -1034,7 +1034,7 @@ module Qmf
           if kind == CLASS_OBJECT
             clist << SchemaObjectClass.new(nil, nil, :impl => @impl.getObjectClass(key))
           elsif kind == CLASS_EVENT
-            clist << SchemaEventClass.new(nil, nil, :impl => @impl.getEventClass(key))
+            clist << SchemaEventClass.new(nil, nil, nil, :impl => @impl.getEventClass(key))
           end
         end
       end
@@ -1190,6 +1190,7 @@ module Qmf
           when Qmfengine::ConsoleEvent::OBJECT_UPDATE
             @handler.object_update(ConsoleObject.new(nil, :impl => @event.object), @event.hasProps,
@event.hasStats) if @handler
           when Qmfengine::ConsoleEvent::EVENT_RECEIVED
+            @handler.event_received(QmfEvent.new(nil, :impl => @event.event)) if @handler
           when Qmfengine::ConsoleEvent::AGENT_HEARTBEAT
             @handler.agent_heartbeat(AgentProxy.new(@event.agent, nil), @event.timestamp)
if @handler
           when Qmfengine::ConsoleEvent::METHOD_RESPONSE

Modified: qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf/tests/ruby_console_test.rb Fri Apr 23 20:27:27 2010
@@ -267,6 +267,39 @@ class ConsoleTest < ConsoleTestBase
   end
 
 
+  def test_F_events
+
+    @event_list.clear
+    @store_events = :true
+
+    parent = @qmfc.object(:class =>"parent")
+    assert(parent, "Number of parent objects")
+
+    parent.set_numerics("big")
+    parent.set_numerics("small")
+    parent.set_numerics("negative")
+    parent.set_short_string("TEST")
+    parent.set_long_string("LONG_TEST")
+    parent.probe_userid()
+
+    @store_events = :false
+
+    assert_equal(@event_list.length, 5)
+
+    assert_equal(@event_list[0].get_attr("uint32val"), 0xA5A55A5A)
+    assert_equal(@event_list[0].get_attr("strval"), "Unused")
+    assert_equal(@event_list[1]["uint32val"], 5)
+    assert_equal(@event_list[1].get_attr("strval"), "Unused")
+    assert_equal(@event_list[2].get_attr("uint32val"), 0)
+    assert_equal(@event_list[2].get_attr("strval"), "Unused")
+    assert_equal(@event_list[3].get_attr("uint32val"), 0)
+    assert_equal(@event_list[3].get_attr("strval"), "TEST")
+    assert_equal(@event_list[4].get_attr("uint32val"), 0)
+    assert_equal(@event_list[4].get_attr("strval"), "LONG_TEST")
+
+    @event_list.clear
+
+  end
 
   def test_G_basic_map_list_data
     parent = @qmfc.object(:class => "parent")

Modified: qpid/trunk/qpid/cpp/bindings/qmf/tests/test_base.rb
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf/tests/test_base.rb?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf/tests/test_base.rb (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf/tests/test_base.rb Fri Apr 23 20:27:27 2010
@@ -28,11 +28,14 @@ class ConsoleTestBase < Qmf::ConsoleHand
     @settings.host = ARGV[0] if ARGV.size > 0
     @settings.port = ARGV[1].to_i if ARGV.size > 1
     @connection = Qmf::Connection.new(@settings)
-    @qmfc = Qmf::Console.new
+    @qmfc = Qmf::Console.new(self)
 
     @broker = @qmfc.add_connection(@connection)
     @broker.wait_for_stable
 
+    @store_events = :false
+    @event_list = []
+
     tests = []
     methods.each do |m|
       name = m.to_s
@@ -70,4 +73,9 @@ class ConsoleTestBase < Qmf::ConsoleHand
   def fail(text)
     raise text
   end
+
+  def event_received(event) 
+    @event_list << event if @store_events
+  end
+
 end

Modified: qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.cpp Fri Apr 23 20:27:27 2010
@@ -445,9 +445,19 @@ void BrokerProxyImpl::handleHeartbeatInd
     QPID_LOG(trace, "RCVD HeartbeatIndication seq=" << seq << " agentBank=" <<
agentBank);
 }
 
-void BrokerProxyImpl::handleEventIndication(Buffer& /*inBuffer*/, uint32_t /*seq*/)
+void BrokerProxyImpl::handleEventIndication(Buffer& inBuffer, uint32_t seq)
 {
-    // TODO
+    auto_ptr<SchemaClassKey> classKey(SchemaClassKeyImpl::factory(inBuffer));
+    const SchemaEventClass *schema = console.impl->getEventClass(classKey.get());
+    if (schema == 0) {
+        QPID_LOG(trace, "No Schema Found for EventIndication. seq=" << seq <<
" key=" << classKey->impl->str());
+        return;
+    }
+
+    EventPtr eptr(EventImpl::factory(schema, inBuffer));
+
+    console.impl->eventEventReceived(eptr);
+    QPID_LOG(trace, "RCVD EventIndication seq=" << seq << " key=" << classKey->impl->str());
 }
 
 void BrokerProxyImpl::handleSchemaResponse(Buffer& inBuffer, uint32_t seq)

Modified: qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h (original)
+++ qpid/trunk/qpid/cpp/src/qmf/engine/BrokerProxyImpl.h Fri Apr 23 20:27:27 2010
@@ -22,6 +22,7 @@
 
 #include "qmf/engine/Console.h"
 #include "qmf/engine/ObjectImpl.h"
+#include "qmf/engine/EventImpl.h"
 #include "qmf/engine/SchemaImpl.h"
 #include "qmf/engine/ValueImpl.h"
 #include "qmf/engine/QueryImpl.h"

Modified: qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.cpp Fri Apr 23 20:27:27 2010
@@ -60,7 +60,7 @@ ConsoleEvent ConsoleEventImpl::copy()
     item.classKey  = classKey;
     item.object    = object.get();
     item.context   = context;
-    item.event     = event;
+    item.event     = event.get();
     item.timestamp = timestamp;
     item.hasProps  = hasProps;
     item.hasStats  = hasStats;
@@ -392,6 +392,15 @@ void ConsoleImpl::eventAgentHeartbeat(bo
     eventQueue.push_back(event);
 }
 
+
+void ConsoleImpl::eventEventReceived(EventPtr event)
+{
+    ConsoleEventImpl::Ptr console_event(new ConsoleEventImpl(ConsoleEvent::EVENT_RECEIVED));
+    console_event->event = event;
+    Mutex::ScopedLock _lock(lock);
+    eventQueue.push_back(console_event);
+}
+
 //==================================================================
 // Wrappers
 //==================================================================

Modified: qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.h?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.h (original)
+++ qpid/trunk/qpid/cpp/src/qmf/engine/ConsoleImpl.h Fri Apr 23 20:27:27 2010
@@ -59,13 +59,13 @@ namespace engine {
         const SchemaClassKey* classKey;
         boost::shared_ptr<Object> object;
         void* context;
-        Event* event;
+        boost::shared_ptr<Event> event;
         uint64_t timestamp;
         bool hasProps;
         bool hasStats;
 
         ConsoleEventImpl(ConsoleEvent::EventKind k) :
-            kind(k), classKey(0), context(0), event(0), timestamp(0) {}
+        kind(k), classKey(0), context(0), timestamp(0) {}
         ~ConsoleEventImpl() {}
         ConsoleEvent copy();
     };
@@ -137,6 +137,7 @@ namespace engine {
         void eventNewClass(const SchemaClassKey* key);
         void eventObjectUpdate(ObjectPtr object, bool prop, bool stat);
         void eventAgentHeartbeat(boost::shared_ptr<AgentProxy> agent, uint64_t timestamp);
+        void eventEventReceived(boost::shared_ptr<Event> event);
     };
 }
 }

Modified: qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.cpp?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.cpp Fri Apr 23 20:27:27 2010
@@ -26,7 +26,7 @@ using namespace std;
 using namespace qmf::engine;
 using qpid::framing::Buffer;
 
-EventImpl::EventImpl(const SchemaEventClass* type) : eventClass(type)
+EventImpl::EventImpl(const SchemaEventClass* type) : eventClass(type), timestamp(0), severity(0)
 {
     int argCount = eventClass->getArgumentCount();
     int idx;
@@ -38,9 +38,21 @@ EventImpl::EventImpl(const SchemaEventCl
 }
 
 
-EventImpl::EventImpl(const SchemaEventClass* type, Buffer&) :
-    eventClass(type)
+EventImpl::EventImpl(const SchemaEventClass* type, Buffer& buffer) :
+    eventClass(type), timestamp(0), severity(0)
 {
+    int argCount = eventClass->getArgumentCount();
+    int idx;
+
+    timestamp = buffer.getLongLong();
+    severity = buffer.getOctet();
+
+    for (idx = 0; idx < argCount; idx++)
+    {
+        const SchemaArgument *arg = eventClass->getArgument(idx);
+        Value* pval = ValueImpl::factory(arg->getType(), buffer);
+        arguments[arg->getName()] = ValuePtr(pval);
+    }
 }
 
 

Modified: qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.h?rev=937506&r1=937505&r2=937506&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.h (original)
+++ qpid/trunk/qpid/cpp/src/qmf/engine/EventImpl.h Fri Apr 23 20:27:27 2010
@@ -29,9 +29,13 @@
 namespace qmf {
 namespace engine {
 
+    typedef boost::shared_ptr<Event> EventPtr;
+
     struct EventImpl {
         typedef boost::shared_ptr<Value> ValuePtr;
         const SchemaEventClass* eventClass;
+        uint64_t timestamp;
+        uint8_t severity;
         mutable std::map<std::string, ValuePtr> arguments;
 
         EventImpl(const SchemaEventClass* type);



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message