From 2301cd621aabdcbd938cb128859330d11419b2ac Mon Sep 17 00:00:00 2001 From: msmit Date: Tue, 9 Feb 2010 10:24:52 +0000 Subject: Tue Feb 9 10:21:44 UTC 2010 Marcel Smit * connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.h: * connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.cpp: Minor code changes. * connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.h: * connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.cpp: Tested thread switch on sender side. Minor code changes. --- CIAO/ChangeLog | 10 + .../Receiver/CSL_USTest_Receiver_exec.cpp | 14 +- .../Receiver/CSL_USTest_Receiver_exec.h | 2 +- .../CSLUnexpStat/Sender/CSL_USTest_Sender_exec.cpp | 242 ++++++++++++++++++--- .../CSLUnexpStat/Sender/CSL_USTest_Sender_exec.h | 36 ++- 5 files changed, 249 insertions(+), 55 deletions(-) (limited to 'CIAO') diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 64d5a04e6c6..3faa90dd8a2 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,13 @@ +Tue Feb 9 10:21:44 UTC 2010 Marcel Smit + + * connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.h: + * connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.cpp: + Minor code changes. + + * connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.h: + * connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.cpp: + Tested thread switch on sender side. Minor code changes. + Tue Feb 9 10:15:43 UTC 2010 Johnny Willemsen * ciao/ComponentServer/CIAO_RTComponentServer_Task.cpp: diff --git a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.cpp b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.cpp index 14d4ac14a28..099eac6c91a 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.cpp +++ b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.cpp @@ -12,7 +12,7 @@ namespace CIAO_CSL_USTest_Receiver_Impl { -//============================================================ + //============================================================ // ConnectorStatusListener_exec_i //============================================================ ConnectorStatusListener_exec_i::ConnectorStatusListener_exec_i (Atomic_Boolean &subscription_matched_received, @@ -67,23 +67,23 @@ namespace CIAO_CSL_USTest_Receiver_Impl void ConnectorStatusListener_exec_i::on_unexpected_status ( ::DDS::Entity_ptr the_entity, - ::DDS::StatusKind status_kind) + ::DDS::StatusKind status_kind) { - ACE_DEBUG ((LM_DEBUG, "RECEIVER ConnectorStatusListener_exec_i::on_unexpected_status: " + ACE_DEBUG ((LM_DEBUG, "RECEIVER\tConnectorStatusListener_exec_i::on_unexpected_status: " "received <%C>\n", CIAO::DDS4CCM::translate_statuskind (status_kind))); - CORBA::ULong kind = status_kind; - if (!CORBA::is_nil (the_entity) && kind == DDS::SUBSCRIPTION_MATCHED_STATUS) + + if (!CORBA::is_nil (the_entity) && status_kind == DDS::SUBSCRIPTION_MATCHED_STATUS) { this->subscription_matched_received_ = true; this->thread_id_subcription_matched_ = ACE_Thread::self (); } - else if (!CORBA::is_nil(the_entity) && kind == DDS::LIVELINESS_CHANGED_STATUS) + else if (!CORBA::is_nil(the_entity) && status_kind == DDS::LIVELINESS_CHANGED_STATUS) { this->liveliness_changed_received_ = true; this->thread_id_liveliness_changed_ = ACE_Thread::self (); } - else if (!CORBA::is_nil(the_entity) && kind == DDS::PUBLICATION_MATCHED_STATUS) + else if (!CORBA::is_nil(the_entity) && status_kind == DDS::PUBLICATION_MATCHED_STATUS) { this->publication_matched_received_ = true; this->thread_id_publication_matched_ = ACE_Thread::self (); diff --git a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.h b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.h index 1e4da4b4f48..8f635d0d968 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.h +++ b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Receiver/CSL_USTest_Receiver_exec.h @@ -43,7 +43,7 @@ namespace CIAO_CSL_USTest_Receiver_Impl virtual void on_many_data ( const ::TestTopic_Seq & data, - const ::CCM_DDS::ReadInfoSeq & info ); + const ::CCM_DDS::ReadInfoSeq & info); private: Atomic_ULong &received_; diff --git a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.cpp b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.cpp index 2aa2e3cf71e..874c06d46ac 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.cpp +++ b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.cpp @@ -13,14 +13,20 @@ namespace CIAO_CSL_USTest_Sender_Impl { //============================================================ - // Facet Executor Implementation Class: ConnectorStatusListener_exec_i + // ConnectorStatusListener_exec_i //============================================================ - ConnectorStatusListener_exec_i::ConnectorStatusListener_exec_i (Atomic_Boolean &unexpected_pub_matched, - Atomic_Boolean &unexpected_sub_matched, - Atomic_Boolean &unexpected_liveliness) - : unexpected_pub_matched_ (unexpected_pub_matched), - unexpected_sub_matched_ (unexpected_sub_matched), - unexpected_liveliness_ (unexpected_liveliness) + ConnectorStatusListener_exec_i::ConnectorStatusListener_exec_i (Atomic_Boolean &subscription_matched_received, + Atomic_Boolean &publication_matched_received, + Atomic_Boolean &liveliness_changed_received, + Atomic_ThreadId &thread_id_subcription_matched, + Atomic_ThreadId &thread_id_publication_matched, + Atomic_ThreadId &thread_id_liveliness_changed) + : subscription_matched_received_ (subscription_matched_received), + publication_matched_received_ (publication_matched_received), + liveliness_changed_received_ (liveliness_changed_received), + thread_id_subcription_matched_ (thread_id_subcription_matched), + thread_id_publication_matched_ (thread_id_publication_matched), + thread_id_liveliness_changed_ (thread_id_liveliness_changed) { } @@ -63,30 +69,37 @@ namespace CIAO_CSL_USTest_Sender_Impl ::DDS::Entity_ptr the_entity, ::DDS::StatusKind status_kind) { - ACE_DEBUG ((LM_DEBUG, "SENDER ConnectorStatusListener_exec_i::on_unexpected_status: " + ACE_DEBUG ((LM_DEBUG, "SENDER\t\tConnectorStatusListener_exec_i::on_unexpected_status: " "received <%C>\n", CIAO::DDS4CCM::translate_statuskind (status_kind))); - if (!CORBA::is_nil(the_entity) && status_kind == DDS::SUBSCRIPTION_MATCHED_STATUS) + + if (!CORBA::is_nil (the_entity) && status_kind == DDS::SUBSCRIPTION_MATCHED_STATUS) { - this->unexpected_sub_matched_ = true; + this->subscription_matched_received_ = true; + this->thread_id_subcription_matched_ = ACE_Thread::self (); } - else if (!CORBA::is_nil(the_entity) && status_kind == DDS::PUBLICATION_MATCHED_STATUS) + else if (!CORBA::is_nil(the_entity) && status_kind == DDS::LIVELINESS_CHANGED_STATUS) { - this->unexpected_pub_matched_ = true; + this->liveliness_changed_received_ = true; + this->thread_id_liveliness_changed_ = ACE_Thread::self (); } - else if (!CORBA::is_nil(the_entity) && status_kind == DDS::LIVELINESS_CHANGED_STATUS) + else if (!CORBA::is_nil(the_entity) && status_kind == DDS::PUBLICATION_MATCHED_STATUS) { - this->unexpected_liveliness_ = true; + this->publication_matched_received_ = true; + this->thread_id_publication_matched_ = ACE_Thread::self (); } - } + } + //============================================================ - // Component Executor Implementation Class: Sender_exec_i + // Sender_exec_i //============================================================ - Sender_exec_i::Sender_exec_i (void) - : unexpected_pub_matched_ (false), - unexpected_sub_matched_ (false), - unexpected_liveliness_ (false) + : subscription_matched_received_ (false), + publication_matched_received_ (false), + liveliness_changed_received_ (false), + thread_id_listener_subscription_matched_ (0), + thread_id_listener_publication_matched_ (0), + thread_id_listener_liveliness_changed_ (0) { } @@ -97,9 +110,12 @@ namespace CIAO_CSL_USTest_Sender_Impl ::CCM_DDS::CCM_ConnectorStatusListener_ptr Sender_exec_i::get_test_topic_connector_status (void) { - return new ConnectorStatusListener_exec_i (this->unexpected_pub_matched_, - this->unexpected_sub_matched_, - this->unexpected_liveliness_); + return new ConnectorStatusListener_exec_i (this->subscription_matched_received_, + this->publication_matched_received_, + this->liveliness_changed_received_, + this->thread_id_listener_subscription_matched_, + this->thread_id_listener_publication_matched_, + this->thread_id_listener_liveliness_changed_); } // Supported operations and attributes. @@ -132,26 +148,180 @@ namespace CIAO_CSL_USTest_Sender_Impl void Sender_exec_i::ccm_remove (void) { - if(!this->unexpected_pub_matched_.value () || - !this->unexpected_sub_matched_.value () || - !this->unexpected_liveliness_.value ()) + if (!this->subscription_matched_received_.value ()) { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: did not receive the expected ") - ACE_TEXT ("states 'PUBLICATION_MATCHED_STATUS ") - ACE_TEXT ("and/or 'SUBSCRIPTION_MATCHED_STATUS' ") - ACE_TEXT ("and/or 'LIVELINESS_CHANGED_STATUS' ") - ACE_TEXT ("in Sender\n") + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: Didn't receive the expected ") + ACE_TEXT ("'SUBSCRIPTION_MATCHED_STATUS'\n") )); } else { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Received the expected ") - ACE_TEXT ("'LIVELINESS_CHANGED_STATUS' ") - ACE_TEXT ("and 'PUBLICATION_MATCHED_STATUS' ") - ACE_TEXT ("and 'SUBSCRIPTION_MATCHED_STATUS' ") - ACE_TEXT ("in Sender\n") + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK : Received the expected ") + ACE_TEXT ("'SUBSCRIPTION_MATCHED_STATUS' in Receiver\n") )); } + if (!this->publication_matched_received_.value ()) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: Didn't receive the expected ") + ACE_TEXT ("'PUBLICATION_MATCHED_STATUS'\n") + )); + } + else + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK : Received the expected ") + ACE_TEXT ("'PUBLICATION_MATCHED_STATUS' in Receiver\n") + )); + } + if (!this->liveliness_changed_received_.value ()) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR: Didn't receive the expected ") + ACE_TEXT ("'LIVELINESS_CHANGED_STATUS'\n") + )); + } + else + { + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK : Received the expected ") + ACE_TEXT ("'LIVELINESS_CHANGED_STATUS' in Receiver\n") + )); + } + + //test thread switch for SUBSCRIPTION_MATCHED_STATUS + if (this->thread_id_listener_subscription_matched_.value () == 0) + { + ACE_ERROR ((LM_ERROR, "ERROR: " + "Thread ID for 'SUBSCRIPTION_MATCHED_STATUS' not set!\n")); + } + #if defined (CIAO_DDS4CCM_CONTEXT_SWITCH) && (CIAO_DDS4CCM_CONTEXT_SWITCH == 1) + else if (ACE_OS::thr_equal (this->thread_id_listener_subscription_matched_.value (), + ACE_Thread::self ())) + { + ACE_DEBUG ((LM_DEBUG, "OK : " + "Thread switch for 'SUBSCRIPTION_MATCHED_STATUS' seems OK. " + "(DDS uses the CCM thread for its callback) " + "listener <%u> - component <%u>\n", + this->thread_id_listener_subscription_matched_.value (), + ACE_Thread::self ())); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR: " + "Thread switch for 'SUBSCRIPTION_MATCHED_STATUS' " + "doesn't seem to work! " + "listener <%u> - component <%u>\n", + this->thread_id_listener_subscription_matched_.value (), + ACE_Thread::self ())); + } + #else + else if (ACE_OS::thr_equal (this->thread_id_listener_subscription_matched_.value (), + ACE_Thread::self ())) + { + ACE_ERROR ((LM_ERROR, "ERROR: 'SUBSCRIPTION_MATCHED_STATUS': " + "DDS seems to use a CCM thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_subscription_matched_.value (), + ACE_Thread::self ())); + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK : 'SUBSCRIPTION_MATCHED_STATUS': " + "DDS seems to use its own thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_subscription_matched_.value (), + ACE_Thread::self ())); + } + #endif + + //test thread switch for PUBLICATION_MATCHED_STATUS + if (this->thread_id_listener_publication_matched_.value () == 0) + { + ACE_ERROR ((LM_ERROR, "ERROR: " + "Thread ID for 'PUBLICATION_MATCHED_STATUS' not set!\n")); + } + #if defined (CIAO_DDS4CCM_CONTEXT_SWITCH) && (CIAO_DDS4CCM_CONTEXT_SWITCH == 1) + else if (ACE_OS::thr_equal (this->thread_id_listener_publication_matched_.value (), + ACE_Thread::self ())) + { + ACE_DEBUG ((LM_DEBUG, "OK : " + "Thread switch for 'PUBLICATION_MATCHED_STATUS' seems OK. " + "(DDS uses the CCM thread for its callback) " + "listener <%u> - component <%u>\n", + this->thread_id_listener_publication_matched_.value (), + ACE_Thread::self ())); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR: " + "Thread switch for 'PUBLICATION_MATCHED_STATUS' " + "doesn't seem to work! " + "listener <%u> - component <%u>\n", + this->thread_id_listener_publication_matched_.value (), + ACE_Thread::self ())); + } + #else + else if (ACE_OS::thr_equal (this->thread_id_listener_publication_matched_.value (), + ACE_Thread::self ())) + { + ACE_ERROR ((LM_ERROR, "ERROR: 'PUBLICATION_MATCHED_STATUS': " + "DDS seems to use a CCM thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_publication_matched_.value (), + ACE_Thread::self ())); + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK : 'PUBLICATION_MATCHED_STATUS': " + "DDS seems to use its own thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_publication_matched_.value (), + ACE_Thread::self ())); + } + #endif + + //test thread switch for LIVELINESS_CHANGED_STATUS + if (this->thread_id_listener_liveliness_changed_.value () == 0) + { + ACE_ERROR ((LM_ERROR, "ERROR: " + "Thread ID for 'LIVELINESS_CHANGED_STATUS' not set!\n")); + } + #if defined (CIAO_DDS4CCM_CONTEXT_SWITCH) && (CIAO_DDS4CCM_CONTEXT_SWITCH == 1) + else if (ACE_OS::thr_equal (this->thread_id_listener_liveliness_changed_.value (), + ACE_Thread::self ())) + { + ACE_DEBUG ((LM_DEBUG, "OK : " + "Thread switch for 'LIVELINESS_CHANGED_STATUS' seems OK. " + "(DDS uses the CCM thread for its callback) " + "listener <%u> - component <%u>\n", + this->thread_id_listener_liveliness_changed_.value (), + ACE_Thread::self ())); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR: " + "Thread switch for 'LIVELINESS_CHANGED_STATUS' " + "doesn't seem to work! " + "listener <%u> - component <%u>\n", + this->thread_id_listener_liveliness_changed_.value (), + ACE_Thread::self ())); + } + #else + else if (ACE_OS::thr_equal (this->thread_id_listener_liveliness_changed_.value (), + ACE_Thread::self ())) + { + ACE_ERROR ((LM_ERROR, "ERROR: 'LIVELINESS_CHANGED_STATUS': " + "DDS seems to use a CCM thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_liveliness_changed_.value (), + ACE_Thread::self ())); + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK : 'LIVELINESS_CHANGED_STATUS': " + "DDS seems to use its own thread for its callback: " + "listener <%u> - component <%u>\n", + this->thread_id_listener_liveliness_changed_.value (), + ACE_Thread::self ())); + } + #endif } extern "C" SENDER_EXEC_Export ::Components::EnterpriseComponent_ptr diff --git a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.h b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.h index ac567dcfb8d..febf5f851dd 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.h +++ b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/Sender/CSL_USTest_Sender_exec.h @@ -20,18 +20,25 @@ namespace CIAO_CSL_USTest_Sender_Impl { typedef ACE_Atomic_Op Atomic_Boolean; + typedef ACE_Atomic_Op Atomic_ThreadId; class Sender_exec_i; - -class SENDER_EXEC_Export ConnectorStatusListener_exec_i + //============================================================ + // ConnectorStatusListener_exec_i + //============================================================ + class SENDER_EXEC_Export ConnectorStatusListener_exec_i : public virtual ::CCM_DDS::CCM_ConnectorStatusListener, public virtual ::CORBA::LocalObject { public: ConnectorStatusListener_exec_i (Atomic_Boolean &, Atomic_Boolean &, - Atomic_Boolean &); + Atomic_Boolean &, + Atomic_ThreadId &, + Atomic_ThreadId &, + Atomic_ThreadId &); + virtual ~ConnectorStatusListener_exec_i (void); virtual @@ -47,15 +54,19 @@ class SENDER_EXEC_Export ConnectorStatusListener_exec_i void on_offered_deadline_missed (::DDS::DataWriter_ptr the_writer, const DDS::OfferedDeadlineMissedStatus & status); virtual - void on_offered_incompatible_qos (::DDS::DataWriter_ptr the_writer, + void on_offered_incompatible_qos( ::DDS::DataWriter_ptr the_writer, const DDS::OfferedIncompatibleQosStatus & status); virtual - void on_unexpected_status (::DDS::Entity_ptr the_entity, + void on_unexpected_status( ::DDS::Entity_ptr the_entity, ::DDS::StatusKind status_kind); + private: - Atomic_Boolean &unexpected_pub_matched_; - Atomic_Boolean &unexpected_sub_matched_; - Atomic_Boolean &unexpected_liveliness_; + Atomic_Boolean &subscription_matched_received_; + Atomic_Boolean &publication_matched_received_; + Atomic_Boolean &liveliness_changed_received_; + Atomic_ThreadId &thread_id_subcription_matched_; + Atomic_ThreadId &thread_id_publication_matched_; + Atomic_ThreadId &thread_id_liveliness_changed_; }; class Sender_exec_i @@ -79,9 +90,12 @@ class SENDER_EXEC_Export ConnectorStatusListener_exec_i private: ::CSL_USTest::CCM_Sender_Context_var context_; - Atomic_Boolean unexpected_pub_matched_; - Atomic_Boolean unexpected_sub_matched_; - Atomic_Boolean unexpected_liveliness_; + Atomic_Boolean subscription_matched_received_; + Atomic_Boolean publication_matched_received_; + Atomic_Boolean liveliness_changed_received_; + Atomic_ThreadId thread_id_listener_subscription_matched_; + Atomic_ThreadId thread_id_listener_publication_matched_; + Atomic_ThreadId thread_id_listener_liveliness_changed_; }; extern "C" SENDER_EXEC_Export ::Components::EnterpriseComponent_ptr -- cgit v1.2.1