From dd6bd1ea7a52660f150364f2b7c8473e8b18cf6e Mon Sep 17 00:00:00 2001 From: irfan Date: Thu, 30 Aug 2001 00:40:43 +0000 Subject: New collocation scheme and related test code. --- TAO/tao/Default_Thread_Lane_Resources_Manager.cpp | 6 + TAO/tao/Default_Thread_Lane_Resources_Manager.h | 3 + TAO/tao/ORB_Core.cpp | 5 +- .../RTCORBA/RT_Thread_Lane_Resources_Manager.cpp | 12 + TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.h | 3 + TAO/tao/RTCORBA/Thread_Pool.cpp | 42 ++ TAO/tao/RTCORBA/Thread_Pool.h | 9 + TAO/tao/Thread_Lane_Resources.cpp | 9 + TAO/tao/Thread_Lane_Resources.h | 9 +- TAO/tao/Thread_Lane_Resources_Manager.h | 4 + TAO/tests/RTCORBA/Collocation/Collocation.cpp | 560 +++++++++++++-------- TAO/tests/RTCORBA/Collocation/test.idl | 2 - TAO/tests/RTCORBA/RTCORBA_tests.dsw | 12 + TAO/tests/RTCORBA/Thread_Pool/test_i.cpp | 2 +- 14 files changed, 465 insertions(+), 213 deletions(-) diff --git a/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp b/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp index 2c949126968..719d8e852a9 100644 --- a/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp +++ b/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp @@ -64,6 +64,12 @@ TAO_Default_Thread_Lane_Resources_Manager::shutdown_reactor (void) this->lane_resources_->shutdown_reactor (); } +int +TAO_Default_Thread_Lane_Resources_Manager::is_collocated (const TAO_MProfile &mprofile) +{ + return this->lane_resources_->is_collocated (mprofile); +} + TAO_Thread_Lane_Resources_Manager * TAO_Default_Thread_Lane_Resources_Manager_Factory::create_thread_lane_resources_manager (TAO_ORB_Core &core) { diff --git a/TAO/tao/Default_Thread_Lane_Resources_Manager.h b/TAO/tao/Default_Thread_Lane_Resources_Manager.h index 6b2c3011eae..5b8faafea25 100644 --- a/TAO/tao/Default_Thread_Lane_Resources_Manager.h +++ b/TAO/tao/Default_Thread_Lane_Resources_Manager.h @@ -49,6 +49,9 @@ public: /// Shutdown reactor. void shutdown_reactor (void); + // Does belong to us? + int is_collocated (const TAO_MProfile &mprofile); + /// @name Accessors // @{ diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 2ef6eb0c4a4..132f8271658 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -1716,9 +1716,6 @@ TAO_ORB_Core::create_collocated_object (TAO_Stub *stub, int TAO_ORB_Core::is_collocated (const TAO_MProfile& mprofile) { - if (!this->lane_resources ().has_acceptor_registry_been_created ()) - return 0; - // @@ Lots of issues arise when dealing with collocation. What about // forwarding or what if this is a multi-profile IOR where the order is // significant and only one of the profiles is collocated. For example @@ -1730,7 +1727,7 @@ TAO_ORB_Core::is_collocated (const TAO_MProfile& mprofile) // address (ORB Host) but not the object_key. This should be checked // also. - return this->lane_resources ().acceptor_registry ().is_collocated (mprofile); + return this->thread_lane_resources_manager ().is_collocated (mprofile); } // **************************************************************** diff --git a/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp b/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp index b89b3615fe9..0c0b75c99cd 100644 --- a/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp +++ b/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp @@ -69,6 +69,18 @@ TAO_RT_Thread_Lane_Resources_Manager::shutdown_reactor (void) this->tp_manager_->shutdown_reactor (); } +int +TAO_RT_Thread_Lane_Resources_Manager::is_collocated (const TAO_MProfile &mprofile) +{ + int result = + this->default_lane_resources_->is_collocated (mprofile); + + if (result) + return result; + + return this->tp_manager_->is_collocated (mprofile); +} + TAO_Thread_Lane_Resources & TAO_RT_Thread_Lane_Resources_Manager::lane_resources (void) { diff --git a/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.h b/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.h index 4cb3587b592..eff190fd84a 100644 --- a/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.h +++ b/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.h @@ -52,6 +52,9 @@ public: /// Shutdown reactor. void shutdown_reactor (void); + // Does belong to us? + int is_collocated (const TAO_MProfile &mprofile); + /// @name Accessors // @{ diff --git a/TAO/tao/RTCORBA/Thread_Pool.cpp b/TAO/tao/RTCORBA/Thread_Pool.cpp index 84ec0e25b86..e2190bf2ce6 100644 --- a/TAO/tao/RTCORBA/Thread_Pool.cpp +++ b/TAO/tao/RTCORBA/Thread_Pool.cpp @@ -177,6 +177,12 @@ TAO_Thread_Lane::wait (void) this->threads_.wait (); } +int +TAO_Thread_Lane::is_collocated (const TAO_MProfile &mprofile) +{ + return this->resources_.is_collocated (mprofile); +} + int TAO_Thread_Lane::create_static_threads (void) { @@ -411,6 +417,24 @@ TAO_Thread_Pool::wait (void) this->lanes_[i]->wait (); } +int +TAO_Thread_Pool::is_collocated (const TAO_MProfile &mprofile) +{ + // Finalize all the lanes. + for (CORBA::ULong i = 0; + i != this->number_of_lanes_; + ++i) + { + int result = + this->lanes_[i]->is_collocated (mprofile); + + if (result) + return result; + } + + return 0; +} + int TAO_Thread_Pool::create_static_threads (void) { @@ -548,6 +572,24 @@ TAO_Thread_Pool_Manager::wait (void) (*iterator).int_id_->wait (); } +int +TAO_Thread_Pool_Manager::is_collocated (const TAO_MProfile &mprofile) +{ + // Finalize all the pools. + for (THREAD_POOLS::ITERATOR iterator = this->thread_pools_.begin (); + iterator != this->thread_pools_.end (); + ++iterator) + { + int result = + (*iterator).int_id_->is_collocated (mprofile); + + if (result) + return result; + } + + return 0; +} + RTCORBA::ThreadpoolId TAO_Thread_Pool_Manager::create_threadpool (CORBA::ULong stacksize, CORBA::ULong static_threads, diff --git a/TAO/tao/RTCORBA/Thread_Pool.h b/TAO/tao/RTCORBA/Thread_Pool.h index f0584ba6a2b..01903b7d761 100644 --- a/TAO/tao/RTCORBA/Thread_Pool.h +++ b/TAO/tao/RTCORBA/Thread_Pool.h @@ -96,6 +96,9 @@ public: /// Wait for threads to exit. void wait (void); + // Does belong to us? + int is_collocated (const TAO_MProfile &mprofile); + /// Create the static threads - only called once. int create_static_threads (void); @@ -195,6 +198,9 @@ public: /// Wait for threads to exit. void wait (void); + // Does belong to us? + int is_collocated (const TAO_MProfile &mprofile); + /// Create the static threads - only called once. int create_static_threads (void); @@ -263,6 +269,9 @@ public: /// Wait for threads to exit. void wait (void); + // Does belong to us? + int is_collocated (const TAO_MProfile &mprofile); + /// Create a threadpool without lanes. RTCORBA::ThreadpoolId create_threadpool (CORBA::ULong stacksize, diff --git a/TAO/tao/Thread_Lane_Resources.cpp b/TAO/tao/Thread_Lane_Resources.cpp index 61107192b52..a305598c07d 100644 --- a/TAO/tao/Thread_Lane_Resources.cpp +++ b/TAO/tao/Thread_Lane_Resources.cpp @@ -42,6 +42,15 @@ TAO_Thread_Lane_Resources::has_acceptor_registry_been_created (void) const return this->acceptor_registry_ != 0; } +int +TAO_Thread_Lane_Resources::is_collocated (const TAO_MProfile& mprofile) +{ + if (!this->has_acceptor_registry_been_created ()) + return 0; + + return this->acceptor_registry ().is_collocated (mprofile); +} + TAO_Acceptor_Registry & TAO_Thread_Lane_Resources::acceptor_registry (void) { diff --git a/TAO/tao/Thread_Lane_Resources.h b/TAO/tao/Thread_Lane_Resources.h index 66fdd55f918..1b2ca3451fa 100644 --- a/TAO/tao/Thread_Lane_Resources.h +++ b/TAO/tao/Thread_Lane_Resources.h @@ -24,6 +24,7 @@ class TAO_ORB_Core; class TAO_Acceptor_Registry; class TAO_Transport_Cache_Manager; class TAO_Leader_Follower; +class TAO_MProfile; /** * @class TAO_Thread_Lane_Resources @@ -42,8 +43,8 @@ public: /// Destructor. ~TAO_Thread_Lane_Resources (void); - /// Checks if the acceptor registry has been created. - int has_acceptor_registry_been_created (void) const; + // Does belong to us? + int is_collocated (const TAO_MProfile &mprofile); /// Open the acceptor registry. int open_acceptor_registry (int ignore_address, @@ -67,6 +68,10 @@ public: // @} private: + + /// Checks if the acceptor registry has been created. + int has_acceptor_registry_been_created (void) const; + /// ORB_Core related to this thread lane. TAO_ORB_Core &orb_core_; diff --git a/TAO/tao/Thread_Lane_Resources_Manager.h b/TAO/tao/Thread_Lane_Resources_Manager.h index 4ede9f3ebc5..d5fbde980b1 100644 --- a/TAO/tao/Thread_Lane_Resources_Manager.h +++ b/TAO/tao/Thread_Lane_Resources_Manager.h @@ -24,6 +24,7 @@ class TAO_ORB_Core; class TAO_Thread_Lane_Resources; class TAO_LF_Strategy; +class TAO_MProfile; /** * @class TAO_Thread_Lane_Resources_Manager @@ -52,6 +53,9 @@ public: /// Shutdown reactor. virtual void shutdown_reactor (void) = 0; + // Does belong to us? + virtual int is_collocated (const TAO_MProfile& mprofile) = 0; + /// @name Accessors // @{ diff --git a/TAO/tests/RTCORBA/Collocation/Collocation.cpp b/TAO/tests/RTCORBA/Collocation/Collocation.cpp index 1d0eb3d26ad..82a64106af9 100644 --- a/TAO/tests/RTCORBA/Collocation/Collocation.cpp +++ b/TAO/tests/RTCORBA/Collocation/Collocation.cpp @@ -2,12 +2,24 @@ #include "ace/Get_Opt.h" #include "ace/Array.h" +#include "tao/ORB_Core.h" +#include "tao/RTCORBA/Thread_Pool.h" #include "testS.h" #include "tao/RTPortableServer/RTPortableServer.h" ACE_RCSID(Collocations, Collocations, "$Id$") -typedef ACE_Array Tests; +RTCORBA::Priority default_thread_priority; + +class test_i; + +struct Test_Object_And_Servant +{ + test_var object_; + test_i *servant_; +}; + +typedef ACE_Array Tests; class test_i : public POA_test, @@ -24,16 +36,31 @@ public: void method (CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)); - void shutdown (CORBA::Environment &ACE_TRY_ENV) - ACE_THROW_SPEC ((CORBA::SystemException)); - PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV); + int client_propagated (void); + + void client_propagated (int); + + void thread_info (const char *method_name); + + void invocation_pool_and_lane (CORBA::ULong pool, + CORBA::ULong lane); + + void invocation_pool (CORBA::ULong pool); + + void invocation_lane (CORBA::ULong lane); + private: CORBA::ORB_var orb_; PortableServer::POA_var poa_; Tests &tests_; + + CORBA::ULong pool_; + CORBA::ULong lane_; + + int client_propagated_; }; test_i::test_i (CORBA::ORB_ptr orb, @@ -41,28 +68,88 @@ test_i::test_i (CORBA::ORB_ptr orb, Tests &tests) : orb_ (CORBA::ORB::_duplicate (orb)), poa_ (PortableServer::POA::_duplicate (poa)), - tests_ (tests) + tests_ (tests), + client_propagated_ (0) { } +int +test_i::client_propagated (void) +{ + return this->client_propagated_; +} + +void +test_i::client_propagated (int client_propagated) +{ + this->client_propagated_ = client_propagated; +} + +void +test_i::invocation_pool_and_lane (CORBA::ULong pool, + CORBA::ULong lane) +{ + this->pool_ = pool; + this->lane_ = lane; +} + +void +test_i::invocation_pool (CORBA::ULong pool) +{ + this->pool_ = pool; +} + +void +test_i::invocation_lane (CORBA::ULong lane) +{ + this->lane_ = lane; +} + void test_i::start (CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_DEBUG ((LM_DEBUG, - "test_i::start\n")); + "\n")); + + this->thread_info ("test_i::start"); + + ACE_DEBUG ((LM_DEBUG, + "\n")); Tests::ITERATOR iterator (this->tests_); while (!iterator.done ()) { - test_var *test = 0; + Test_Object_And_Servant *test = 0; iterator.next (test); - (*test)->method (ACE_TRY_ENV); + if (test->servant_->client_propagated ()) + { + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RTCurrent", + ACE_TRY_ENV); + ACE_CHECK; + + RTCORBA::Current_var current = + RTCORBA::Current::_narrow (object.in (), + ACE_TRY_ENV); + ACE_CHECK; + + CORBA::Short current_thread_priority = + current->the_priority (ACE_TRY_ENV); + ACE_CHECK; + + if (current_thread_priority == default_thread_priority) + test->servant_->invocation_lane (0); + else + test->servant_->invocation_lane (1); + } + + test->object_->method (ACE_TRY_ENV); ACE_CHECK; CORBA::String_var ior = - this->orb_->object_to_string (test->in (), + this->orb_->object_to_string (test->object_.in (), ACE_TRY_ENV); ACE_CHECK; @@ -84,23 +171,43 @@ test_i::start (CORBA::Environment &ACE_TRY_ENV) } void -test_i::method (CORBA::Environment &) - ACE_THROW_SPEC ((CORBA::SystemException)) +test_i::thread_info (const char *method_name) { - ACE_DEBUG ((LM_DEBUG, - "test_i::method\n")); + // Get the ORB_Core's TSS resources. + TAO_ORB_Core_TSS_Resources *tss = + this->orb_->orb_core ()->get_tss_resources (); + + /// Get the lane attribute in TSS. + TAO_Thread_Lane *lane = + (TAO_Thread_Lane *) tss->lane_; + + if (lane) + { + ACE_DEBUG ((LM_DEBUG, + "%s invoked by thread %t (pool id = %d; lane id = %d)\n", + method_name, + lane->pool ().id (), + lane->id ())); + + ACE_ASSERT (this->pool_ == lane->pool ().id ()); + ACE_ASSERT (this->lane_ == lane->id ()); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "%s invoked by thread %t (default thread pool)\n", + method_name)); + + ACE_ASSERT (this->pool_ == 0); + ACE_ASSERT (this->lane_ == 0); + } } void -test_i::shutdown (CORBA::Environment &ACE_TRY_ENV) +test_i::method (CORBA::Environment &) ACE_THROW_SPEC ((CORBA::SystemException)) { - ACE_DEBUG ((LM_DEBUG, - "test_i::shutdown\n")); - - this->orb_->shutdown (0, - ACE_TRY_ENV); - ACE_CHECK; + this->thread_info ("test_i::method"); } PortableServer::POA_ptr @@ -109,91 +216,145 @@ test_i::_default_POA (CORBA_Environment &) return PortableServer::POA::_duplicate (this->poa_.in ()); } -static CORBA::ULong stacksize = 0; -static CORBA::ULong static_threads = 1; -static CORBA::ULong dynamic_threads = 0; -static RTCORBA::Priority default_thread_priority; -static CORBA::Boolean allow_request_buffering = 0; -static CORBA::Boolean allow_borrowing = 0; -static CORBA::ULong max_buffered_requests = 0; -static CORBA::ULong max_request_buffer_size = 0; -static int iterations = 5; +class Server +{ +public: + Server (int argc, + char *argv[], + CORBA::Environment &ACE_TRY_ENV); + + void create_servant_in_root_poa (CORBA::Environment &ACE_TRY_ENV); + void create_poa_and_servant_with_tp_policy (CORBA::Environment &ACE_TRY_ENV); + void create_poa_and_servant_with_tp_with_lanes_policy (const char *poa_name, + RTCORBA::PriorityModel priority_model, + CORBA::Environment &ACE_TRY_ENV); + void test (CORBA::Environment &ACE_TRY_ENV); + void start_testing (CORBA::Environment &ACE_TRY_ENV); + void shutdown (CORBA::Environment &ACE_TRY_ENV); -int -parse_args (int argc, char *argv[]) + CORBA::ORB_var orb_; + RTCORBA::RTORB_var rt_orb_; + PortableServer::POA_var root_poa_; + PortableServer::POAManager_var poa_manager_; + RTCORBA::Current_var current_; + + Tests tests_; + + CORBA::ULong stacksize_; + CORBA::ULong static_threads_; + CORBA::ULong dynamic_threads_; + CORBA::Boolean allow_request_buffering_; + CORBA::Boolean allow_borrowing_; + CORBA::ULong max_buffered_requests_; + CORBA::ULong max_request_buffer_size_; +}; + +Server::Server (int argc, + char *argv[], + CORBA::Environment &ACE_TRY_ENV) + : stacksize_ (0), + static_threads_ (1), + dynamic_threads_ (0), + allow_request_buffering_ (0), + allow_borrowing_ (0), + max_buffered_requests_ (0), + max_request_buffer_size_ (0) { - ACE_Get_Opt get_opts (argc, argv, "i:"); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'i': - iterations = ACE_OS::atoi (get_opts.optarg); - break; - - case '?': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s " - "-i " - "\n", - argv [0]), - -1); - } + this->orb_ = + CORBA::ORB_init (argc, + argv, + "", + ACE_TRY_ENV); + ACE_CHECK; - return 0; + CORBA::Object_var object = + this->orb_->resolve_initial_references ("RTORB", + ACE_TRY_ENV); + ACE_CHECK; + + this->rt_orb_ = + RTCORBA::RTORB::_narrow (object.in (), + ACE_TRY_ENV); + ACE_CHECK; + + object = + this->orb_->resolve_initial_references ("RTCurrent", + ACE_TRY_ENV); + ACE_CHECK; + + this->current_ = + RTCORBA::Current::_narrow (object.in (), + ACE_TRY_ENV); + ACE_CHECK; + + default_thread_priority = + this->current_->the_priority (ACE_TRY_ENV); + ACE_CHECK; + + object = + this->orb_->resolve_initial_references ("RootPOA", + ACE_TRY_ENV); + ACE_CHECK; + + this->root_poa_ = + PortableServer::POA::_narrow (object.in (), + ACE_TRY_ENV); + ACE_CHECK; + + this->poa_manager_ = + this->root_poa_->the_POAManager (ACE_TRY_ENV); + ACE_CHECK; + + this->poa_manager_->activate (ACE_TRY_ENV); + ACE_CHECK; } + void -create_servant_in_root_poa (Tests &tests, - CORBA::ORB_ptr orb, - PortableServer::POA_ptr root_poa, - CORBA::Environment &ACE_TRY_ENV) +Server::create_servant_in_root_poa (CORBA::Environment &ACE_TRY_ENV) { test_i *servant = 0; ACE_NEW_THROW_EX (servant, - test_i (orb, - root_poa, - tests), + test_i (this->orb_.in (), + this->root_poa_.in (), + this->tests_), CORBA::NO_MEMORY ()); ACE_CHECK; + servant->invocation_pool_and_lane (0, 0); + PortableServer::ServantBase_var safe_servant (servant); - tests.size (tests.size () + 1); - tests[tests.size () - 1] = + this->tests_.size (this->tests_.size () + 1); + this->tests_[this->tests_.size () - 1].object_ = servant->_this (ACE_TRY_ENV); + this->tests_[this->tests_.size () - 1].servant_ = + servant; ACE_CHECK; } void -create_poa_and_servant_with_tp_policy (Tests &tests, - CORBA::ORB_ptr orb, - RTCORBA::RTORB_ptr rt_orb, - PortableServer::POA_ptr root_poa, - PortableServer::POAManager_ptr poa_manager, - CORBA::Environment &ACE_TRY_ENV) +Server::create_poa_and_servant_with_tp_policy (CORBA::Environment &ACE_TRY_ENV) { RTCORBA::ThreadpoolId threadpool_id = - rt_orb->create_threadpool (stacksize, - static_threads, - dynamic_threads, - default_thread_priority, - allow_request_buffering, - max_buffered_requests, - max_request_buffer_size, - ACE_TRY_ENV); + this->rt_orb_->create_threadpool (this->stacksize_, + this->static_threads_, + this->dynamic_threads_, + default_thread_priority, + this->allow_request_buffering_, + this->max_buffered_requests_, + this->max_request_buffer_size_, + ACE_TRY_ENV); ACE_CHECK; CORBA::Policy_var threadpool_policy = - rt_orb->create_threadpool_policy (threadpool_id, - ACE_TRY_ENV); + this->rt_orb_->create_threadpool_policy (threadpool_id, + ACE_TRY_ENV); ACE_CHECK; CORBA::Policy_var implicit_activation_policy = - root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION, - ACE_TRY_ENV); + this->root_poa_->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION, + ACE_TRY_ENV); ACE_CHECK; CORBA::PolicyList policies; @@ -207,68 +368,67 @@ create_poa_and_servant_with_tp_policy (Tests &tests, threadpool_policy; PortableServer::POA_var poa = - root_poa->create_POA ("tp_child", - poa_manager, - policies, - ACE_TRY_ENV); + this->root_poa_->create_POA ("tp_child", + this->poa_manager_.in (), + policies, + ACE_TRY_ENV); ACE_CHECK; test_i *servant = 0; ACE_NEW_THROW_EX (servant, - test_i (orb, + test_i (this->orb_.in (), poa.in (), - tests), + this->tests_), CORBA::NO_MEMORY ()); ACE_CHECK; + servant->invocation_pool_and_lane (1, 0); + PortableServer::ServantBase_var safe_servant (servant); - tests.size (tests.size () + 1); - tests[tests.size () - 1] = + this->tests_.size (this->tests_.size () + 1); + this->tests_[this->tests_.size () - 1].object_ = servant->_this (ACE_TRY_ENV); + this->tests_[this->tests_.size () - 1].servant_ = + servant; ACE_CHECK; } void -create_poa_and_servant_with_tp_with_lanes_policy (Tests &tests, - CORBA::ORB_ptr orb, - RTCORBA::RTORB_ptr rt_orb, - PortableServer::POA_ptr root_poa, - PortableServer::POAManager_ptr poa_manager, - const char *poa_name, - RTCORBA::PriorityModel priority_model, - CORBA::Environment &ACE_TRY_ENV) +Server::create_poa_and_servant_with_tp_with_lanes_policy (const char *poa_name, + RTCORBA::PriorityModel priority_model, + CORBA::Environment &ACE_TRY_ENV) { RTCORBA::ThreadpoolLanes lanes (2); lanes.length (2); lanes[0].lane_priority = default_thread_priority; - lanes[0].static_threads = static_threads; - lanes[0].dynamic_threads = dynamic_threads; + lanes[0].static_threads = this->static_threads_; + lanes[0].dynamic_threads = this->dynamic_threads_; lanes[1].lane_priority = default_thread_priority + 1; - lanes[1].static_threads = static_threads; - lanes[1].dynamic_threads = dynamic_threads; + lanes[1].static_threads = this->static_threads_; + lanes[1].dynamic_threads = this->dynamic_threads_; RTCORBA::ThreadpoolId threadpool_id = - rt_orb->create_threadpool_with_lanes (stacksize, - lanes, - allow_borrowing, - allow_request_buffering, - max_buffered_requests, - max_request_buffer_size, - ACE_TRY_ENV); + this->rt_orb_->create_threadpool_with_lanes (this->stacksize_, + lanes, + this->allow_borrowing_, + this->allow_request_buffering_, + this->max_buffered_requests_, + this->max_request_buffer_size_, + ACE_TRY_ENV); ACE_CHECK; CORBA::Policy_var threadpool_policy = - rt_orb->create_threadpool_policy (threadpool_id, - ACE_TRY_ENV); + this->rt_orb_->create_threadpool_policy (threadpool_id, + ACE_TRY_ENV); ACE_CHECK; CORBA::Policy_var priority_model_policy = - rt_orb->create_priority_model_policy (priority_model, - 0, - ACE_TRY_ENV); + this->rt_orb_->create_priority_model_policy (priority_model, + 0, + ACE_TRY_ENV); ACE_CHECK; CORBA::PolicyList policies; @@ -282,10 +442,10 @@ create_poa_and_servant_with_tp_with_lanes_policy (Tests &tests, priority_model_policy; PortableServer::POA_var poa = - root_poa->create_POA (poa_name, - poa_manager, - policies, - ACE_TRY_ENV); + this->root_poa_->create_POA (poa_name, + this->poa_manager_.in (), + policies, + ACE_TRY_ENV); ACE_CHECK; RTPortableServer::POA_var rt_poa = @@ -296,16 +456,16 @@ create_poa_and_servant_with_tp_with_lanes_policy (Tests &tests, test_i *servant1 = 0; test_i *servant2 = 0; ACE_NEW_THROW_EX (servant1, - test_i (orb, + test_i (this->orb_.in (), poa.in (), - tests), + this->tests_), CORBA::NO_MEMORY ()); ACE_CHECK; ACE_NEW_THROW_EX (servant2, - test_i (orb, + test_i (this->orb_.in (), poa.in (), - tests), + this->tests_), CORBA::NO_MEMORY ()); ACE_CHECK; @@ -317,6 +477,9 @@ create_poa_and_servant_with_tp_with_lanes_policy (Tests &tests, if (priority_model == RTCORBA::SERVER_DECLARED) { + servant1->invocation_pool_and_lane (3, 0); + servant2->invocation_pool_and_lane (3, 1); + id1 = rt_poa->activate_object_with_priority (servant1, default_thread_priority, @@ -331,6 +494,11 @@ create_poa_and_servant_with_tp_with_lanes_policy (Tests &tests, } else { + servant1->invocation_pool (2); + servant2->invocation_pool (2); + servant1->client_propagated (1); + servant2->client_propagated (1); + id1 = rt_poa->activate_object (servant1, ACE_TRY_ENV); @@ -352,124 +520,108 @@ create_poa_and_servant_with_tp_with_lanes_policy (Tests &tests, ACE_TRY_ENV); ACE_CHECK; - tests.size (tests.size () + 1); - tests[tests.size () - 1] = + this->tests_.size (this->tests_.size () + 1); + this->tests_[this->tests_.size () - 1].object_ = test::_narrow (object1.in (), ACE_TRY_ENV); + this->tests_[this->tests_.size () - 1].servant_ = + servant1; ACE_CHECK; - tests.size (tests.size () + 1); - tests[tests.size () - 1] = + this->tests_.size (this->tests_.size () + 1); + this->tests_[this->tests_.size () - 1].object_ = test::_narrow (object2.in (), ACE_TRY_ENV); + this->tests_[this->tests_.size () - 1].servant_ = + servant2; ACE_CHECK; } -int -main (int argc, char *argv[]) +void +Server::start_testing (CORBA::Environment &ACE_TRY_ENV) { - ACE_TRY_NEW_ENV + Tests::ITERATOR iterator (this->tests_); + while (!iterator.done ()) { - CORBA::ORB_var orb = - CORBA::ORB_init (argc, - argv, - "", - ACE_TRY_ENV); - ACE_TRY_CHECK; - - CORBA::Object_var object = - orb->resolve_initial_references ("RTORB", - ACE_TRY_ENV); - ACE_TRY_CHECK; + Test_Object_And_Servant *test = 0; + iterator.next (test); - RTCORBA::RTORB_var rt_orb = - RTCORBA::RTORB::_narrow (object.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; + if (test->servant_->client_propagated ()) + { + CORBA::Short current_thread_priority = + this->current_->the_priority (ACE_TRY_ENV); + ACE_CHECK; + + if (current_thread_priority == default_thread_priority) + test->servant_->invocation_lane (0); + else + test->servant_->invocation_lane (1); + } - object = - orb->resolve_initial_references ("RTCurrent", - ACE_TRY_ENV); - ACE_TRY_CHECK; + test->object_->start (ACE_TRY_ENV); + ACE_CHECK; - RTCORBA::Current_var current = - RTCORBA::Current::_narrow (object.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; + iterator.advance (); + } +} - default_thread_priority = - current->the_priority (ACE_TRY_ENV); - ACE_TRY_CHECK; +void +Server::test (CORBA::Environment &ACE_TRY_ENV) +{ + this->start_testing (ACE_TRY_ENV); + ACE_CHECK; - object = - orb->resolve_initial_references ("RootPOA", - ACE_TRY_ENV); - ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG, + "\n\n*** Changing priority to be higher ***\n\n")); - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (object.in (), - ACE_TRY_ENV); - ACE_TRY_CHECK; + this->current_->the_priority (default_thread_priority + 1, + ACE_TRY_ENV); + ACE_CHECK; - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (ACE_TRY_ENV); - ACE_TRY_CHECK; + this->start_testing (ACE_TRY_ENV); + ACE_CHECK; +} - poa_manager->activate (ACE_TRY_ENV); - ACE_TRY_CHECK; +void +Server::shutdown (CORBA::Environment &ACE_TRY_ENV) +{ + this->orb_->shutdown (1, ACE_TRY_ENV); + ACE_CHECK; - Tests tests; + this->orb_->destroy (ACE_TRY_ENV); + ACE_CHECK; +} - create_servant_in_root_poa (tests, - orb.in (), - root_poa.in (), - ACE_TRY_ENV); +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + Server server (argc, + argv, + ACE_TRY_ENV); ACE_TRY_CHECK; - create_poa_and_servant_with_tp_policy (tests, - orb.in (), - rt_orb.in (), - root_poa.in (), - poa_manager.in (), - ACE_TRY_ENV); + server.create_servant_in_root_poa (ACE_TRY_ENV); ACE_TRY_CHECK; - create_poa_and_servant_with_tp_with_lanes_policy (tests, - orb.in (), - rt_orb.in (), - root_poa.in (), - poa_manager.in (), - "tp_with_lanes_client_propagated_poa", - RTCORBA::CLIENT_PROPAGATED, - ACE_TRY_ENV); + server.create_poa_and_servant_with_tp_policy (ACE_TRY_ENV); ACE_TRY_CHECK; - create_poa_and_servant_with_tp_with_lanes_policy (tests, - orb.in (), - rt_orb.in (), - root_poa.in (), - poa_manager.in (), - "tp_with_lanes_server_declared_poa", - RTCORBA::SERVER_DECLARED, - ACE_TRY_ENV); + server.create_poa_and_servant_with_tp_with_lanes_policy ("tp_with_lanes_client_propagated_poa", + RTCORBA::CLIENT_PROPAGATED, + ACE_TRY_ENV); ACE_TRY_CHECK; - Tests::ITERATOR iterator (tests); - while (!iterator.done ()) - { - test_var *test = 0; - iterator.next (test); - - (*test)->start (ACE_TRY_ENV); - ACE_TRY_CHECK; - - iterator.advance (); - } + server.create_poa_and_servant_with_tp_with_lanes_policy ("tp_with_lanes_server_declared_poa", + RTCORBA::SERVER_DECLARED, + ACE_TRY_ENV); + ACE_TRY_CHECK; - orb->shutdown (1, ACE_TRY_ENV); + server.test (ACE_TRY_ENV); ACE_TRY_CHECK; - orb->destroy (ACE_TRY_ENV); + server.shutdown (ACE_TRY_ENV); ACE_TRY_CHECK; } ACE_CATCHANY diff --git a/TAO/tests/RTCORBA/Collocation/test.idl b/TAO/tests/RTCORBA/Collocation/test.idl index 61a9662678b..fb23b0eeb08 100644 --- a/TAO/tests/RTCORBA/Collocation/test.idl +++ b/TAO/tests/RTCORBA/Collocation/test.idl @@ -5,6 +5,4 @@ interface test void start (); void method (); - - void shutdown (); }; diff --git a/TAO/tests/RTCORBA/RTCORBA_tests.dsw b/TAO/tests/RTCORBA/RTCORBA_tests.dsw index 98c72b5ccb5..fd0adcfd92a 100644 --- a/TAO/tests/RTCORBA/RTCORBA_tests.dsw +++ b/TAO/tests/RTCORBA/RTCORBA_tests.dsw @@ -75,6 +75,18 @@ Package=<4> ############################################################################### +Project: "Collocation"=.\Collocation\Collocation.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "Destroy_Thread_Pool"=.\Destroy_Thread_Pool\Destroy_Thread_Pool.dsp - Package Owner=<4> Package=<5> diff --git a/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp b/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp index 034d6e6ef25..0597652d87d 100644 --- a/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp +++ b/TAO/tests/RTCORBA/Thread_Pool/test_i.cpp @@ -39,7 +39,7 @@ test_i::method (CORBA::Long client_id, iteration)); else ACE_DEBUG ((LM_DEBUG, - "Request in thread %t (default pool id) for client %d iteration %d\n", + "Request in thread %t (default thread pool) for client %d iteration %d\n", client_id, iteration)); -- cgit v1.2.1