From a7e7ccab0b3094bf1cb6275fb2778ead3e7cdc55 Mon Sep 17 00:00:00 2001 From: arvindk Date: Wed, 6 Aug 2003 23:49:08 +0000 Subject: ChangeLogTag: Wed Aug 6 18:39:32 CDT 2003 Arvind S. Krishna --- .../Latency/Collocation/Client_Task.cpp | 5 +- .../Latency/Collocation/Roundtrip.cpp | 25 +++++ .../Latency/Collocation/Roundtrip.h | 46 ++++++++++ .../Latency/Collocation/Server_Task.cpp | 101 +++++++++++++++++++++ 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 TAO/performance-tests/Latency/Collocation/Roundtrip.cpp create mode 100644 TAO/performance-tests/Latency/Collocation/Roundtrip.h create mode 100644 TAO/performance-tests/Latency/Collocation/Server_Task.cpp diff --git a/TAO/performance-tests/Latency/Collocation/Client_Task.cpp b/TAO/performance-tests/Latency/Collocation/Client_Task.cpp index e96a8c1f826..4acc9e86a3b 100644 --- a/TAO/performance-tests/Latency/Collocation/Client_Task.cpp +++ b/TAO/performance-tests/Latency/Collocation/Client_Task.cpp @@ -1,6 +1,7 @@ // -// $Id$ +// $Id$ // + #include "Client_Task.h" #include "TestC.h" #include "ace/Stats.h" @@ -52,7 +53,7 @@ Client_Task::svc (void) //Warm up the system for (int i=0; i < 1000; i++) rt->test_method (test_time); - + /// Start for actual Measurements ACE_Sample_History history (niterations); diff --git a/TAO/performance-tests/Latency/Collocation/Roundtrip.cpp b/TAO/performance-tests/Latency/Collocation/Roundtrip.cpp new file mode 100644 index 00000000000..5826226a627 --- /dev/null +++ b/TAO/performance-tests/Latency/Collocation/Roundtrip.cpp @@ -0,0 +1,25 @@ +// +// $Id$ +// + +#include "Roundtrip.h" + +Roundtrip::Roundtrip (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +Test::Timestamp +Roundtrip::test_method (Test::Timestamp send_time + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return send_time; +} + +void +Roundtrip::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/performance-tests/Latency/Collocation/Roundtrip.h b/TAO/performance-tests/Latency/Collocation/Roundtrip.h new file mode 100644 index 00000000000..6474b130a24 --- /dev/null +++ b/TAO/performance-tests/Latency/Collocation/Roundtrip.h @@ -0,0 +1,46 @@ +// +// $Id$ +// + +#ifndef ROUNDTRIP_H +#define ROUNDTRIP_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +#if defined (_MSC_VER) +# if (_MSC_VER >= 1200) +# pragma warning(push) +# endif /* _MSC_VER >= 1200 */ +# pragma warning (disable:4250) +#endif /* _MSC_VER */ + +/// Implement the Test::Roundtrip interface +class Roundtrip + : public virtual POA_Test::Roundtrip + , public virtual PortableServer::RefCountServantBase +{ +public: + /// Constructor + Roundtrip (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual Test::Timestamp test_method (Test::Timestamp send_time + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* ROUNDTRIP_H */ diff --git a/TAO/performance-tests/Latency/Collocation/Server_Task.cpp b/TAO/performance-tests/Latency/Collocation/Server_Task.cpp new file mode 100644 index 00000000000..d7e2bdfa920 --- /dev/null +++ b/TAO/performance-tests/Latency/Collocation/Server_Task.cpp @@ -0,0 +1,101 @@ +// +// $Id$ +// + +#include "Server_Task.h" +#include "TestS.h" +#include "Roundtrip.h" + +Server_Task::Server_Task (char* ior_file, + CORBA::ORB_ptr sorb, + ACE_Null_Condition &cond, + ACE_Thread_Manager *thr_mgr) + : ACE_Task_Base (thr_mgr), + ior_file(ior_file), + cond_ (cond), + sorb_ (CORBA::ORB::_duplicate (sorb)) +{ +} + + +int +Server_Task::svc (void) +{ + ACE_TRY_NEW_ENV + { + CORBA::Object_var poa_object = + this->sorb_->resolve_initial_references("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + Roundtrip *rt_impl; + + ACE_NEW_RETURN (rt_impl, + Roundtrip (this->sorb_.in ()), + 1); + + PortableServer::ServantBase_var owner_transfer(rt_impl); + + Test::Roundtrip_var rt_var = + rt_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + this->sorb_->object_to_string (rt_var.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Output the IOR to the output_> + FILE *output_file= ACE_OS::fopen (this->ior_file, + "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + this->ior_file), + 1); + + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Signal the main thread to spawn the client + this->cond_.signal (); + + this->sorb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); + + root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + this->sorb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + + ACE_ENDTRY; + + return 0; +} -- cgit v1.2.1