From 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c Mon Sep 17 00:00:00 2001 From: "William R. Otte" Date: Mon, 24 Jul 2006 15:50:21 +0000 Subject: Repo restructuring --- .../RTEvent/lib/Auto_Disconnect.cpp | 24 +++ .../RTEvent/lib/Auto_Disconnect.h | 54 ++++++ .../RTEvent/lib/Auto_Disconnect.inl | 27 +++ .../performance-tests/RTEvent/lib/Client_Group.cpp | 76 +++++++++ .../performance-tests/RTEvent/lib/Client_Group.h | 101 ++++++++++++ .../performance-tests/RTEvent/lib/Client_Group.inl | 36 ++++ .../RTEvent/lib/Client_Options.cpp | 104 ++++++++++++ .../performance-tests/RTEvent/lib/Client_Options.h | 60 +++++++ .../performance-tests/RTEvent/lib/Client_Pair.cpp | 82 ++++++++++ .../performance-tests/RTEvent/lib/Client_Pair.h | 100 ++++++++++++ .../performance-tests/RTEvent/lib/Client_Pair.inl | 24 +++ .../performance-tests/RTEvent/lib/Consumer.cpp | 141 ++++++++++++++++ .../performance-tests/RTEvent/lib/Consumer.h | 88 ++++++++++ .../performance-tests/RTEvent/lib/Control.cpp | 179 ++++++++++++++++++++ .../performance-tests/RTEvent/lib/Control.h | 80 +++++++++ .../performance-tests/RTEvent/lib/EC_Destroyer.cpp | 34 ++++ .../performance-tests/RTEvent/lib/EC_Destroyer.h | 48 ++++++ .../performance-tests/RTEvent/lib/EC_Destroyer.inl | 7 + .../RTEvent/lib/Federated_Test.idl | 105 ++++++++++++ .../RTEvent/lib/Implicit_Deactivator.cpp | 74 +++++++++ .../RTEvent/lib/Implicit_Deactivator.h | 52 ++++++ .../RTEvent/lib/Implicit_Deactivator.inl | 13 ++ .../performance-tests/RTEvent/lib/Loopback.cpp | 40 +++++ .../performance-tests/RTEvent/lib/Loopback.h | 47 ++++++ .../RTEvent/lib/Loopback_Consumer.cpp | 116 +++++++++++++ .../RTEvent/lib/Loopback_Consumer.h | 76 +++++++++ .../RTEvent/lib/Loopback_Pair.cpp | 56 +++++++ .../performance-tests/RTEvent/lib/Loopback_Pair.h | 79 +++++++++ .../RTEvent/lib/Loopback_Pair.inl | 24 +++ .../RTEvent/lib/Loopback_Supplier.cpp | 134 +++++++++++++++ .../RTEvent/lib/Loopback_Supplier.h | 80 +++++++++ .../RTEvent/lib/Low_Priority_Setup.cpp | 121 ++++++++++++++ .../RTEvent/lib/Low_Priority_Setup.h | 83 ++++++++++ .../RTEvent/lib/Low_Priority_Setup.inl | 7 + .../performance-tests/RTEvent/lib/Makefile.am | 181 +++++++++++++++++++++ .../performance-tests/RTEvent/lib/ORB_Holder.cpp | 37 +++++ .../performance-tests/RTEvent/lib/ORB_Holder.h | 62 +++++++ .../performance-tests/RTEvent/lib/ORB_Holder.inl | 25 +++ .../performance-tests/RTEvent/lib/ORB_Shutdown.cpp | 16 ++ .../performance-tests/RTEvent/lib/ORB_Shutdown.h | 31 ++++ .../performance-tests/RTEvent/lib/ORB_Shutdown.inl | 23 +++ .../performance-tests/RTEvent/lib/ORB_Task.cpp | 39 +++++ .../performance-tests/RTEvent/lib/ORB_Task.h | 46 ++++++ .../performance-tests/RTEvent/lib/ORB_Task.inl | 13 ++ .../RTEvent/lib/ORB_Task_Activator.cpp | 29 ++++ .../RTEvent/lib/ORB_Task_Activator.h | 42 +++++ .../RTEvent/lib/ORB_Task_Activator.inl | 19 +++ .../performance-tests/RTEvent/lib/Peer_Base.cpp | 145 +++++++++++++++++ .../performance-tests/RTEvent/lib/Peer_Base.h | 76 +++++++++ .../RTEvent/lib/PriorityBand_Setup.cpp | 63 +++++++ .../RTEvent/lib/PriorityBand_Setup.h | 46 ++++++ .../RTEvent/lib/PriorityBand_Setup.inl | 8 + .../performance-tests/RTEvent/lib/RIR_Narrow.cpp | 49 ++++++ .../performance-tests/RTEvent/lib/RIR_Narrow.h | 39 +++++ .../RTEvent/lib/RTCORBA_Setup.cpp | 82 ++++++++++ .../performance-tests/RTEvent/lib/RTCORBA_Setup.h | 63 +++++++ .../RTEvent/lib/RTCORBA_Setup.inl | 19 +++ .../RTEvent/lib/RTClient_Setup.cpp | 55 +++++++ .../performance-tests/RTEvent/lib/RTClient_Setup.h | 59 +++++++ .../RTEvent/lib/RTClient_Setup.inl | 19 +++ .../RTEvent/lib/RTEC_Initializer.cpp | 47 ++++++ .../RTEvent/lib/RTEC_Initializer.h | 44 +++++ .../performance-tests/RTEvent/lib/RTEC_Perf.mpc | 16 ++ .../performance-tests/RTEvent/lib/RTPOA_Setup.cpp | 100 ++++++++++++ .../performance-tests/RTEvent/lib/RTPOA_Setup.h | 45 +++++ .../performance-tests/RTEvent/lib/RTPOA_Setup.inl | 13 ++ .../RTEvent/lib/RTServer_Setup.cpp | 57 +++++++ .../performance-tests/RTEvent/lib/RTServer_Setup.h | 50 ++++++ .../RTEvent/lib/RTServer_Setup.inl | 13 ++ .../performance-tests/RTEvent/lib/RT_Class.cpp | 52 ++++++ .../performance-tests/RTEvent/lib/RT_Class.h | 74 +++++++++ .../performance-tests/RTEvent/lib/RT_Class.inl | 37 +++++ .../performance-tests/RTEvent/lib/Send_Task.cpp | 130 +++++++++++++++ .../performance-tests/RTEvent/lib/Send_Task.h | 78 +++++++++ .../RTEvent/lib/Send_Task_Stopper.cpp | 24 +++ .../RTEvent/lib/Send_Task_Stopper.h | 41 +++++ .../RTEvent/lib/Send_Task_Stopper.inl | 16 ++ .../performance-tests/RTEvent/lib/Servant_var.cpp | 58 +++++++ .../performance-tests/RTEvent/lib/Servant_var.h | 81 +++++++++ .../performance-tests/RTEvent/lib/Servant_var.inl | 89 ++++++++++ .../performance-tests/RTEvent/lib/Shutdown.cpp | 17 ++ .../performance-tests/RTEvent/lib/Shutdown.h | 34 ++++ .../performance-tests/RTEvent/lib/Shutdown.inl | 20 +++ .../performance-tests/RTEvent/lib/Supplier.cpp | 121 ++++++++++++++ .../performance-tests/RTEvent/lib/Supplier.h | 81 +++++++++ .../RTEvent/lib/SyncScope_Setup.cpp | 71 ++++++++ .../RTEvent/lib/SyncScope_Setup.h | 53 ++++++ .../RTEvent/lib/SyncScope_Setup.inl | 7 + .../RTEvent/lib/Task_Activator.cpp | 55 +++++++ .../performance-tests/RTEvent/lib/Task_Activator.h | 86 ++++++++++ .../RTEvent/lib/Task_Activator.inl | 13 ++ .../RTEvent/lib/rtec_perf_export.h | 40 +++++ 92 files changed, 5321 insertions(+) create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Control.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Control.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Federated_Test.idl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Makefile.am create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Perf.mpc create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.cpp create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.h create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.inl create mode 100644 TAO/orbsvcs/performance-tests/RTEvent/lib/rtec_perf_export.h (limited to 'TAO/orbsvcs/performance-tests/RTEvent/lib') diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.cpp new file mode 100644 index 00000000000..5acd660e5c4 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.cpp @@ -0,0 +1,24 @@ +/** + * @file Auto_Disconnect.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_AUTO_DISCONNECT_CPP +#define TAO_PERF_RTEC_AUTO_DISCONNECT_CPP + +#include "Auto_Disconnect.h" + +#if !defined(__ACE_INLINE__) +#include "Auto_Disconnect.inl" +#endif /* __ACE_INLINE__ */ + +template Auto_Disconnect& +Auto_Disconnect::operator= (Client *client) +{ + this->reset(client); + return *this; +} + +#endif /* TAO_PERF_RTEC_AUTO_DISCONNECT_CPP */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.h new file mode 100644 index 00000000000..6cb1a65d988 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.h @@ -0,0 +1,54 @@ +/** + * @file Auto_Disconnect.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_AUTO_DISCONNECT_H +#define TAO_PERF_RTEC_AUTO_DISCONNECT_H + +#include "tao/corba.h" +#include "ace/Auto_Functor.h" + +/** + * @class Disconnect + * + * @brief Helper functor to call the disconnect() method of a class. + */ +template +class Disconnect +{ +public: + void operator() (Client *client); +}; + +/** + * @class Auto_Disconnect + * + * @brief Automatically invoke the disconnect() operation on some + * RTEC client. + */ +template +class Auto_Disconnect : public ACE_Utils::Auto_Functor > +{ +public: + /// Constructor + /** + * @param client The client + */ + explicit Auto_Disconnect (Client *s = 0); + + /// Assignment operator + Auto_Disconnect& operator= (Client *client); +}; + +#if defined(__ACE_INLINE__) +#include "Auto_Disconnect.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Auto_Disconnect.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#endif /* TAO_PERF_RTEC_AUTO_DISCONNECT_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.inl new file mode 100644 index 00000000000..3a09d5c68cf --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Auto_Disconnect.inl @@ -0,0 +1,27 @@ +/** + * @file Auto_Disconnect.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#include "ace/CORBA_macros.h" + +template ACE_INLINE void +Disconnect::operator () (Client *client) +{ + ACE_DECLARE_NEW_ENV; + ACE_TRY + { + client->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY { }; + ACE_ENDTRY; +} + +template ACE_INLINE +Auto_Disconnect::Auto_Disconnect (Client *client) + : ACE_Utils::Auto_Functor > (client) +{ +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.cpp new file mode 100644 index 00000000000..7daaf4ae6b4 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.cpp @@ -0,0 +1,76 @@ +/** + * @file Client_Group.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Client_Group.h" +#include "Auto_Disconnect.h" + +#if !defined(__ACE_INLINE__) +#include "Client_Group.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + Client_Group, + "$Id$") + +void +Client_Group::init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa) +{ + this->init (experiment_id, base_event_type, 1, + iterations, workload_in_usecs, gsf, + supplier_poa, consumer_poa); +} + +void +Client_Group::init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::Long event_type_range, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa) +{ + this->client_pair_.init (experiment_id, + base_event_type, + event_type_range, + iterations, + workload_in_usecs, + gsf, + supplier_poa, + consumer_poa); + this->loopback_pair_.init (experiment_id, base_event_type, + supplier_poa, consumer_poa); +} + +void +Client_Group::connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->client_pair_.connect (ec ACE_ENV_ARG_PARAMETER); + Auto_Disconnect client_pair_disconnect (&this->client_pair_); + + this->loopback_pair_.connect (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + Auto_Disconnect loopback_pair_disconnect (&this->loopback_pair_); + + loopback_pair_disconnect.release (); + client_pair_disconnect.release (); +} + +void +Client_Group::disconnect (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + Auto_Disconnect client_pair_disconnect (&this->client_pair_); + Auto_Disconnect loopback_pair_disconnect (&this->loopback_pair_); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.h new file mode 100644 index 00000000000..ef93ba153c1 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.h @@ -0,0 +1,101 @@ +/** + * @file Client_Group.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_CLIENT_GROUP_H +#define TAO_PERF_RTEC_CLIENT_GROUP_H + +#include "Servant_var.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Client_Pair.h" +#include "Loopback_Pair.h" + +/** + * @class Client_Group + * + * @brief Simplify the initialization of a Supplier/Consumer pair + * connected through a Loopback. + */ +class TAO_RTEC_Perf_Export Client_Group +{ +public: + /// Constructor + /** + * We need a default constructor because this class is often used in + * arrays. + */ + Client_Group (void); + + /// Initialize the consumer/supplier pair(s) + /** + * @param experiment_id For tests that run multiple experiments + * this number is changed on each iteration, guaranteeing + * better isolation. + * @param base_event_type The event type generated by the supplier. + * The Loopback_Consumer consumes the same event, the + * Loopback_Supplier generates (base_event_type + 1), and the + * consumer subscribes for that type too. + * @param iterations The number of iterations expected on the test. + * @param workload_in_usecs The consumer workload, in microseconds. + * @param gsf The high resolution timer global scale factor. + * + */ + void init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa); + + /// Initialize the consumer/supplier pair(s) + /** + * @param event_type_range The supplier declares more events than it + * generates. + */ + void init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::Long base_event_type_range, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa); + + /// Connect to the event channel + void connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + /// Disconnect from the event channel + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + //@{ + /** @name Accessors + */ + Supplier *supplier (void) const; + + Consumer *consumer (void) const; + + Loopback_Supplier *loopback_supplier (void) const; + + Loopback_Consumer *loopback_consumer (void) const; + //@} + +private: + Client_Pair client_pair_; + Loopback_Pair loopback_pair_; +}; + +#if defined(__ACE_INLINE__) +#include "Client_Group.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_CLIENT_GROUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.inl new file mode 100644 index 00000000000..b0ae0d1ce35 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Group.inl @@ -0,0 +1,36 @@ +/** + * @file Client_Group.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE +Client_Group::Client_Group (void) +{ +} + +ACE_INLINE Supplier * +Client_Group::supplier (void) const +{ + return this->client_pair_.supplier (); +} + +ACE_INLINE Consumer * +Client_Group::consumer (void) const +{ + return this->client_pair_.consumer (); +} + +ACE_INLINE Loopback_Supplier * +Client_Group::loopback_supplier (void) const +{ + return this->loopback_pair_.loopback_supplier (); +} + +ACE_INLINE Loopback_Consumer * +Client_Group::loopback_consumer (void) const +{ + return this->loopback_pair_.loopback_consumer (); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.cpp new file mode 100644 index 00000000000..c8e69760669 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.cpp @@ -0,0 +1,104 @@ +/** + * @file Client_Options.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Client_Options.h" + +#include "ace/Log_Msg.h" +#include "ace/OS.h" + +ACE_RCSID (TAO_PERF_RTEC, + Client_Options, + "$Id$") + +Client_Options::Client_Options (int &argc, char *argv[]) + : ior ("file://test.ior") + , iterations (1000) + , nthreads (0) + , high_priority_period (0) + , high_priority_workload (0) + , low_priority_period (0) + , low_priority_workload (0) + , low_priority_consumers (0) + , dump_history (0) + , use_rt_corba (0) + , global_low_priority_rate (0) + , unique_low_priority_event (0) + , funky_supplier_publication (0) + , high_priority_is_last (0) +{ + ACE_Arg_Shifter arg_shifter (argc, argv); + + while (arg_shifter.is_anything_left ()) + { + const char *arg = arg_shifter.get_current (); + + if (ACE_OS::strcmp (arg, "-k") == 0) + { + arg_shifter.consume_arg (); + + if (arg_shifter.is_parameter_next ()) + { + this->ior = arg_shifter.get_current (); + arg_shifter.consume_arg (); + } + } + + else if (option (arg_shifter, "-i", iterations)) {} + else if (option (arg_shifter, "-n", nthreads)) {} + else if (option (arg_shifter, "-h", high_priority_period)) {} + else if (option (arg_shifter, "-l", low_priority_period)) {} + else if (option (arg_shifter, "-w", low_priority_workload)) {} + else if (option (arg_shifter, "-v", high_priority_workload)) {} + else if (option (arg_shifter, "-c", low_priority_consumers)) {} + + else if (boolean_option (arg_shifter, "-d", dump_history)) {} + else if (boolean_option (arg_shifter, "-r", use_rt_corba)) {} + else if (boolean_option (arg_shifter, "-g", global_low_priority_rate)) {} + else if (boolean_option (arg_shifter, "-u", unique_low_priority_event)) {} + else if (boolean_option (arg_shifter, "-f", funky_supplier_publication)) {} + else if (boolean_option (arg_shifter, "-x", high_priority_is_last)) {} + + else + { + arg_shifter.ignore_arg (); + } + } +} + +int +Client_Options::option (ACE_Arg_Shifter &arg_shifter, + const char *option_name, + int &option_value) +{ + if (ACE_OS::strcmp (arg_shifter.get_current (), option_name) != 0) + return 0; + arg_shifter.consume_arg (); + if (arg_shifter.is_parameter_next ()) + { + option_value = ACE_OS::atoi (arg_shifter.get_current ()); + arg_shifter.consume_arg (); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "Missing value for option '%s'\n", option_name)); + } + return 1; +} + +int +Client_Options::boolean_option (ACE_Arg_Shifter &arg_shifter, + const char *option_name, + int &option_value) +{ + if (ACE_OS::strcmp (arg_shifter.get_current (), option_name) != 0) + return 0; + arg_shifter.consume_arg (); + option_value = 1; + return 1; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.h new file mode 100644 index 00000000000..8d12ab4fafc --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Options.h @@ -0,0 +1,60 @@ +/** + * @file Client_Options.h + * + * $Id$ + * + * @author Carlos O'Ryan + * + */ + +#ifndef TAO_RTEC_PERF_CLIENT_OPTIONS_H +#define TAO_RTEC_PERF_CLIENT_OPTIONS_H +#include /**/ "ace/pre.h" + +#include "rtec_perf_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Arg_Shifter.h" + +/// Parse the command-line client_options for the tests. +/** + * Note that some of the tests ignore some of the client_options, but it is + * easier to have them all in a single class. + */ +class TAO_RTEC_Perf_Export Client_Options +{ +public: + /// Constructor + Client_Options (int &argc, char *argv[]); + + const char *ior; + int iterations; + int nthreads; + int high_priority_period; + int high_priority_workload; + int low_priority_period; + int low_priority_workload; + int low_priority_consumers; + + int dump_history; + int use_rt_corba; + int global_low_priority_rate; + int unique_low_priority_event; + int funky_supplier_publication; + int high_priority_is_last; + +private: + int option (ACE_Arg_Shifter &arg_shifter, + const char *option_name, + int &option_value); + + int boolean_option (ACE_Arg_Shifter &arg_shifter, + const char *option_name, + int &option_value); +}; + +#include /**/ "ace/post.h" +#endif /* TAO_RTEC_PERF_CLIENT_OPTIONS_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.cpp new file mode 100644 index 00000000000..9f32c911ff2 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.cpp @@ -0,0 +1,82 @@ +/** + * @file Client_Pair.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Client_Pair.h" +#include "Auto_Disconnect.h" + +#if !defined(__ACE_INLINE__) +#include "Client_Pair.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + Client_Pair, + "$Id$") + +void +Client_Pair::init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa) +{ + const CORBA::Long source_event_range = 1; + this->init (experiment_id, + base_event_type, + source_event_range, + iterations, + workload_in_usecs, + gsf, + supplier_poa, + consumer_poa); +} + +void +Client_Pair::init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::Long source_event_range, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa) +{ + this->supplier_ = new Supplier (experiment_id, + base_event_type, source_event_range, + supplier_poa); + this->consumer_ = new Consumer (experiment_id, + base_event_type + 1, + iterations, + workload_in_usecs, + gsf, + consumer_poa); +} + +void +Client_Pair::connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->supplier_->connect (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + Auto_Disconnect supplier_disconnect (this->supplier_); + + this->consumer_->connect (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + Auto_Disconnect consumer_disconnect (this->consumer_); + + consumer_disconnect.release (); + supplier_disconnect.release (); +} + +void +Client_Pair::disconnect (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + Auto_Disconnect supplier_disconnect (this->supplier_); + Auto_Disconnect consumer_disconnect (this->consumer_); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.h new file mode 100644 index 00000000000..8dc4e8b03b2 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.h @@ -0,0 +1,100 @@ +/** + * @file Client_Pair.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_CLIENT_PAIR_H +#define TAO_PERF_RTEC_CLIENT_PAIR_H + +#include "Servant_var.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Consumer.h" +#include "Supplier.h" + +/** + * @class Client_Pair + * + * @brief Simplify the initialization of a Supplier/Consumer pair + * connected to the event channel. + */ +class TAO_RTEC_Perf_Export Client_Pair +{ +public: + /// Constructor + /** + * We need a default constructor because this class is often used in + * arrays. + */ + Client_Pair (void); + + /// Initialize the consumer/supplier pair + /** + * @param experiment_id For tests that run multiple experiments + * this number is changed on each iteration, guaranteeing + * better isolation. + * @param base_event_type The event type generated by the supplier. + * The Loopback_Consumer consumes the same event, the + * Loopback_Supplier generates (base_event_type + 1), and the + * consumer subscribes for that type too. + * @param iterations The number of iterations expected on the test. + * @param workload_in_usecs The consumer workload, in microseconds. + * @param gsf The high resolution timer global scale factor. + * + */ + void init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa); + + /// Initialize the consumer/supplier pair + /** + * This variant works as the previous one, but it allows for + * multiple events in the supplier-side. + * + * @param source_event_range The number of events declared by the + * source. + */ + void init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + CORBA::Long source_event_range, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa); + + /// Connect to the event channel + void connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + /// Disconnect from the event channel + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + //@{ + /** @name Accessors + */ + Supplier *supplier (void) const; + + Consumer *consumer (void) const; + //@} + +private: + Servant_var supplier_; + Servant_var consumer_; +}; + +#if defined(__ACE_INLINE__) +#include "Client_Pair.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_CLIENT_PAIR_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.inl new file mode 100644 index 00000000000..a4c0f7cabb7 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Client_Pair.inl @@ -0,0 +1,24 @@ +/** + * @file Client_Pair.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE +Client_Pair::Client_Pair (void) +{ +} + +ACE_INLINE Supplier * +Client_Pair::supplier (void) const +{ + return this->supplier_.in (); +} + +ACE_INLINE Consumer * +Client_Pair::consumer (void) const +{ + return this->consumer_.in (); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.cpp new file mode 100644 index 00000000000..5fc7489897e --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.cpp @@ -0,0 +1,141 @@ +/** + * @file Consumer.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Consumer.h" +#include "Implicit_Deactivator.h" +#include "orbsvcs/Event_Service_Constants.h" +#include "ace/OS_NS_unistd.h" + +ACE_RCSID (TAO_PERF_RTEC, + Consumer, + "$Id$") + +Consumer::Consumer (CORBA::Long experiment_id, + CORBA::Long event_type, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr poa) + : experiment_id_ (experiment_id) + , event_type_ (event_type) + , sample_history_ (iterations) + , workload_in_usecs_ (workload_in_usecs) + , gsf_ (gsf) + , default_POA_ (PortableServer::POA::_duplicate (poa)) +{ +} + +void +Consumer::connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = + ec->for_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (!CORBA::is_nil (this->proxy_supplier_.in ())) + return; + + this->proxy_supplier_ = + consumer_admin->obtain_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + + RtecEventComm::PushConsumer_var consumer = + this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::ConsumerQOS consumer_qos; + consumer_qos.is_gateway = 0; + consumer_qos.dependencies.length (2); + RtecEventComm::EventHeader& h0 = + consumer_qos.dependencies[0].event.header; + h0.type = ACE_ES_DISJUNCTION_DESIGNATOR; + h0.source = 1; + + RtecEventComm::EventHeader& h1 = + consumer_qos.dependencies[1].event.header; + h1.type = this->event_type_; + h1.source = this->experiment_id_; + + this->proxy_supplier_->connect_push_consumer (consumer.in (), + consumer_qos + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +Consumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + RtecEventChannelAdmin::ProxyPushSupplier_var proxy; + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (CORBA::is_nil (this->proxy_supplier_.in ())) + return; + proxy = this->proxy_supplier_._retn (); + } + + Implicit_Deactivator deactivator (this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY { + proxy->disconnect_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY { + } ACE_ENDTRY; +} + +ACE_Sample_History & +Consumer::sample_history (void) +{ + return this->sample_history_; +} + +void +Consumer::push (const RtecEventComm::EventSet &events + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_hrtime_t now = ACE_OS::gethrtime (); + + ACE_hrtime_t creation; + ORBSVCS_Time::TimeT_to_hrtime (creation, + events[0].header.creation_time); + + while (this->workload_in_usecs_ > 0) + { + ACE_hrtime_t elapsed = ACE_OS::gethrtime () - now; + if (elapsed > this->gsf_ * this->workload_in_usecs_) + break; + ACE_OS::sleep (0); + } + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (sample_history_.max_samples () == sample_history_.sample_count ()) + return; + this->sample_history_.sample (now - creation); +} + +void +Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + this->proxy_supplier_ = + RtecEventChannelAdmin::ProxyPushSupplier::_nil (); +} + +PortableServer::POA_ptr +Consumer::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.h new file mode 100644 index 00000000000..f9206fe4ba2 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Consumer.h @@ -0,0 +1,88 @@ +/** + * @file Consumer.h + * + * $Id$ + * + */ + +#ifndef TAO_PERF_RTEC_CONSUMER_H +#define TAO_PERF_RTEC_CONSUMER_H + +#include "rtec_perf_export.h" +#include "orbsvcs/RtecEventCommS.h" +#include "orbsvcs/RtecEventChannelAdminC.h" + +#include "ace/Sample_History.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Consumer + * + * @brief Implement a simple consumer to keep track of the latency + * + */ +class TAO_RTEC_Perf_Export Consumer + : public virtual POA_RtecEventComm::PushConsumer + +{ +public: + /// Constructor + Consumer (CORBA::Long experiment_id, + CORBA::Long event_type, + CORBA::ULong iterations, + CORBA::Long workload_in_usecs, + ACE_UINT32 gsf, + PortableServer::POA_ptr poa); + + /// Connect to the event channel + void connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + /// Disconnect from the event channel + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + /// Access the history of samples + ACE_Sample_History &sample_history (void); + + //@{ + /** @name The RtecEventComm::PushConsumer methods + */ + virtual void push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +private: + /// Synchronize access to the internal data + TAO_SYNCH_MUTEX mutex_; + + /// The proxy this object is connected to + RtecEventChannelAdmin::ProxyPushSupplier_var proxy_supplier_; + + /// The experiment id + CORBA::Long experiment_id_; + + /// The event type + CORBA::Long event_type_; + + /// The history of latency samples + ACE_Sample_History sample_history_; + + /// The time spent processing each event, in microseconds + CORBA::ULong workload_in_usecs_; + + /// The global scale factor for the high resolution timers + ACE_UINT32 gsf_; + + /// The default poa + PortableServer::POA_var default_POA_; +}; + +#endif /* TAO_PERF_RTEC_CONSUMER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Control.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Control.cpp new file mode 100644 index 00000000000..b35d809551c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Control.cpp @@ -0,0 +1,179 @@ +/** + * @file Control.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Control.h" +#include "ORB_Shutdown.h" +#include "Shutdown.h" +#include "Auto_Disconnect.h" + +#include "orbsvcs/Event_Service_Constants.h" + +#include "ace/High_Res_Timer.h" +#include "ace/Sample_History.h" +#include "ace/Basic_Stats.h" +#include "ace/Auto_Ptr.h" + +ACE_RCSID (TAO_RTEC_Perf, + Control, + "$Id$") + +Control::Control (size_t peers_expected, + size_t iterations, + int do_dump_history, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : peers_expected_ (peers_expected) + , iterations_ (iterations) + , do_dump_history_ (do_dump_history) + , orb_ (CORBA::ORB::_duplicate (orb)) + , poa_ (PortableServer::POA::_duplicate (poa)) + , peers_count_ (0) + , peers_ (new Federated_Test::Peer_var[this->peers_expected_]) +{ +} + +Control::~Control (void) +{ + delete[] this->peers_; +} + +void +Control::join (Federated_Test::Peer_ptr peer + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (this->peers_count_ == this->peers_expected_) + return; + + this->peers_[this->peers_count_++] = + Federated_Test::Peer::_duplicate (peer); + + if (this->peers_count_ < this->peers_expected_) + return; + } + + /// Automatically shutdown the ORB + ACE_Utils::Auto_Functor orb_shutdown (this->orb_.in ()); + + /// Automatically shutdown the peers + typedef ACE_Utils::Auto_Functor > Peer_Shutdown; + ACE_Auto_Basic_Array_Ptr peer_shutdown ( + new Peer_Shutdown[this->peers_count_] + ); + + size_t i; + for (i = 0; i != this->peers_count_; ++i) + { + peer_shutdown[i].reset(this->peers_[i].in()); + } + + ACE_DEBUG ((LM_DEBUG, + "Control (%P|%t) Building the federation\n")); + + /// Build the EC federation + for (i = 0; i != this->peers_count_; ++i) + { + for (size_t j = 0; j != this->peers_count_; ++j) + { + if (i != j) + { + this->peers_[j]->connect (this->peers_[i].in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } + } + + /// ... run the test(s) ... + for (i = 0; i != this->peers_count_; ++i) + { + /// ... automatically release the object references ... + ACE_Auto_Basic_Array_Ptr loopbacks ( + new Federated_Test::Loopback_var[2*this->peers_count_] + ); + + /// ... and automatically disconnect the loopbacks ... + typedef Auto_Disconnect Loopback_Disconnect; + ACE_Auto_Basic_Array_Ptr > disconnects ( + new auto_ptr[2*this->peers_count_] + ); + + ACE_DEBUG ((LM_DEBUG, + "Control (%P|%t) Running test for peer %d\n", + i)); + CORBA::Long experiment_id = 128 + i; + CORBA::Long base_event_type = ACE_ES_EVENT_UNDEFINED; + + size_t lcount = 0; + + size_t j; + for (j = 0; j != this->peers_count_; ++j) + { + if (j != i) + { + loopbacks[lcount] = + this->peers_[j]->setup_loopback (experiment_id, + base_event_type + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_AUTO_PTR_RESET (disconnects[lcount], + new Loopback_Disconnect ( + loopbacks[lcount].in ()), + Loopback_Disconnect + ); + lcount++; + + loopbacks[lcount] = + this->peers_[j]->setup_loopback (experiment_id, + base_event_type + 2 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_AUTO_PTR_RESET (disconnects[lcount], + new Loopback_Disconnect ( + loopbacks[lcount].in ()), + Loopback_Disconnect + ); + lcount++; + } + } + + Federated_Test::Experiment_Results_var results = + this->peers_[i]->run_experiment (experiment_id, + this->iterations_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_Sample_History history (results->length ()); + for (CORBA::ULong k = 0; k != results->length (); ++k) + history.sample (results[k]); + + // We use a fake scale factor because the peer already converted + // to microseconds... + const ACE_UINT32 fake_scale_factor = 1; + + ACE_Basic_Stats stats; + history.collect_basic_stats (stats); + stats.dump_results ("Total", fake_scale_factor); + + if (this->do_dump_history_) + { + history.dump_samples ("HISTORY", fake_scale_factor); + } + } +} + +PortableServer::POA_ptr +Control::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Control.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Control.h new file mode 100644 index 00000000000..9b09d063fb0 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Control.h @@ -0,0 +1,80 @@ +/** + * @file Control.h + * + * $Id$ + * + */ + +#ifndef TAO_RTEC_PERF_CONTROL_H +#define TAO_RTEC_PERF_CONTROL_H +#include /**/ "ace/pre.h" + +#include "Federated_TestS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Control + * + * @brief Implement the Federated_Test::Control interface + * + */ +class TAO_RTEC_Perf_Export Control + : public virtual POA_Federated_Test::Control +{ +public: + /// Constructor + Control (size_t peers_expected, + size_t iterations, + int do_dump_history, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa); + + /// Destructor + virtual ~Control (void); + + //@{ + /** @name The Federated_Test::Control methods + */ + virtual void join (Federated_Test::Peer_ptr peer + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +private: + /// Synchronize access to the internal data + TAO_SYNCH_MUTEX mutex_; + + /// Number of peers expected + size_t peers_expected_; + + /// Number of iterations on each test + size_t iterations_; + + /// This flag is set to 1 to dump the complete test history + int do_dump_history_; + + /// Keep a reference to the ORB, used in shutdown + CORBA::ORB_var orb_; + + /// The default POA + PortableServer::POA_var poa_; + + /// Current number of items in the in the @c peers_ array. + size_t peers_count_; + + /// An array to keep the list of peers. + /** + * @todo I would like to use ACE_Array<> but the interface is too + * confusing. std::vector<> would be better, but I'm not allowed to + */ + Federated_Test::Peer_var *peers_; +}; + +#include /**/ "ace/post.h" +#endif /* TAO_RTEC_PERF_CONTROL_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.cpp new file mode 100644 index 00000000000..220c8c3957c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.cpp @@ -0,0 +1,34 @@ +/** + * @file EC_Destroyer.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "EC_Destroyer.h" + +#if !defined(__ACE_INLINE__) +#include "EC_Destroyer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + EC_Destroyer, + "$Id$") + +EC_Destroyer::EC_Destroyer (RtecEventChannelAdmin::EventChannel_ptr ec) + : ec_ (RtecEventChannelAdmin::EventChannel::_duplicate (ec)) +{ +} + +EC_Destroyer::~EC_Destroyer (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY { + this->ec_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCH (CORBA::Exception, ex) { + // @@ TODO Log this event, check the Servant_var.cpp comments for + // details. + } ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.h new file mode 100644 index 00000000000..0c622a996a8 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.h @@ -0,0 +1,48 @@ +/** + * @file EC_Destroyer.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_EC_DESTROYER_H +#define TAO_PERF_RTEC_EC_DESTROYER_H + +#include "rtec_perf_export.h" +#include "orbsvcs/RtecEventChannelAdminC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class EC_Destroyer + * + * @brief Implement a helper class to destroy a Real-time Event + * Channel. + * + */ +class TAO_RTEC_Perf_Export EC_Destroyer +{ +public: + /// Constructor + EC_Destroyer (RtecEventChannelAdmin::EventChannel_ptr ec); + + /// Destructor + /** + * @todo This method could benefit from the error logging described + * in Servant_var.cpp + */ + ~EC_Destroyer (void); + +private: + /// The event channel + RtecEventChannelAdmin::EventChannel_var ec_; +}; + +#if defined(__ACE_INLINE__) +#include "EC_Destroyer.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_EC_DESTROYER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.inl new file mode 100644 index 00000000000..8106257cde1 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/EC_Destroyer.inl @@ -0,0 +1,7 @@ +/** + * @file EC_Destroyer.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Federated_Test.idl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Federated_Test.idl new file mode 100644 index 00000000000..ac013f92dd2 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Federated_Test.idl @@ -0,0 +1,105 @@ +/** + * @file Federated_Test.idl + * + * $Id$ + * + * @author Carlos O'Ryan + * + */ + +module Federated_Test +{ + interface Peer; + + interface Loopback; + + /** + * @interface Coordinator + * + * @brief Controls a federated test. + * + * Implementations of the Control interface: + * + * -# wait for all the peers to join + * -# connecting the peers to each other + * -# run different experiments on each peer + * -# collect the results and print them + * + */ + interface Control + { + /// Join a new peer into the simulation. + /** + * Implementations of this interface arbitrarly decide when there + * are "enough" peers to run the test. + */ + void join (in Peer the_peer); + }; + + /// The results of a single experiment + typedef sequence Experiment_Results; + + /** + * @interface Peer + * + * @brief A member of a federated test + * + * Peers define the required interface to participate in a federated + * test. + */ + interface Peer + { + /// Shutdown the peer + void shutdown (); + + /// Setup an Consumer/Supplier loopback pair + /** + * Some experiments require one or more peers to setup a + * "loopback" through their event channel, i.e. a + * Consumer/Supplier pair that simply "loop" every event they + * receive through the event channel. + * + * @param experiment_id Each experiment receives a unique ID to + * separate resources. + * + * @param base_event_type The type the Consumer part of the + * loopback should subscribe to, the supplier generate events of + * type base_event_type + 1 + * + * @return The returned object can be used to disconnect and + * destroy the loopback elements. + */ + Loopback setup_loopback (in long experiment_id, + in long base_event_type); + + /// Run a single experiment + /** + * @param experiment_id Each experiment is assigned a different ID + * by the Control object. + * @param iterations How many iterations of the experiment should + * be run. + * + * @return All the samples captured in the experiment, the samples + * are returned in microseconds. + */ + Experiment_Results run_experiment (in long experiment_id, + in long iterations); + + /// Return the event channel in this peer + readonly attribute Object channel; + + /// Connect to a remote peer + void connect (in Peer remote_peer); + }; + + /** + * @interface Loopback + * + * @brief Control the elements on a Consumer/Supplier loopback pair. + */ + interface Loopback + { + /// Disconnect and destroy the loopback elements + void disconnect (); + }; +}; diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.cpp new file mode 100644 index 00000000000..ded3aa19ae6 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.cpp @@ -0,0 +1,74 @@ +/** + * @file Implicit_Deactivator.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Implicit_Deactivator.h" +#include "tao/PortableServer/Servant_Base.h" +#include "tao/Environment.h" +#include "ace/Swap.h" + +#if !defined(__ACE_INLINE__) +#include "Implicit_Deactivator.inl" +#endif /* __ACE_INLINE__ */ + +Implicit_Deactivator::Implicit_Deactivator (PortableServer::Servant servant + ACE_ENV_ARG_DECL) +{ + this->poa_ = + servant->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->id_ = + this->poa_->servant_to_id (servant ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +Implicit_Deactivator::Implicit_Deactivator (Implicit_Deactivator &rhs) + : poa_ (rhs.poa_) + , id_ (rhs.id_) +{ + rhs.release (); +} + +Implicit_Deactivator& +Implicit_Deactivator::operator= (Implicit_Deactivator &rhs) +{ + Implicit_Deactivator tmp (rhs); + // @@ This seems bogus, there should be a more efficient way to swap + // vars + ACE_Swap::swap (this->poa_, tmp.poa_); + ACE_Swap::swap (this->id_, tmp.id_); + return *this; +} + +Implicit_Deactivator::~Implicit_Deactivator () +{ + if (this->id_.ptr () == 0) + return; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY { + this->poa_->deactivate_object (this->id_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY { + // @@ TODO This event should be logged. Cannot throw because that + // would make it impossible to use this class effectively. + // Read Servant_var.cpp for more details. + } ACE_ENDTRY; +} + +Implicit_Deactivator& +Implicit_Deactivator::operator= (PortableServer::Servant servant) +{ + Implicit_Deactivator tmp (servant); + // @@ This seems bogus, there should be a more efficient way to swap + // vars + ACE_Swap::swap (this->poa_, tmp.poa_); + ACE_Swap::swap (this->id_, tmp.id_); + return *this; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.h new file mode 100644 index 00000000000..d7140a3275c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.h @@ -0,0 +1,52 @@ +/** + * @file Implicit_Deactivator.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_IMPLICIT_DEACTIVATOR_H +#define TAO_PERF_RTEC_IMPLICIT_DEACTIVATOR_H + +#include "rtec_perf_export.h" +#include "tao/PortableServer/PortableServer.h" + +/** + * @class Implicit_Deactivator + * + * @brief Automatically deactivate an implicitly activated object. + */ +class TAO_RTEC_Perf_Export Implicit_Deactivator +{ +public: + /// Constructor + /** + * @param client The client + */ + explicit Implicit_Deactivator (PortableServer::Servant servant = 0 + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + Implicit_Deactivator (Implicit_Deactivator& rhs); + Implicit_Deactivator& operator= (Implicit_Deactivator& rhs); + + /// Destructor + ~Implicit_Deactivator (void); + + /// Assignment operator + Implicit_Deactivator& operator= (PortableServer::Servant servant); + + /// Release the servant, i.e. the destructor does not deactivate anything + void release (void); + +private: + /// The POA + PortableServer::POA_var poa_; + + /// The object id + PortableServer::ObjectId_var id_; +}; + +#if defined(__ACE_INLINE__) +#include "Implicit_Deactivator.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_IMPLICIT_DEACTIVATOR_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.inl new file mode 100644 index 00000000000..b220d7959e4 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Implicit_Deactivator.inl @@ -0,0 +1,13 @@ +/** + * @file Implicit_Deactivator.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE void +Implicit_Deactivator::release (void) +{ + this->id_ = 0; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.cpp new file mode 100644 index 00000000000..41c08b2a882 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.cpp @@ -0,0 +1,40 @@ +/** + * @file Loopback.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Loopback.h" +#include "Auto_Disconnect.h" +#include "Implicit_Deactivator.h" + +ACE_RCSID (TAO_RTEC_Perf, + Loopback, + "$Id$") + +Loopback::Loopback (CORBA::Long experiment_id, + CORBA::Long base_event_type, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->loopback_pair_.init (experiment_id, + base_event_type, + supplier_poa, + consumer_poa); + + this->loopback_pair_.connect (ec ACE_ENV_ARG_PARAMETER); +} + +void +Loopback::disconnect (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + Auto_Disconnect disconnect (&this->loopback_pair_); + + Implicit_Deactivator deactivator (this ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.h new file mode 100644 index 00000000000..384c42cd3cb --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback.h @@ -0,0 +1,47 @@ +/** + * @file Loopback.h + * + * $Id$ + * + */ + +#ifndef TAO_RTEC_PERF_LOOPBACK_H +#define TAO_RTEC_PERF_LOOPBACK_H + +#include "Federated_TestS.h" +#include "Loopback_Pair.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Loopback + * + * @brief Implement the Control::Loopback interface + * + */ +class TAO_RTEC_Perf_Export Loopback + : public virtual POA_Federated_Test::Loopback +{ +public: + /// Constructor + Loopback (CORBA::Long experiment_id, + CORBA::Long base_event_type, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa, + RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + //@{ + /** @name The Federated_Test::Loopback methods + */ + virtual void disconnect (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +private: + Loopback_Pair loopback_pair_; +}; + +#endif /* TAO_RTEC_PERF_LOOPBACK_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.cpp new file mode 100644 index 00000000000..2c3d1f8084e --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.cpp @@ -0,0 +1,116 @@ +/** + * @file Loopback_Consumer.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Loopback_Consumer.h" +#include "Implicit_Deactivator.h" +#include "orbsvcs/Event_Service_Constants.h" + +ACE_RCSID (PERF_RTEC, + Loopback_Consumer, + "$Id$") + +Loopback_Consumer:: +Loopback_Consumer (CORBA::Long experiment_id, + CORBA::Long event_type, + Loopback_Supplier *supplier, + PortableServer::POA_ptr poa) + : experiment_id_ (experiment_id) + , event_type_ (event_type) + , supplier_ (TAO::Utils::Servant_Var::_duplicate (supplier)) + , default_POA_ (PortableServer::POA::_duplicate (poa)) +{ +} + +void +Loopback_Consumer::connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = + ec->for_consumers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (!CORBA::is_nil (this->proxy_supplier_.in ())) + return; + + this->proxy_supplier_ = + consumer_admin->obtain_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + + RtecEventComm::PushConsumer_var consumer = + this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::ConsumerQOS consumer_qos; + consumer_qos.is_gateway = 0; + consumer_qos.dependencies.length (2); + RtecEventComm::EventHeader& h0 = + consumer_qos.dependencies[0].event.header; + h0.type = ACE_ES_DISJUNCTION_DESIGNATOR; + h0.source = 1; + + RtecEventComm::EventHeader& h1 = + consumer_qos.dependencies[1].event.header; + h1.source = this->experiment_id_; + h1.type = this->event_type_; + + this->proxy_supplier_->connect_push_consumer (consumer.in (), + consumer_qos + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +Loopback_Consumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + RtecEventChannelAdmin::ProxyPushSupplier_var proxy; + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (CORBA::is_nil (this->proxy_supplier_.in ())) + return; + proxy = this->proxy_supplier_._retn (); + } + + Implicit_Deactivator deactivator (this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + proxy->disconnect_push_supplier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY {} ACE_ENDTRY; +} + +void +Loopback_Consumer::push (const RtecEventComm::EventSet &events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Loopback_Consumer::push (%P|%t)\n")); + this->supplier_->push (events ACE_ENV_ARG_PARAMETER); +} + +void +Loopback_Consumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + this->proxy_supplier_ = + RtecEventChannelAdmin::ProxyPushSupplier::_nil (); +} + +PortableServer::POA_ptr +Loopback_Consumer::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.h new file mode 100644 index 00000000000..4ff3203146c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Consumer.h @@ -0,0 +1,76 @@ +/** + * @file Loopback_Consumer.h + * + * $Id$ + * + */ + +#ifndef TAO_PERF_RTEC_LOOPBACK_CONSUMER_H +#define TAO_PERF_RTEC_LOOPBACK_CONSUMER_H + +#include "Loopback_Supplier.h" +#include "tao/Utils/Servant_Var.h" +#include "orbsvcs/RtecEventCommS.h" +#include "orbsvcs/RtecEventChannelAdminC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Loopback_Consumer + * + * @brief Implement a simple consumer to keep track of the latency + * + */ +class TAO_RTEC_Perf_Export Loopback_Consumer + : public virtual POA_RtecEventComm::PushConsumer + +{ +public: + /// Constructor + Loopback_Consumer (CORBA::Long experiment_id, + CORBA::Long event_type, + Loopback_Supplier *supplier, + PortableServer::POA_ptr poa); + + /// Connect to the event channel + void connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + /// Disconnect from the event channel + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + //@{ + /** @name The RtecEventComm::PushConsumer methods + */ + virtual void push (const RtecEventComm::EventSet& events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +private: + /// Synchronize access to the internal data + TAO_SYNCH_MUTEX mutex_; + + /// The experiment id + CORBA::Long experiment_id_; + + /// The event type this consumer subscribes to + CORBA::Long event_type_; + + /// The supplier used to close the loopback + TAO::Utils::Servant_Var supplier_; + + /// The proxy this object is connected to + RtecEventChannelAdmin::ProxyPushSupplier_var proxy_supplier_; + + /// The default poa + PortableServer::POA_var default_POA_; +}; + +#endif /* ECFL_LOOPBACK_CONSUMER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.cpp new file mode 100644 index 00000000000..5a0c80aed0c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.cpp @@ -0,0 +1,56 @@ +/** + * @file Loopback_Pair.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Loopback_Pair.h" +#include "Auto_Disconnect.h" + +#if !defined(__ACE_INLINE__) +#include "Loopback_Pair.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + Loopback_Pair, + "$Id$") + +void +Loopback_Pair::init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa) +{ + this->loopback_supplier_ = new Loopback_Supplier (experiment_id, + base_event_type + 1, + supplier_poa); + this->loopback_consumer_ = new Loopback_Consumer (experiment_id, + base_event_type, + loopback_supplier_.in (), + consumer_poa); +} + +void +Loopback_Pair::connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + this->loopback_supplier_->connect (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + Auto_Disconnect loopback_supplier_disconnect (this->loopback_supplier_); + + this->loopback_consumer_->connect (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + Auto_Disconnect loopback_consumer_disconnect (this->loopback_consumer_); + + loopback_consumer_disconnect.release (); + loopback_supplier_disconnect.release (); +} + +void +Loopback_Pair::disconnect (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + Auto_Disconnect loopback_supplier_disconnect (this->loopback_supplier_); + Auto_Disconnect loopback_consumer_disconnect (this->loopback_consumer_); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.h new file mode 100644 index 00000000000..d70b8bfd9a4 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.h @@ -0,0 +1,79 @@ +/** + * @file Loopback_Pair.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_LOOPBACK_PAIR_H +#define TAO_PERF_RTEC_LOOPBACK_PAIR_H + +#include "Servant_var.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Loopback_Supplier.h" +#include "Loopback_Consumer.h" + +/** + * @class Loopback_Pair + * + * @brief Simplify the initialization of a Loopback connection through + * the event channel. + */ +class TAO_RTEC_Perf_Export Loopback_Pair +{ +public: + /// Constructor + /** + * We need a default constructor because this class is often used in + * arrays. + */ + Loopback_Pair (void); + + /** + * @param experiment_id For tests that run multiple experiments + * this number is changed on each iteration, guaranteeing + * better isolation. + * @param base_event_type The event type generated by the supplier. + * The Loopback_Consumer consumes the same event, the + * Loopback_Supplier generates (base_event_type + 1), and the + * consumer subscribes for that type too. + * @param iterations The number of iterations expected on the test. + * @param workload_in_usecs The consumer workload, in microseconds. + * @param gsf The high resolution timer global scale factor. + * + */ + void init (CORBA::Long experiment_id, + CORBA::Long base_event_type, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa); + + /// Connect to the event channel + void connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + /// Disconnect from the event channel + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + //@{ + /** @name Accessors + */ + Loopback_Supplier *loopback_supplier (void) const; + + Loopback_Consumer *loopback_consumer (void) const; + //@} + +private: + Servant_var loopback_supplier_; + Servant_var loopback_consumer_; +}; + +#if defined(__ACE_INLINE__) +#include "Loopback_Pair.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_LOOPBACK_PAIR_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.inl new file mode 100644 index 00000000000..64079dad6d5 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Pair.inl @@ -0,0 +1,24 @@ +/** + * @file Loopback_Pair.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE +Loopback_Pair::Loopback_Pair (void) +{ +} + +ACE_INLINE Loopback_Supplier * +Loopback_Pair::loopback_supplier (void) const +{ + return this->loopback_supplier_.in (); +} + +ACE_INLINE Loopback_Consumer * +Loopback_Pair::loopback_consumer (void) const +{ + return this->loopback_consumer_.in (); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.cpp new file mode 100644 index 00000000000..1e516958c44 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.cpp @@ -0,0 +1,134 @@ +/** + * @file Loopback_Supplier.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Loopback_Supplier.h" +#include "Implicit_Deactivator.h" + +ACE_RCSID (TAO_PERF_RTEC, + Loopback_Supplier, + "$Id$") + +Loopback_Supplier::Loopback_Supplier (CORBA::Long experiment_id, + CORBA::Long response_type, + PortableServer::POA_ptr poa) + : experiment_id_ (experiment_id) + , response_type_ (response_type) + , default_POA_ (PortableServer::POA::_duplicate (poa)) + , counter_ (0) +{ +} + +void +Loopback_Supplier::connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + RtecEventChannelAdmin::SupplierAdmin_var supplier_admin = + ec->for_suppliers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (!CORBA::is_nil (this->proxy_consumer_.in ())) + return; + + this->proxy_consumer_ = + supplier_admin->obtain_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + + RtecEventComm::PushSupplier_var supplier = + this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::SupplierQOS supplier_qos; + supplier_qos.is_gateway = 0; + supplier_qos.publications.length (1); + RtecEventComm::EventHeader& sh0 = + supplier_qos.publications[0].event.header; + sh0.type = this->response_type_; + sh0.source = this->experiment_id_; + + this->proxy_consumer_->connect_push_supplier (supplier.in (), + supplier_qos + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +Loopback_Supplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + RtecEventChannelAdmin::ProxyPushConsumer_var proxy; + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (CORBA::is_nil (this->proxy_consumer_.in ())) + return; + proxy = this->proxy_consumer_._retn (); + } + + Implicit_Deactivator deactivator (this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY { + proxy->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY { + } ACE_ENDTRY; +} + +void +Loopback_Supplier::push (const RtecEventComm::EventSet &source + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Loopback_Supplier pushing\n")); + RtecEventChannelAdmin::ProxyPushConsumer_var proxy; + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (CORBA::is_nil (this->proxy_consumer_.in ())) + return; + proxy = this->proxy_consumer_; + +#if 0 + this->counter_ += source.length (); + if ((this->counter_ + 1) % 1000 == 0) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) - Loopback (%d) sending %d messages\n", + this->response_type_, this->counter_ + 1)); + } +#endif /* 0 */ + } + + // ACE_DEBUG ((LM_DEBUG, "Loopback_Supplier::push (%P|%t)\n")); + RtecEventComm::EventSet events (source); + for (CORBA::ULong i = 0; i != events.length (); ++i) + { + events[i].header.ttl = 1; + events[i].header.type = this->response_type_; + events[i].header.source = this->experiment_id_; + } + + proxy->push (events ACE_ENV_ARG_PARAMETER); +} + +void +Loopback_Supplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + this->proxy_consumer_ = + RtecEventChannelAdmin::ProxyPushConsumer::_nil (); +} + +PortableServer::POA_ptr +Loopback_Supplier::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.h new file mode 100644 index 00000000000..24f2055cf04 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Loopback_Supplier.h @@ -0,0 +1,80 @@ +/** + * @file Loopback_Supplier.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_RTEC_LOOPBACK_SUPPLIER_H +#define TAO_RTEC_LOOPBACK_SUPPLIER_H + +#include "rtec_perf_export.h" +#include "orbsvcs/RtecEventCommS.h" +#include "orbsvcs/RtecEventChannelAdminC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Loopback_Supplier + * + * @brief Implement a simple supplier to keep track of the latency + * + */ +class TAO_RTEC_Perf_Export Loopback_Supplier + : public virtual POA_RtecEventComm::PushSupplier +{ +public: + /// Constructor + /** + * The experiment ID is used to configure the supplier ID on the + * publication. + */ + Loopback_Supplier (CORBA::Long experiment_id, + CORBA::Long response_type, + PortableServer::POA_ptr poa); + + /// Connect to the event channel + void connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + /// Disconnect from the event channel + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + void push (const RtecEventComm::EventSet &events + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + //@{ + /** @name The RtecEventComm::PushSupplier methods + */ + virtual void disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +private: + /// The experiment id + /// Synchronize access to the internal data + TAO_SYNCH_MUTEX mutex_; + + /// The experiment id + CORBA::Long experiment_id_; + + /// The response event type + CORBA::Long response_type_; + + /// The proxy this object is connected to + RtecEventChannelAdmin::ProxyPushConsumer_var proxy_consumer_; + + /// The default poa + PortableServer::POA_var default_POA_; + + /// Count the number of events processed + CORBA::ULong counter_; +}; + +#endif /* TAO_RTEC_LOOPBACK_SUPPLIER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.cpp new file mode 100644 index 00000000000..36154df9fcd --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.cpp @@ -0,0 +1,121 @@ +/** + * @file Low_Priority_Setup.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_LOW_PRIORITY_SETUP_CPP +#define TAO_PERF_RTEC_LOW_PRIORITY_SETUP_CPP + +#include "Low_Priority_Setup.h" + +#include "ace/Basic_Stats.h" +#include "ace/Sample_History.h" + +template Low_Priority_Setup:: +Low_Priority_Setup (int consumer_count, + int iterations, + int use_different_types, + CORBA::Long experiment_id, + CORBA::Long base_event_type, + int workload, + ACE_UINT32 gsf, + int nthreads, + int thread_priority, + int thread_sched_class, + int per_thread_period, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa, + RtecEventChannelAdmin::EventChannel_ptr ec, + ACE_Barrier *barrier + ACE_ENV_ARG_DECL) + : consumer_count_ (consumer_count) + , clients_ (consumer_count ? new Client_Type[consumer_count] : 0) + , disconnect_ (consumer_count ? new Client_Auto_Disconnect[consumer_count] : 0) + , nthreads_ (nthreads) + , tasks_ (nthreads ? new Send_Task[nthreads] : 0) + , stoppers_ (nthreads ? new Auto_Send_Task_Stopper[nthreads] : 0) +{ + for (int i = 0; i != consumer_count; ++i) + { + int per_consumer_workload = + workload / this->consumer_count_; + if (workload != 0 && per_consumer_workload == 0) + per_consumer_workload = 1; + + CORBA::Long event_type = + base_event_type; + if (use_different_types) + event_type = base_event_type + 2 * i; + + this->clients_[i].init (experiment_id, + event_type, + iterations, + per_consumer_workload, + gsf, + supplier_poa, + consumer_poa); + this->clients_[i].connect (ec + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + // Automatically disconnect the group if the connection was + // successful + this->disconnect_[i] = &this->clients_[i]; + } + + for (int j = 0; j != nthreads; ++j) + { + CORBA::Long event_type = + base_event_type; + if (use_different_types) + event_type = base_event_type + 2 * j; + + this->tasks_[j].init (0, + per_thread_period, + j * per_thread_period, + event_type, + experiment_id, + this->clients_[j].supplier (), + barrier); + this->tasks_[j].thr_mgr (&this->thr_mgr_); + ACE_AUTO_PTR_RESET (this->stoppers_[j], + new Send_Task_Stopper (thread_priority, + thread_sched_class, + &this->tasks_[j]), + Send_Task_Stopper); + } +} + +template void +Low_Priority_Setup::stop_all_threads (void) +{ + ACE_DEBUG ((LM_DEBUG, "Stopping:")); + for (int i = 0; i != this->nthreads_; ++i) + { + this->tasks_[i].stop (); + ACE_DEBUG ((LM_DEBUG, " %d", i)); + } + ACE_DEBUG ((LM_DEBUG, "\n")); + this->thr_mgr_.wait (); + + /// Resetting the auto_ptr<> destroys all the objects. The + /// destructors automatically stop and wait for all the threads. + /// Depending on your personal bias this is either "super neat" or + /// "a horrible kludge", IMHO is just good use of the language :-) + this->stoppers_.reset (0); +} + +template void +Low_Priority_Setup::collect_basic_stats (ACE_Basic_Stats &stats) +{ + for (int i = 0; i != this->consumer_count_; ++i) + { + ACE_Sample_History &history = + this->clients_[i].consumer ()->sample_history (); + history.collect_basic_stats (stats); + } +} + +#endif /* TAO_PERF_RTEC_LOW_PRIORITY_SETUP_CPP */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.h new file mode 100644 index 00000000000..e6f5315abd0 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.h @@ -0,0 +1,83 @@ +/** + * @file Low_Priority_Setup.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_LOW_PRIORITY_SETUP_H +#define TAO_PERF_RTEC_LOW_PRIORITY_SETUP_H + +#include "Auto_Disconnect.h" +#include "Send_Task.h" +#include "Send_Task_Stopper.h" +#include "ace/Auto_Ptr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class RT_Class; + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +class ACE_Basic_Stats; +ACE_END_VERSIONED_NAMESPACE_DECL + +/** + * @class Low_Priority_Setup + * + * @brief Simplify the initialization of performance tests clients + * + */ +template +class Low_Priority_Setup +{ +public: + /// Constructor + Low_Priority_Setup (int consumer_count, + int iterations, + int use_different_types, + CORBA::Long experiment_id, + CORBA::Long base_event_type, + int workload, + ACE_UINT32 gsf, + int nthreads, + int thread_priority, + int thread_sched_class, + int per_thread_period, + PortableServer::POA_ptr supplier_poa, + PortableServer::POA_ptr consumer_poa, + RtecEventChannelAdmin::EventChannel_ptr ec, + ACE_Barrier *barrier + ACE_ENV_ARG_DECL); + + /// Stop all running threads + void stop_all_threads (void); + + /// Collect the stats from all the clients + void collect_basic_stats (ACE_Basic_Stats &stats); + + typedef ACE_Auto_Basic_Array_Ptr Client_Array; + typedef Auto_Disconnect Client_Auto_Disconnect; + typedef ACE_Auto_Basic_Array_Ptr Client_Auto_Disconnect_Array; + typedef ACE_Auto_Basic_Array_Ptr Send_Task_Array; + typedef auto_ptr Auto_Send_Task_Stopper; + typedef ACE_Auto_Basic_Array_Ptr Send_Task_Stopper_Array; + +private: + int consumer_count_; + Client_Array clients_; + Client_Auto_Disconnect_Array disconnect_; + + int nthreads_; + Send_Task_Array tasks_; + Send_Task_Stopper_Array stoppers_; + ACE_Thread_Manager thr_mgr_; +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Low_Priority_Setup.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#endif /* TAO_PERF_RTEC_LOW_PRIORITY_SETUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.inl new file mode 100644 index 00000000000..e9f4cab94a8 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Low_Priority_Setup.inl @@ -0,0 +1,7 @@ +/** + * @file Low_Priority_Setup.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Makefile.am b/TAO/orbsvcs/performance-tests/RTEvent/lib/Makefile.am new file mode 100644 index 00000000000..cc8e9942d43 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Makefile.am @@ -0,0 +1,181 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf +TAO_ROOT = $(top_srcdir) + + +## Makefile.RTEC_Perf.am + +if BUILD_CORBA_MESSAGING +if BUILD_RT_CORBA +if !BUILD_ACE_FOR_TAO +if !BUILD_MINIMUM_CORBA + +BUILT_SOURCES = \ + Federated_TestC.cpp \ + Federated_TestC.h \ + Federated_TestC.inl \ + Federated_TestS.cpp \ + Federated_TestS.h \ + Federated_TestS.inl \ + Federated_TestS_T.cpp \ + Federated_TestS_T.h \ + Federated_TestS_T.inl + +CLEANFILES = \ + Federated_Test-stamp \ + Federated_TestC.cpp \ + Federated_TestC.h \ + Federated_TestC.inl \ + Federated_TestS.cpp \ + Federated_TestS.h \ + Federated_TestS.inl \ + Federated_TestS_T.cpp \ + Federated_TestS_T.h \ + Federated_TestS_T.inl + +Federated_TestC.cpp Federated_TestC.h Federated_TestC.inl Federated_TestS.cpp Federated_TestS.h Federated_TestS.inl Federated_TestS_T.cpp Federated_TestS_T.h Federated_TestS_T.inl: Federated_Test-stamp + +Federated_Test-stamp: $(srcdir)/Federated_Test.idl $(TAO_IDL_DEP) + $(TAO_IDL) $(TAO_IDLFLAGS) -I$(TAO_ROOT)/orbsvcs -GT -Wb,export_macro=TAO_RTEC_Perf_Export -Wb,export_include=rtec_perf_export.h $(srcdir)/Federated_Test.idl + @touch $@ + +noinst_LTLIBRARIES = libTAO_RTEC_Perf.la + +libTAO_RTEC_Perf_la_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(TAO_ROOT)/orbsvcs \ + -I$(TAO_BUILDDIR)/orbsvcs \ + -DTAO_RTEC_PERF_BUILD_DLL + +libTAO_RTEC_Perf_la_SOURCES = \ + Client_Group.cpp \ + Client_Options.cpp \ + Client_Pair.cpp \ + Consumer.cpp \ + Control.cpp \ + EC_Destroyer.cpp \ + Federated_TestC.cpp \ + Federated_TestS.cpp \ + Implicit_Deactivator.cpp \ + Loopback.cpp \ + Loopback_Consumer.cpp \ + Loopback_Pair.cpp \ + Loopback_Supplier.cpp \ + ORB_Holder.cpp \ + ORB_Shutdown.cpp \ + ORB_Task.cpp \ + ORB_Task_Activator.cpp \ + Peer_Base.cpp \ + PriorityBand_Setup.cpp \ + RTCORBA_Setup.cpp \ + RTClient_Setup.cpp \ + RTEC_Initializer.cpp \ + RTPOA_Setup.cpp \ + RTServer_Setup.cpp \ + RT_Class.cpp \ + Send_Task.cpp \ + Send_Task_Stopper.cpp \ + Supplier.cpp \ + SyncScope_Setup.cpp + +noinst_HEADERS = \ + Auto_Disconnect.cpp \ + Auto_Disconnect.h \ + Auto_Disconnect.inl \ + Client_Group.h \ + Client_Group.inl \ + Client_Options.h \ + Client_Pair.h \ + Client_Pair.inl \ + Consumer.h \ + Control.h \ + EC_Destroyer.h \ + EC_Destroyer.inl \ + Federated_Test.idl \ + Federated_TestC.h \ + Federated_TestC.inl \ + Federated_TestS.h \ + Federated_TestS.inl \ + Federated_TestS_T.cpp \ + Federated_TestS_T.h \ + Federated_TestS_T.inl \ + Implicit_Deactivator.h \ + Implicit_Deactivator.inl \ + Loopback.h \ + Loopback_Consumer.h \ + Loopback_Pair.h \ + Loopback_Pair.inl \ + Loopback_Supplier.h \ + Low_Priority_Setup.cpp \ + Low_Priority_Setup.h \ + Low_Priority_Setup.inl \ + ORB_Holder.h \ + ORB_Holder.inl \ + ORB_Shutdown.h \ + ORB_Shutdown.inl \ + ORB_Task.h \ + ORB_Task.inl \ + ORB_Task_Activator.h \ + ORB_Task_Activator.inl \ + Peer_Base.h \ + PriorityBand_Setup.h \ + PriorityBand_Setup.inl \ + RIR_Narrow.cpp \ + RIR_Narrow.h \ + RTCORBA_Setup.h \ + RTCORBA_Setup.inl \ + RTClient_Setup.h \ + RTClient_Setup.inl \ + RTEC_Initializer.h \ + RTPOA_Setup.h \ + RTPOA_Setup.inl \ + RTServer_Setup.h \ + RTServer_Setup.inl \ + RT_Class.h \ + RT_Class.inl \ + Send_Task.h \ + Send_Task_Stopper.h \ + Send_Task_Stopper.inl \ + Servant_var.cpp \ + Servant_var.h \ + Servant_var.inl \ + Shutdown.cpp \ + Shutdown.h \ + Shutdown.inl \ + Supplier.h \ + SyncScope_Setup.h \ + SyncScope_Setup.inl \ + Task_Activator.cpp \ + Task_Activator.h \ + Task_Activator.inl \ + rtec_perf_export.h + +endif !BUILD_MINIMUM_CORBA +endif !BUILD_ACE_FOR_TAO +endif BUILD_RT_CORBA +endif BUILD_CORBA_MESSAGING + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.cpp new file mode 100644 index 00000000000..a2ee9263b1f --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.cpp @@ -0,0 +1,37 @@ +/** + * @file ORB_Holder.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "ORB_Holder.h" + +#if !defined(__ACE_INLINE__) +#include "ORB_Holder.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + ORB_Holder, + "$Id$") + +ORB_Holder::ORB_Holder (int &argc, char *argv[], + const char *orb_id + ACE_ENV_ARG_DECL) + : orb_ (CORBA::ORB_init (argc, argv, orb_id + ACE_ENV_ARG_PARAMETER)) +{ +} + +ORB_Holder::~ORB_Holder (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY { + this->orb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCH (CORBA::Exception, ex) { + // @@ TODO Log this event, check the Servant_var.cpp comments for + // details. + } ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.h new file mode 100644 index 00000000000..a600f780980 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.h @@ -0,0 +1,62 @@ +/** + * @file ORB_Holder.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_ORB_HOLDER_H +#define TAO_PERF_RTEC_ORB_HOLDER_H + +#include "rtec_perf_export.h" +#include "tao/ORB.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class ORB_Holder + * + * @brief Implement a helper class to initialize and destroy an ORB. + * + */ +class TAO_RTEC_Perf_Export ORB_Holder +{ +public: + /// Constructor + ORB_Holder (int &argc, char *argv[], + const char *orb_id = 0 + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// Destructor + /** + * @todo This method could benefit from the error logging described + * in Servant_var.cpp + */ + ~ORB_Holder (void); + + /// Access the underlying ORB, using the canonical CORBA memory + /// management model + CORBA::ORB_ptr orb (void); + + /// Implicit conversion to CORBA::ORB_ptr + /** + * It behaves as the .in() methods in the T_var classes. + */ + operator CORBA::ORB_ptr () const; + + /// Smart pointer behavior + CORBA::ORB_ptr operator-> () const; + +private: + /// The ORB + CORBA::ORB_var orb_; +}; + +#if defined(__ACE_INLINE__) +#include "ORB_Holder.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_ORB_HOLDER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.inl new file mode 100644 index 00000000000..60900f61610 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Holder.inl @@ -0,0 +1,25 @@ +/** + * @file ORB_Holder.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE CORBA::ORB_ptr +ORB_Holder::orb (void) +{ + return CORBA::ORB::_duplicate (this->orb_.in ()); +} + +ACE_INLINE +ORB_Holder::operator CORBA::ORB_ptr (void) const +{ + return this->orb_.in (); +} + +ACE_INLINE CORBA::ORB_ptr +ORB_Holder::operator-> (void) const +{ + return this->orb_.in (); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.cpp new file mode 100644 index 00000000000..2071b0a718e --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.cpp @@ -0,0 +1,16 @@ +/** + * @file ORB_Shutdown.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#include "ORB_Shutdown.h" + +#if !defined(__ACE_INLINE__) +#include "ORB_Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + ORB_Shutdown, + "$Id$") diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.h new file mode 100644 index 00000000000..4e26067d2a4 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.h @@ -0,0 +1,31 @@ +/** + * @file ORB_Shutdown.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_ORB_SHUTDOWN_H +#define TAO_PERF_RTEC_ORB_SHUTDOWN_H +#include /**/ "ace/pre.h" + +#include "rtec_perf_export.h" +#include "tao/ORB.h" + +/** + * @class ORB_Shutdown + * + * @brief Helper functor to call the shutdown() operation in the ORB. + */ +class ORB_Shutdown +{ +public: + void operator() (CORBA::ORB_ptr orb); +}; + +#if defined(__ACE_INLINE__) +#include "ORB_Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* TAO_PERF_RTEC_ORB_SHUTDOWN_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.inl new file mode 100644 index 00000000000..13fbb623600 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Shutdown.inl @@ -0,0 +1,23 @@ +// -*- C++ -*- + +/** + * @file ORB_Shutdown.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE void +ORB_Shutdown::operator () (CORBA::ORB_ptr orb) +{ + ACE_DECLARE_NEW_ENV; + ACE_TRY + { + orb->shutdown (0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY { }; + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.cpp new file mode 100644 index 00000000000..369d7f358fa --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.cpp @@ -0,0 +1,39 @@ +/** + * @file ORB_Task.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "ORB_Task.h" + +#if !defined(__ACE_INLINE__) +#include "ORB_Task.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + ORB_Task, + "$Id$") + +ORB_Task::ORB_Task (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +int +ORB_Task::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + return 0; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.h new file mode 100644 index 00000000000..28240439233 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.h @@ -0,0 +1,46 @@ +/** + * @file ORB_Task.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_ORB_TASK_H +#define TAO_PERF_RTEC_ORB_TASK_H + +#include "rtec_perf_export.h" +#include "tao/ORB.h" +#include "ace/Task.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class ORB_Task + * + * @brief Implement a simple ACE_Task to send the events + * + */ +class TAO_RTEC_Perf_Export ORB_Task : public ACE_Task_Base +{ +public: + /// Constructor + ORB_Task (CORBA::ORB_ptr orb); + + /// Run the event loop + int svc (void); + + /// Smart-pointer operator + CORBA::ORB_ptr operator-> (void) const; + +private: + CORBA::ORB_var orb_; +}; + +#if defined(__ACE_INLINE__) +#include "ORB_Task.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_ORB_TASK_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.inl new file mode 100644 index 00000000000..66344be0f08 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task.inl @@ -0,0 +1,13 @@ +/** + * @file ORB_Task.inl + * +` * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE CORBA::ORB_ptr +ORB_Task::operator-> (void) const +{ + return this->orb_.in (); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.cpp new file mode 100644 index 00000000000..42bc3fb5676 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.cpp @@ -0,0 +1,29 @@ +/** + * @file ORB_Task_Activator.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "ORB_Task_Activator.h" + +#if !defined(__ACE_INLINE__) +#include "ORB_Task_Activator.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + ORB_Task_Activator, + "$Id$") + +ORB_Task_Activator::~ORB_Task_Activator (void) +{ + if (this->task_ == 0) + return; + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY { + (*this->task_)->shutdown (0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY { + } ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.h new file mode 100644 index 00000000000..1a81ca995cc --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.h @@ -0,0 +1,42 @@ +/** + * @file ORB_Task_Activator.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_ORB_TASK_ACTIVATOR_H +#define TAO_PERF_RTEC_ORB_TASK_ACTIVATOR_H + +#include "ORB_Task.h" +#include "Task_Activator.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class ORB_Task_Activator + * + * @brief Implement a helper class to activate and stop Send_Tasks. + * + */ +class TAO_RTEC_Perf_Export ORB_Task_Activator : public Task_Activator +{ +public: + /// Constructor + ORB_Task_Activator (int priority, + int scheduling_class, + int nthreads, + ORB_Task *task); + + /// Destructor, stop the task and wait for it + ~ORB_Task_Activator (void); +}; + +#if defined(__ACE_INLINE__) +#include "ORB_Task_Activator.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_ORB_TASK_ACTIVATOR_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.inl new file mode 100644 index 00000000000..ac24f29094c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/ORB_Task_Activator.inl @@ -0,0 +1,19 @@ +/** + * @file ORB_Task_Activator.inl + * +` * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE +ORB_Task_Activator::ORB_Task_Activator (int priority, + int scheduling_class, + int nthreads, + ORB_Task *task) + : Task_Activator (priority, + scheduling_class, + nthreads, + task) +{ +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.cpp new file mode 100644 index 00000000000..2b0a05a1eee --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.cpp @@ -0,0 +1,145 @@ +/** + * @file Peer_Base.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Peer_Base.h" +#include "RTServer_Setup.h" +#include "RIR_Narrow.h" +#include "Servant_var.h" +#include "RTEC_Initializer.h" +#include "EC_Destroyer.h" +#include "Auto_Disconnect.h" +#include "Loopback.h" + +#include "orbsvcs/Event/EC_Event_Channel.h" +#include "orbsvcs/Event/EC_Gateway_IIOP.h" + +ACE_RCSID (TAO_RTEC_Perf, + Peer_Base, + "$Id$") + +Peer_Base::Peer_Base (CORBA::ORB_ptr orb, + RTServer_Setup &rtserver_setup + ACE_ENV_ARG_DECL) + : orb_ (CORBA::ORB::_duplicate (orb)) + , poa_ (rtserver_setup.poa ()) +{ + Servant_var ec_impl ( + RTEC_Initializer::create (this->poa_.in (), + this->poa_.in (), + rtserver_setup.rtcorba_setup () + ACE_ENV_ARG_PARAMETER) + ); + ACE_CHECK; + + ec_impl->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + PortableServer::ObjectId_var ec_id = + this->poa_->activate_object (ec_impl.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + CORBA::Object_var ec_object = + this->poa_->id_to_reference (ec_id.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_channel_ = + RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +Peer_Base::~Peer_Base (void) +{ +} + +void +Peer_Base::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + { + EC_Destroyer ec_destroyer (this->event_channel_.in ()); + this->event_channel_ = + RtecEventChannelAdmin::EventChannel::_nil (); + } + + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); +} + +CORBA::Object_ptr +Peer_Base::channel (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::Object::_duplicate (this->event_channel_.in ()); +} + +void +Peer_Base::connect (Federated_Test::Peer_ptr remote_peer + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Connecting....\n")); + CORBA::Object_var remote_ec_object = + remote_peer->channel (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::EventChannel_var remote_ec = + RtecEventChannelAdmin::EventChannel::_narrow (remote_ec_object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + Servant_var gateway (new TAO_EC_Gateway_IIOP); + gateway->init (remote_ec.in (), + this->event_channel_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::Observer_var observer = + gateway->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::Observer_Handle h = + this->event_channel_->append_observer (observer.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + gateway->observer_handle (h); +} + +Federated_Test::Loopback_ptr +Peer_Base::setup_loopback (CORBA::Long experiment_id, + CORBA::Long base_event_type + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + Servant_var loopback ( + new Loopback (experiment_id, + base_event_type, + this->poa_.in (), + this->poa_.in (), + this->event_channel_.in () + ACE_ENV_ARG_PARAMETER)); + ACE_CHECK_RETURN (Federated_Test::Loopback::_nil ()); + + Auto_Disconnect disconnect (loopback); + + Federated_Test::Loopback_var lb = + loopback->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (Federated_Test::Loopback::_nil ()); + + disconnect.release (); + + return lb._retn (); +} + +PortableServer::POA_ptr +Peer_Base::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.h new file mode 100644 index 00000000000..948ef5b20a1 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Peer_Base.h @@ -0,0 +1,76 @@ +/** + * @file Peer_Base.h + * + * $Id$ + * + * @author Carlos O'Ryan + * + */ + +#ifndef TAO_RTEC_PERF_PEER_BASE_H +#define TAO_RTEC_PERF_PEER_BASE_H + +#include "Federated_TestS.h" +#include "orbsvcs/RtecEventChannelAdminC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class RTServer_Setup; + +/** + * @class Peer_Base + * + * @brief Implement the shared portions of Federated_Test::Peer + * servants + * + */ +class TAO_RTEC_Perf_Export Peer_Base + : public virtual POA_Federated_Test::Peer +{ +public: + /// Constructor + Peer_Base (CORBA::ORB_ptr orb, + RTServer_Setup &rtserver_setup + ACE_ENV_ARG_DECL); + + /// Destructor + virtual ~Peer_Base (void); + + //@{ + /** @name The Federated_Test::Peer methods + */ + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Object_ptr + channel (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void connect (Federated_Test::Peer_ptr remote_peer + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + Federated_Test::Loopback_ptr setup_loopback (CORBA::Long experiment_id, + CORBA::Long base_event_type + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +protected: + /// Keep a reference to the ORB, used in shutdown + CORBA::ORB_var orb_; + + /// The POA used for the suppliers, consumers, activate the EC and + /// as this servant's _default_POA() + PortableServer::POA_var poa_; + + /// Event Channel references + RtecEventChannelAdmin::EventChannel_var event_channel_; +}; + +#endif /* TAO_RTEC_PERF_PEER_BASE_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.cpp new file mode 100644 index 00000000000..bbb980bde7b --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.cpp @@ -0,0 +1,63 @@ +/** + * @file PriorityBand_Setup.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "PriorityBand_Setup.h" +#include "RTCORBA_Setup.h" +#include "RIR_Narrow.h" + +#if !defined(__ACE_INLINE__) +#include "PriorityBand_Setup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + PriorityBand_Setup, + "$Id$") + +PriorityBand_Setup::PriorityBand_Setup (CORBA::ORB_ptr orb, + const RTCORBA_Setup &rtcorba_setup + ACE_ENV_ARG_DECL) +{ + CORBA::PolicyManager_var policy_manager = + RIR_Narrow::resolve (orb, + "ORBPolicyManager" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + RTCORBA::RTORB_var rtorb = + RIR_Narrow::resolve (orb, + "RTORB" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + const RTCORBA::ThreadpoolLanes &lanes = rtcorba_setup.lanes (); + + RTCORBA::PriorityBands priority_bands (3); priority_bands.length (3); + for (CORBA::ULong i = 0; i != lanes.length (); ++i) + { + priority_bands[i].low = lanes[i].lane_priority; + priority_bands[i].high = lanes[i].lane_priority; + } + + CORBA::PolicyList policy_list (1); policy_list.length (1); + + policy_list[0] = + rtorb->create_priority_banded_connection_policy (priority_bands + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + policy_manager->set_policy_overrides (policy_list, + CORBA::ADD_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +PriorityBand_Setup::~PriorityBand_Setup (void) +{ +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.h new file mode 100644 index 00000000000..33cebd601cf --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.h @@ -0,0 +1,46 @@ +/** + * @file PriorityBand_Setup.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_PRIORITYBAND_SETUP_H +#define TAO_PERF_RTEC_PRIORITYBAND_SETUP_H + +#include "rtec_perf_export.h" +#include "tao/ORB.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class RTCORBA_Setup; + +/** + * @class PriorityBand_Setup + * + * @brief Simplify the initialization of performance tests. + * + */ +class TAO_RTEC_Perf_Export PriorityBand_Setup +{ +public: + /// Constructor + PriorityBand_Setup (CORBA::ORB_ptr orb, + const RTCORBA_Setup &rtcorba_setup + ACE_ENV_ARG_DECL); + + /// Destructor + /** + * It is a no-op, but it shuts up g++ + */ + ~PriorityBand_Setup (void); +}; + +#if defined(__ACE_INLINE__) +#include "PriorityBand_Setup.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_PRIORITYBAND_SETUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.inl new file mode 100644 index 00000000000..c9ee6e6c756 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/PriorityBand_Setup.inl @@ -0,0 +1,8 @@ +/** + * @file PriorityBand_Setup.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.cpp new file mode 100644 index 00000000000..ba719129de4 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.cpp @@ -0,0 +1,49 @@ +/** + * @file RIR_Narrow.cpp + * + * $Id$ + * + * @author Jody Hagins + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_RIR_NARROW_CPP +#define TAO_PERF_RTEC_RIR_NARROW_CPP + +#include "RIR_Narrow.h" + +#include "tao/Environment.h" + +#include "ace/Log_Msg.h" + +template ACE_TYPENAME RIR_Narrow::Interface_ptr +RIR_Narrow::resolve (CORBA::ORB_ptr orb, + const char *object_id + ACE_ENV_ARG_DECL) +{ + Interface_var interface; + + ACE_TRY + { + CORBA::Object_var object = + orb->resolve_initial_references (object_id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + interface = Interface::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (interface.in ())) + { + ACE_ERROR ((LM_ERROR, + "Panic - error while narrowing <%s>\n", + object_id)); + ACE_OS::exit (1); + } + }ACE_CATCHANY{ + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Caught an exception \n"); + } + ACE_ENDTRY; + return interface._retn (); +} + +#endif /* TAO_PERF_RTEC_RIR_NARROW_CPP */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.h new file mode 100644 index 00000000000..3cb61f27724 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RIR_Narrow.h @@ -0,0 +1,39 @@ +/** + * @file RIR_Narrow.h + * + * $Id$ + * + * @author Jody Hagins + * @author Carlos O'Ryan + * + */ +#ifndef TAO_PERF_RTEC_RIR_NARROW_H +#define TAO_PERF_RTEC_RIR_NARROW_H + +#include "tao/ORB.h" +#include "tao/Object.h" + +/** + * @class RIR_Narrow + * + * @brief Implement a helper method to narrow the results from + * resolve_initial_references. + * + */ +template +class RIR_Narrow +{ +public: + typedef ACE_TYPENAME Interface::_ptr_type Interface_ptr; + typedef ACE_TYPENAME Interface::_var_type Interface_var; + + static Interface_ptr resolve (CORBA::ORB_ptr orb, + const char *object_id + ACE_ENV_ARG_DECL); +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "RIR_Narrow.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#endif /* TAO_PERF_RTEC_RIR_NARROW_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.cpp new file mode 100644 index 00000000000..b5c6d99ae37 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.cpp @@ -0,0 +1,82 @@ +/** + * @file RTCORBA_Setup.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "RTCORBA_Setup.h" +#include "RIR_Narrow.h" +#include "RT_Class.h" + +#include "ace/Log_Msg.h" + +#if !defined(__ACE_INLINE__) +#include "RTCORBA_Setup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + RTCORBA_Setup, + "$Id$") + +RTCORBA_Setup::RTCORBA_Setup (CORBA::ORB_ptr orb, + const RT_Class &rtclass, + int nthreads + ACE_ENV_ARG_DECL) + : lanes_ (3) +{ + this->priority_mapping_manager_ = + RIR_Narrow::resolve (orb, + "PriorityMappingManager" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->priority_mapping_ = + this->priority_mapping_manager_->mapping (); + + RTCORBA::Current_var current = + RIR_Narrow::resolve (orb, + "RTCurrent" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + RTCORBA::Priority corba_prc_priority; + this->priority_mapping_->to_CORBA (rtclass.priority_process (), + corba_prc_priority); + + current->the_priority (corba_prc_priority + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->lanes_.length (3); + + this->setup_lane (rtclass.priority_high (), + this->lanes_[0] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->setup_lane (rtclass.priority_process (), + this->lanes_[1] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->setup_lane (rtclass.priority_low (), + this->lanes_[2] + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->lanes_[2].static_threads = nthreads; + + this->process_priority_ = this->lanes_[1].lane_priority; +} + +void +RTCORBA_Setup::setup_lane (int priority, + RTCORBA::ThreadpoolLane &lane + ACE_ENV_ARG_DECL) +{ + if (!this->priority_mapping_->to_CORBA (priority, + lane.lane_priority)) + ACE_THROW (CORBA::BAD_PARAM ()); + + lane.static_threads = 1; + lane.dynamic_threads = 0; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.h new file mode 100644 index 00000000000..96f7c487daf --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.h @@ -0,0 +1,63 @@ +/** + * @file RTCORBA_Setup.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_RTCORBA_SETUP_H +#define TAO_PERF_RTEC_RTCORBA_SETUP_H + +#include "rtec_perf_export.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "tao/RTCORBA/Priority_Mapping_Manager.h" +#include "ace/Auto_Ptr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class RT_Class; + +/** + * @class RTCORBA_Setup + * + * @brief Simplify the initialization of performance tests. + * + */ +class TAO_RTEC_Perf_Export RTCORBA_Setup +{ +public: + /// Constructor + RTCORBA_Setup (CORBA::ORB_ptr orb, + const RT_Class &rtclass, + int nthreads + ACE_ENV_ARG_DECL); + + /// Return the thread pool lanes appropriate for the benchamrks + const RTCORBA::ThreadpoolLanes & lanes (void) const; + + /// Return the priority of the process + RTCORBA::Priority process_priority (void) const; + +private: + void setup_lane (int priority, RTCORBA::ThreadpoolLane &lane + ACE_ENV_ARG_DECL_WITH_DEFAULTS ); + +private: + RTCORBA::PriorityMappingManager_var priority_mapping_manager_; + + RTCORBA::ThreadpoolLanes lanes_; + + RTCORBA::Priority process_priority_; + + /// Just a plain pointer, the ORB owns the memory... + RTCORBA::PriorityMapping *priority_mapping_; +}; + +#if defined(__ACE_INLINE__) +#include "RTCORBA_Setup.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_RTCORBA_SETUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.inl new file mode 100644 index 00000000000..e63b68593e3 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTCORBA_Setup.inl @@ -0,0 +1,19 @@ +/** + * @file RTCORBA_Setup.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE const RTCORBA::ThreadpoolLanes & +RTCORBA_Setup::lanes (void) const +{ + return this->lanes_; +} + +ACE_INLINE RTCORBA::Priority +RTCORBA_Setup::process_priority (void) const +{ + return this->process_priority_; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.cpp new file mode 100644 index 00000000000..6e3d06125f6 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.cpp @@ -0,0 +1,55 @@ +/** + * @file RTClient_Setup.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "RTClient_Setup.h" +#include "RIR_Narrow.h" +#include "tao/RTCORBA/RTCORBA.h" + +#include "ace/Log_Msg.h" + +#if !defined(__ACE_INLINE__) +#include "RTClient_Setup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + RTClient_Setup, + "$Id$") + +RTClient_Setup::RTClient_Setup (int use_rt_corba, + CORBA::ORB_ptr orb, + const RT_Class &rt_class, + int nthreads + ACE_ENV_ARG_DECL) + : use_rt_corba_ (use_rt_corba) + , syncscope_setup_ (orb ACE_ENV_ARG_PARAMETER) +{ + ACE_CHECK; + + if (use_rt_corba) + { + ACE_AUTO_PTR_RESET (this->rtcorba_setup_, + new RTCORBA_Setup (orb, + rt_class, + nthreads + ACE_ENV_ARG_PARAMETER), + RTCORBA_Setup + ); + ACE_CHECK; + +#if 0 + ACE_AUTO_PTR_RESET (this->priorityband_setup_, + new PriorityBand_Setup (orb, + *this->rtcorba_setup_ + ACE_ENV_ARG_PARAMETER), + PriorityBand_Setup + ); + ACE_CHECK; + +#endif /* 0 */ + } +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.h new file mode 100644 index 00000000000..8bea1503961 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.h @@ -0,0 +1,59 @@ +/** + * @file RTClient_Setup.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_RTCLIENT_SETUP_H +#define TAO_PERF_RTEC_RTCLIENT_SETUP_H +#include /**/ "ace/pre.h" + +#include "RTCORBA_Setup.h" +#include "PriorityBand_Setup.h" +#include "SyncScope_Setup.h" +#include "ace/Auto_Ptr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class RT_Class; + +/** + * @class RTClient_Setup + * + * @brief Simplify the initialization of performance tests. + * + */ +class TAO_RTEC_Perf_Export RTClient_Setup +{ +public: + /// Constructor + RTClient_Setup (int use_rt_corba, + CORBA::ORB_ptr orb, + const RT_Class &rt_class, + int nthreads + ACE_ENV_ARG_DECL); + + /// Return non-zero if RTCORBA is enabled + int use_rt_corba (void) const; + + /// Return the underlying RTCORBA_Setup pointer + RTCORBA_Setup *rtcorba_setup (void); + +private: + int use_rt_corba_; + + auto_ptr rtcorba_setup_; + auto_ptr priorityband_setup_; + SyncScope_Setup syncscope_setup_; +}; + +#if defined(__ACE_INLINE__) +#include "RTClient_Setup.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* TAO_PERF_RTEC_RTCLIENT_SETUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.inl new file mode 100644 index 00000000000..7e7eebf1254 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTClient_Setup.inl @@ -0,0 +1,19 @@ +/** + * @file RTClient_Setup.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE int +RTClient_Setup::use_rt_corba (void) const +{ + return this->use_rt_corba_; +} + +ACE_INLINE RTCORBA_Setup * +RTClient_Setup::rtcorba_setup (void) +{ + return this->rtcorba_setup_.get (); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.cpp new file mode 100644 index 00000000000..408b52b3557 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.cpp @@ -0,0 +1,47 @@ +/** + * @file RTEC_Initializer.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "RTEC_Initializer.h" +#include "RTCORBA_Setup.h" + +#include "orbsvcs/Event/EC_Event_Channel.h" +#include "orbsvcs/Event/EC_Default_Factory.h" +#include "orbsvcs/Event/EC_RTCORBA_Factory.h" + +#include "ace/Dynamic_Service.h" + +ACE_RCSID (TAO_PERF_RTEC, + RTEC_Initializer, + "$Id$") + +TAO_EC_Event_Channel * +RTEC_Initializer::create (PortableServer::POA_ptr consumer_poa, + PortableServer::POA_ptr supplier_poa, + RTCORBA_Setup * rtcorba_setup + ACE_ENV_ARG_DECL_NOT_USED) +{ + TAO_EC_Event_Channel_Attributes attr (consumer_poa, + supplier_poa); + + if (rtcorba_setup == 0) + { + return new TAO_EC_Event_Channel (attr); + } + + TAO_EC_Factory *body = + ACE_Dynamic_Service::instance ("EC_Factory"); + auto_ptr factory ( + new TAO_EC_RTCORBA_Factory (body, + rtcorba_setup->lanes ())); + + TAO_EC_Event_Channel *ec = + new TAO_EC_Event_Channel (attr, factory.get (), 1); + factory.release (); + + return ec; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.h new file mode 100644 index 00000000000..64645bcbf18 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Initializer.h @@ -0,0 +1,44 @@ +/** + * @file RTEC_Initializer.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_RTEC_INITIALIZER_H +#define TAO_PERF_RTEC_RTEC_INITIALIZER_H + +#include "rtec_perf_export.h" +#include "tao/ORB.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "tao/PortableServer/PortableServer.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL +class TAO_EC_Event_Channel; +TAO_END_VERSIONED_NAMESPACE_DECL + +class RTCORBA_Setup; + +/** + * @class RTEC_Initializer + * + * @brief Implement a helper method to initialize and instance of + * TAO's Real-time Event Service + * + */ +class TAO_RTEC_Perf_Export RTEC_Initializer +{ +public: + /// Return a new event channel + static TAO_EC_Event_Channel *create (PortableServer::POA_ptr consumer_poa, + PortableServer::POA_ptr supplier_poa, + RTCORBA_Setup *rtcorba_setup + ACE_ENV_ARG_DECL); +}; + +#endif /* TAO_PERF_RTEC_RTEC_INITIALIZER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Perf.mpc b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Perf.mpc new file mode 100644 index 00000000000..c73d8a6a356 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTEC_Perf.mpc @@ -0,0 +1,16 @@ +// $Id$ + +project(RTEC_Perf): strategies, rtcorbaevent, minimum_corba { + sharedname = TAO_RTEC_Perf + idlflags += -Wb,export_macro=TAO_RTEC_Perf_Export -Wb,export_include=rtec_perf_export.h + dynamicflags += TAO_RTEC_PERF_BUILD_DLL + + Template_Files { + Auto_Disconnect.cpp + Low_Priority_Setup.cpp + RIR_Narrow.cpp + Servant_var.cpp + Shutdown.cpp + Task_Activator.cpp + } +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.cpp new file mode 100644 index 00000000000..fdaaee06d30 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.cpp @@ -0,0 +1,100 @@ +/** + * @file RTPOA_Setup.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "RTPOA_Setup.h" +#include "RIR_Narrow.h" +#include "RTCORBA_Setup.h" +#include "tao/RTCORBA/RTCORBA.h" + +#include "ace/Log_Msg.h" + +#if !defined(__ACE_INLINE__) +#include "RTPOA_Setup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + RTPOA_Setup, + "$Id$") + +RTPOA_Setup::RTPOA_Setup (CORBA::ORB_ptr orb, + const RTCORBA_Setup &rtcorba_setup + ACE_ENV_ARG_DECL) +{ + RTPortableServer::POA_var root_poa = + RIR_Narrow::resolve (orb, + "RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + RTCORBA::RTORB_var rtorb = + RIR_Narrow::resolve (orb, + "RTORB" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + const CORBA::ULong stacksize = 1024 * 1024; // 1 Mb + const RTCORBA::ThreadpoolLanes &lanes = rtcorba_setup.lanes (); + const CORBA::Boolean allow_borrowing = 0; + const CORBA::Boolean allow_request_buffering = 0; + const CORBA::ULong max_buffered_requests = 0; // dummy value + const CORBA::ULong max_request_buffer_size = 0; // dummy value + + RTCORBA::ThreadpoolId pool_id = + rtorb->create_threadpool_with_lanes (stacksize, + lanes, + allow_borrowing, + allow_request_buffering, + max_buffered_requests, + max_request_buffer_size + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // @@ We need an 'auto_ptr for thread pools' here! + CORBA::PolicyList policies (4); policies.length (4); + policies[0] = + rtorb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, + rtcorba_setup.process_priority () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policies[1] = + root_poa->create_id_assignment_policy (PortableServer::SYSTEM_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policies[2] = + root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + +#if 0 + policies.length (3); +#else + policies[3] = + rtorb->create_threadpool_policy (pool_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +#endif /* 0 */ + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->poa_ = + root_poa->create_POA ("RTEC_Perf", + poa_manager.in (), + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + for (CORBA::ULong i = 0; i != policies.length (); ++i) + { + policies[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.h new file mode 100644 index 00000000000..dc3d19f0054 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.h @@ -0,0 +1,45 @@ +/** + * @file RTPOA_Setup.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_RTPOA_SETUP_H +#define TAO_PERF_RTEC_RTPOA_SETUP_H + +#include "rtec_perf_export.h" +#include "tao/RTPortableServer/RTPortableServer.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class RTCORBA_Setup; + +/** + * @class RTPOA_Setup + * + * @brief Simplify the initialization of performance tests. + * + */ +class TAO_RTEC_Perf_Export RTPOA_Setup +{ +public: + /// Constructor + RTPOA_Setup (CORBA::ORB_ptr orb, + const RTCORBA_Setup &rtcorba_setup + ACE_ENV_ARG_DECL); + + PortableServer::POA_ptr poa (void); + +private: + PortableServer::POA_var poa_; +}; + +#if defined(__ACE_INLINE__) +#include "RTPOA_Setup.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_RTPOA_SETUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.inl new file mode 100644 index 00000000000..1cbd13ca230 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTPOA_Setup.inl @@ -0,0 +1,13 @@ +/** + * @file RTPOA_Setup.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE PortableServer::POA_ptr +RTPOA_Setup::poa (void) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.cpp new file mode 100644 index 00000000000..609f8f7b314 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.cpp @@ -0,0 +1,57 @@ +/** + * @file RTServer_Setup.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "RTServer_Setup.h" +#include "RIR_Narrow.h" +#include "tao/RTCORBA/RTCORBA.h" + +#include "ace/Log_Msg.h" + +#if !defined(__ACE_INLINE__) +#include "RTServer_Setup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + RTServer_Setup, + "$Id$") + +RTServer_Setup::RTServer_Setup (int use_rt_corba, + CORBA::ORB_ptr orb, + const RT_Class &rt_class, + int nthreads + ACE_ENV_ARG_DECL) + : RTClient_Setup (use_rt_corba, + orb, + rt_class, + nthreads + ACE_ENV_ARG_PARAMETER) +{ + ACE_CHECK; + + if (use_rt_corba) + { + ACE_AUTO_PTR_RESET (this->rtpoa_setup_, + new RTPOA_Setup (orb, + *this->rtcorba_setup () + ACE_ENV_ARG_PARAMETER), + RTPOA_Setup + ); + ACE_CHECK; + + this->poa_ = + this->rtpoa_setup_->poa (); + } + else + { + this->poa_ = + RIR_Narrow::resolve (orb, + "RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.h new file mode 100644 index 00000000000..eecc21ec6f8 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.h @@ -0,0 +1,50 @@ +/** + * @file RTServer_Setup.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_RTSERVER_SETUP_H +#define TAO_PERF_RTEC_RTSERVER_SETUP_H +#include /**/ "ace/pre.h" + +#include "RTClient_Setup.h" +#include "RTPOA_Setup.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class RTServer_Setup + * + * @brief Simplify the initialization of performance tests. + * + */ +class TAO_RTEC_Perf_Export RTServer_Setup : public RTClient_Setup +{ +public: + /// Constructor + RTServer_Setup (int use_rt_corba, + CORBA::ORB_ptr orb, + const RT_Class &rt_class, + int nthreads + ACE_ENV_ARG_DECL); + + /// Return the POA configured by the RTPOA_Setup + PortableServer::POA_ptr poa (void); + +private: + PortableServer::POA_var poa_; + + auto_ptr rtpoa_setup_; +}; + +#if defined(__ACE_INLINE__) +#include "RTServer_Setup.inl" +#endif /* __ACE_INLINE__ */ + +#include /**/ "ace/post.h" +#endif /* TAO_PERF_RTEC_RTSERVER_SETUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.inl new file mode 100644 index 00000000000..40816da97c0 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RTServer_Setup.inl @@ -0,0 +1,13 @@ +/** + * @file RTServer_Setup.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE PortableServer::POA_ptr +RTServer_Setup::poa (void) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.cpp new file mode 100644 index 00000000000..65abada52e8 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.cpp @@ -0,0 +1,52 @@ +/** + * @file RT_Class.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "RT_Class.h" + +#include "ace/Log_Msg.h" +#include "ace/OS_NS_errno.h" + +#if !defined(__ACE_INLINE__) +#include "RT_Class.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + RT_Class, + "$Id$") + +RT_Class::RT_Class (void) + : prc_sched_class_ (ACE_SCHED_FIFO) + , thr_sched_class_ (THR_SCHED_FIFO) +{ + int priority = + (ACE_Sched_Params::priority_min (this->prc_sched_class_) + + ACE_Sched_Params::priority_max (this->prc_sched_class_)) / 2; + + if (ACE_OS::sched_params (ACE_Sched_Params (this->prc_sched_class_, + priority, + ACE_SCOPE_PROCESS)) != 0) + { + if (ACE_OS::last_error () == EPERM) + { + ACE_DEBUG ((LM_DEBUG, + "WARNING (%P|%t) user does not have " + "permissions to run real-time tests.\n" + "The test will run in the time-shared " + "class, it may fail or produce unpredictable " + "results\n")); + this->prc_sched_class_ = ACE_SCHED_OTHER; + this->thr_sched_class_ = THR_SCHED_DEFAULT; + } + } + this->priority_low_ = + ACE_Sched_Params::priority_min (this->prc_sched_class_); + this->priority_high_ = + ACE_Sched_Params::priority_max (this->prc_sched_class_); + this->priority_process_ = + (this->priority_low_ + this->priority_high_) / 2; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.h new file mode 100644 index 00000000000..d4dd0888362 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.h @@ -0,0 +1,74 @@ +/** + * @file RT_Class.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_RT_CLASS_H +#define TAO_PERF_RTEC_RT_CLASS_H + +#include "rtec_perf_export.h" +#include "ace/Sched_Params.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class RT_Class + * + * @brief Simplify the initialization of performance tests. + * + */ +class TAO_RTEC_Perf_Export RT_Class +{ +public: + /// Constructor + RT_Class (void); + + /** @name Return the test scheduling parameters + */ + //@{ + /// Return the process scheduling class selected for the test + int prc_sched_class (void) const; + + /// Return the thread scheduling class selected for the test + int thr_sched_class (void) const; + + /// Return the process priority selected for the test + int priority_process (void) const; + + /// Return the (thread, native) priority for the high priority + /// task(s) in the test + int priority_high (void) const; + + /// Return the (thread, native) priority for the low priority + /// task(s) in the test + int priority_low (void) const; + + //@} + +private: + /// The process scheduling class + int prc_sched_class_; + + /// The thread scheduling class + int thr_sched_class_; + + /// The process priority + int priority_process_; + + /// The high priority task(s) priority + int priority_high_; + + /// The low priority task(s) priority + int priority_low_; +}; + +#if defined(__ACE_INLINE__) +#include "RT_Class.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_RT_CLASS_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.inl new file mode 100644 index 00000000000..a6a60d8e7a0 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/RT_Class.inl @@ -0,0 +1,37 @@ +/** + * @file RT_Class.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE int +RT_Class::prc_sched_class (void) const +{ + return this->prc_sched_class_; +} + +ACE_INLINE int +RT_Class::thr_sched_class (void) const +{ + return this->thr_sched_class_; +} + +ACE_INLINE int +RT_Class::priority_process (void) const +{ + return this->priority_process_; +} + +ACE_INLINE int +RT_Class::priority_high (void) const +{ + return this->priority_high_; +} + +ACE_INLINE int +RT_Class::priority_low (void) const +{ + return this->priority_low_; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.cpp new file mode 100644 index 00000000000..125e75c85e7 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.cpp @@ -0,0 +1,130 @@ +/** + * @file Send_Task.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Send_Task.h" + +#include "orbsvcs/Time_Utilities.h" + +#include "ace/Barrier.h" +#include "ace/OS_NS_unistd.h" + +ACE_RCSID (TAO_PERF_RTEC, + Send_Task, + "$Id$") + +Send_Task::Send_Task (void) + : iterations_ (0) + , period_in_usecs_ (0) + , startup_sleep_ (0) + , event_type_ (0) + , event_source_ (0) + , barrier_ (0) + , stop_ (0) +{ +} + +void +Send_Task::init (int iterations, + int period_in_usecs, + int startup_sleep, + int event_type, + int event_source, + Supplier *supplier, + ACE_Barrier *barrier) +{ + this->iterations_ = iterations; + this->period_in_usecs_ = period_in_usecs; + this->startup_sleep_ = startup_sleep; + this->event_type_ = event_type; + this->event_source_ = event_source; + this->supplier_ = + TAO::Utils::Servant_Var::_duplicate (supplier); + this->barrier_ = barrier; +} + +void +Send_Task::stop (void) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + this->stop_ = 1; +} + +int +Send_Task::svc (void) +{ + if (this->barrier_ == 0) + return -1; + + this->barrier_->wait (); + + ACE_Time_Value startup (0, this->startup_sleep_); + ACE_OS::sleep (startup); + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) - Thread started, " + "iterations = %d, period = %d, event_type = %d\n", + this->iterations_, this->period_in_usecs_, + this->event_type_)); + + + int start_i = 0; + if (this->iterations_ == 0) + { + // Starting from 1 results in an infinite loop (well, so long + // that I call it infinite), which is exactly what we want, kind + // of hackish, oh well. + start_i = 1; + } + + RtecEventComm::EventSet event (1); + event.length (1); + event[0].header.type = this->event_type_; + event[0].header.source = this->event_source_; + event[0].header.ttl = 1; + + ACE_DECLARE_NEW_CORBA_ENV; + for (int i = start_i; i != this->iterations_; ++i) + { + if ((i + 1) % 1000 == 0) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) - Thread has sent %d messages @ %T\n", + i + 1)); + } + + ACE_Time_Value period (0, this->period_in_usecs_); + ACE_OS::sleep (period); + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->mutex_, -1); + if (this->stop_ != 0) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) - Thread has been stopped\n")); + return 0; + } + } + ACE_hrtime_t creation = ACE_OS::gethrtime (); + ORBSVCS_Time::hrtime_to_TimeT (event[0].header.creation_time, + creation); + ACE_TRY + { + // push one event... + this->supplier_->push (event ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Caught exception:"); + } + ACE_ENDTRY; + } + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) - Thread finished\n")); + return 0; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.h new file mode 100644 index 00000000000..318bb24e2aa --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task.h @@ -0,0 +1,78 @@ +/** + * @file Send_Task.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_SEND_TASK_H +#define TAO_PERF_RTEC_SEND_TASK_H + +#include "tao/Utils/Servant_Var.h" +#include "Supplier.h" +#include "ace/Task.h" +#include "ace/Synch_Traits.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +ACE_BEGIN_VERSIONED_NAMESPACE_DECL +class ACE_Barrier; +ACE_END_VERSIONED_NAMESPACE_DECL + +/** + * @class Send_Task + * + * @brief Implement a simple ACE_Task to send the events + * + */ +class TAO_RTEC_Perf_Export Send_Task : public ACE_Task_Base +{ +public: + /// Constructor + Send_Task (void); + + /// This is for compilers that are a PITA complaining that we are + /// hiding something. + virtual int init (int argc, ACE_TCHAR *argv[]) + { + return ACE_Task_Base::init (argc, argv); + } + + void init (int iterations, + int period_in_usecs, + int startup_sleep, + int event_type, + int event_source, + Supplier *supplier, + ACE_Barrier *barrier); + + /// Run the experiment + int svc (void); + + /// Stop the experiment + void stop (void); + +private: + int iterations_; + + int period_in_usecs_; + + int startup_sleep_; + + int event_type_; + + int event_source_; + + TAO::Utils::Servant_Var supplier_; + + ACE_Barrier *barrier_; + + TAO_SYNCH_MUTEX mutex_; + int stop_; +}; + + +#endif /* TAO_PERF_RTEC_SEND_TASK_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.cpp new file mode 100644 index 00000000000..6b8779e632e --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.cpp @@ -0,0 +1,24 @@ +/** + * @file Send_Task_Stopper.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Send_Task_Stopper.h" + +#if !defined(__ACE_INLINE__) +#include "Send_Task_Stopper.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + Send_Task_Stopper, + "$Id$") + +Send_Task_Stopper::~Send_Task_Stopper (void) +{ + if (this->task_ == 0) + return; + this->task_->stop (); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.h new file mode 100644 index 00000000000..3212409700c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.h @@ -0,0 +1,41 @@ +/** + * @file Send_Task_Stopper.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_SEND_TASK_STOPPER_H +#define TAO_PERF_RTEC_SEND_TASK_STOPPER_H + +#include "Send_Task.h" +#include "Task_Activator.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Send_Task_Stopper + * + * @brief Implement a helper class to activate and stop Send_Tasks. + * + */ +class TAO_RTEC_Perf_Export Send_Task_Stopper : public Task_Activator +{ +public: + /// Constructor + Send_Task_Stopper (int priority, + int scheduling_class, + Send_Task *task); + + /// Destructor, stop the task and wait for it + ~Send_Task_Stopper (void); +}; + +#if defined(__ACE_INLINE__) +#include "Send_Task_Stopper.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_SEND_TASK_STOPPER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.inl new file mode 100644 index 00000000000..b620c992a2d --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Send_Task_Stopper.inl @@ -0,0 +1,16 @@ +/** + * @file Send_Task_Stopper.inl + * +` * $Id$ + * + * @author Carlos O'Ryan + */ + +ACE_INLINE +Send_Task_Stopper::Send_Task_Stopper (int priority, + int scheduling_class, + Send_Task *task) + : Task_Activator (priority, scheduling_class, 1, + task) +{ +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.cpp new file mode 100644 index 00000000000..7e154ad088b --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.cpp @@ -0,0 +1,58 @@ +/** + * @file Servant_var.cpp + * + * $Id$ + * + * @author Jody Hagins + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_SERVANT_VAR_CPP +#define TAO_PERF_RTEC_SERVANT_VAR_CPP + +#include "Servant_var.h" +#include "tao/Environment.h" + +#if !defined(__ACE_INLINE__) +#include "Servant_var.inl" +#endif /* __ACE_INLINE__ */ + +template +Servant_var::~Servant_var () +{ + if (this->ptr_ == 0) + return; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY { + this->ptr_->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } ACE_CATCHANY { + // @@ TODO This event should be logged. Cannot throw because that + // would make it impossible to use this class effectively. + // + // Suggested implementation: + // + // class Servant_Logger { + // public: + // static void log_error (void *servant_pointer) + // { + // if (Servant_Logger::instance_ == 0) + // return; + // Servant_Logger::instance_->logger_implementation (servant_pointer); + // } + // static Servant_Logger *set_instance (Servant_Logger*); + // + // virtual void logger_implementation (void *servant_pointer) = 0; + // + // private: + // static Servant_Logger *instance_; + // }; + // + // Using an abstract class for logging decouples the code from any + // particular implementation, and provides a light-weight, + // high-performance solution for applications that want to avoid + // logging. + } ACE_ENDTRY; +} + +#endif /* TAO_PERF_RTEC_SERVANT_VAR_CPP */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.h new file mode 100644 index 00000000000..4d035f8b43c --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.h @@ -0,0 +1,81 @@ +/** + * @file Servant_var.h + * + * $Id$ + * + * @author Jody Hagins + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_SERVANT_VAR_H +#define TAO_PERF_RTEC_SERVANT_VAR_H + +#include "ace/Swap.h" +#include "tao/corba.h" + +/** + * @class Servant_var + * + * @brief Implement a smart pointer class for Servants + * + * All servants, are reference counted objects. + * Unfortunately the specification lacks such an useful smart pointer + * class to manage their life-cycle. + */ +template +class Servant_var +{ +public: + /// Constructor + /** + * @param s The contained servant. The constructor assumes + * ownership. + */ + explicit Servant_var (SERVANT *s = 0); + + /// Copy constructor + Servant_var (const Servant_var &rhs); + + /// Assignment + Servant_var& operator= (const Servant_var &rhs); + + /// Assignment + Servant_var& operator= (SERVANT *s); + + /// Destructor + ~Servant_var (); + + /// Helper method to increase the reference count on a servant. + static SERVANT *duplicate (SERVANT *servart); + + //@{ + /** @name Smart pointer operations + */ + const SERVANT * operator->() const; + SERVANT * operator->(); + + operator SERVANT *(); + operator const SERVANT * () const; + //@} + + //@{ + /** @name Canonical CORBA T_var methods + */ + SERVANT *in () const; + SERVANT *&out (); + SERVANT *&inout (); + //@} + +private: + /// The owned object + SERVANT *ptr_; +}; + +#if defined(__ACE_INLINE__) +#include "Servant_var.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Servant_var.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#endif /* TAO_PERF_RTEC_SERVANT_VAR_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.inl new file mode 100644 index 00000000000..bc65b994d0d --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.inl @@ -0,0 +1,89 @@ +/** + * @file Servant_var.inl + * + * $Id$ + * + * @author Jody Hagins + * @author Carlos O'Ryan + */ + +template ACE_INLINE SERVANT * +Servant_var::duplicate (SERVANT *servant) +{ + if (servant != 0) + servant->_add_ref (); + return servant; +} + +template ACE_INLINE +Servant_var::Servant_var (SERVANT *s) + : ptr_ (s) +{ +} + +template ACE_INLINE +Servant_var::Servant_var (const Servant_var &rhs) + : ptr_ (Servant_var::duplicate (rhs.ptr_)) +{ +} + +template ACE_INLINE Servant_var& +Servant_var::operator= (const Servant_var &rhs) +{ + Servant_var tmp (rhs); + ACE_Swap::swap (this->ptr_, tmp.ptr_); + return *this; +} + +template ACE_INLINE Servant_var& +Servant_var::operator= (SERVANT *rhs) +{ + Servant_var tmp (rhs); + ACE_Swap::swap (this->ptr_, tmp.ptr_); + return *this; +} + +template ACE_INLINE SERVANT* +Servant_var::operator-> () +{ + return this->ptr_; +} + +template ACE_INLINE const SERVANT* +Servant_var::operator-> () const +{ + return this->ptr_; +} + +template ACE_INLINE +Servant_var::operator SERVANT *() +{ + return this->ptr_; +} + +template ACE_INLINE +Servant_var::operator const SERVANT * () const +{ + return this->ptr_; +} + +template ACE_INLINE SERVANT * +Servant_var::in () const +{ + return this->ptr_; +} + +template ACE_INLINE SERVANT *& +Servant_var::out () +{ + Servant_var tmp; + ACE_Swap::swap (tmp.ptr_, this->ptr_); + + return this->ptr_; +} + +template ACE_INLINE SERVANT *& +Servant_var::inout () +{ + return this->ptr_; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.cpp new file mode 100644 index 00000000000..84d42ba3bc6 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.cpp @@ -0,0 +1,17 @@ +/** + * @file Shutdown.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_SHUTDOWN_CPP +#define TAO_PERF_RTEC_SHUTDOWN_CPP + +#include "Shutdown.h" + +#if !defined(__ACE_INLINE__) +#include "Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_SHUTDOWN_CPP */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.h new file mode 100644 index 00000000000..d0737b7bf01 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.h @@ -0,0 +1,34 @@ +/** + * @file Shutdown.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_SHUTDOWN_H +#define TAO_PERF_RTEC_SHUTDOWN_H + +#include "ace/config-all.h" +#include "ace/CORBA_macros.h" + +/** + * @class Shutdown + * + * @brief Helper functor to call the shutdown() method of a class. + */ +template +class Shutdown +{ +public: + void operator() (Client *client); +}; + +#if defined(__ACE_INLINE__) +#include "Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Shutdown.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#endif /* TAO_PERF_RTEC_SHUTDOWN_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.inl new file mode 100644 index 00000000000..aa5af0895cb --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Shutdown.inl @@ -0,0 +1,20 @@ +/** + * @file Shutdown.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +template ACE_INLINE void +Shutdown::operator () (Client *client) +{ + ACE_DECLARE_NEW_ENV; + ACE_TRY + { + client->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY { }; + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.cpp new file mode 100644 index 00000000000..11c14e80232 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.cpp @@ -0,0 +1,121 @@ +/** + * @file Supplier.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "Supplier.h" +#include "Implicit_Deactivator.h" + +ACE_RCSID (TAO_PERF_RTEC, + Supplier, + "$Id$") + +Supplier::Supplier (CORBA::Long experiment_id, + CORBA::Long event_type, + CORBA::Long event_range, + PortableServer::POA_ptr poa) + : experiment_id_ (experiment_id) + , event_type_ (event_type) + , event_range_ (event_range) + , default_POA_ (PortableServer::POA::_duplicate (poa)) +{ +} + +void +Supplier::connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL) +{ + RtecEventChannelAdmin::SupplierAdmin_var supplier_admin = + ec->for_suppliers (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (!CORBA::is_nil (this->proxy_consumer_.in ())) + return; + + this->proxy_consumer_ = + supplier_admin->obtain_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + + RtecEventComm::PushSupplier_var supplier = + this->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + RtecEventChannelAdmin::SupplierQOS supplier_qos; + supplier_qos.is_gateway = 0; + supplier_qos.publications.length (this->event_range_); + for (CORBA::Long i = 0; i != this->event_range_; ++i) + { + RtecEventComm::EventHeader& sh = + supplier_qos.publications[i].event.header; + sh.type = this->event_type_ + 2 * i; + sh.source = this->experiment_id_; + } + + this->proxy_consumer_->connect_push_supplier (supplier.in (), + supplier_qos + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +Supplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + RtecEventChannelAdmin::ProxyPushConsumer_var proxy; + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (CORBA::is_nil (this->proxy_consumer_.in ())) + return; + proxy = this->proxy_consumer_._retn (); + } + + Implicit_Deactivator deactivator (this + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + proxy->disconnect_push_consumer (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY {} ACE_ENDTRY; +} + +void +Supplier::push (const RtecEventComm::EventSet &events + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // ACE_DEBUG ((LM_DEBUG, "Supplier pushing (%d,%d)\n", + // events[0].header.type, events[0].header.source)); + RtecEventChannelAdmin::ProxyPushConsumer_var proxy; + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + if (CORBA::is_nil (this->proxy_consumer_.in ())) + return; + proxy = this->proxy_consumer_; + } + + proxy->push (events ACE_ENV_ARG_PARAMETER); +} + +void +Supplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + this->proxy_consumer_ = + RtecEventChannelAdmin::ProxyPushConsumer::_nil (); +} + +PortableServer::POA_ptr +Supplier::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.h new file mode 100644 index 00000000000..4ae8d76a414 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Supplier.h @@ -0,0 +1,81 @@ +/** + * @file Supplier.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_SUPPLIER_H +#define TAO_PERF_RTEC_SUPPLIER_H + +#include "rtec_perf_export.h" +#include "orbsvcs/RtecEventCommS.h" +#include "orbsvcs/RtecEventChannelAdminC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Supplier + * + * @brief Implement a simple supplier to keep track of the latency + * + */ +class TAO_RTEC_Perf_Export Supplier + : public virtual POA_RtecEventComm::PushSupplier +{ +public: + /// Constructor + /** + * The experiment ID is used to configure the supplier ID on the + * publication. + */ + Supplier (CORBA::Long experiment_id, + CORBA::Long event_type, + CORBA::Long event_range, + PortableServer::POA_ptr poa); + + /// Connect to the event channel + void connect (RtecEventChannelAdmin::EventChannel_ptr ec + ACE_ENV_ARG_DECL); + + /// Disconnect from the event channel + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + void push (const RtecEventComm::EventSet &events + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + + //@{ + /** @name The RtecEventComm::PushSupplier methods + */ + virtual void disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + virtual PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)); + //@} + +private: + /// The experiment id + /// Synchronize access to the internal data + TAO_SYNCH_MUTEX mutex_; + + /// The experiment id + CORBA::Long experiment_id_; + + /// The event type + CORBA::Long event_type_; + + /// The event type + CORBA::Long event_range_; + + /// The proxy this object is connected to + RtecEventChannelAdmin::ProxyPushConsumer_var proxy_consumer_; + + /// The default poa + PortableServer::POA_var default_POA_; +}; + +#endif /* TAO_PERF_RTEC_SUPPLIER_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.cpp new file mode 100644 index 00000000000..b0f66d12d9e --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.cpp @@ -0,0 +1,71 @@ +/** + * @file SyncScope_Setup.cpp + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "SyncScope_Setup.h" +#include "RIR_Narrow.h" +#include "tao/AnyTypeCode/Any.h" + +#if !defined(__ACE_INLINE__) +#include "SyncScope_Setup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (TAO_PERF_RTEC, + SyncScope_Setup, + "$Id$") + +SyncScope_Setup::SyncScope_Setup (CORBA::ORB_ptr orb, + Messaging::SyncScope value + ACE_ENV_ARG_DECL) +{ + this->init (orb, value + ACE_ENV_ARG_PARAMETER); +} + +SyncScope_Setup::SyncScope_Setup (CORBA::ORB_ptr orb + ACE_ENV_ARG_DECL) +{ + this->init (orb, Messaging::SYNC_WITH_TARGET + ACE_ENV_ARG_PARAMETER); +} + +void +SyncScope_Setup::init (CORBA::ORB_ptr orb, + Messaging::SyncScope value + ACE_ENV_ARG_DECL) +{ + CORBA::PolicyManager_var policy_manager = + RIR_Narrow::resolve (orb, + "ORBPolicyManager" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::PolicyList policy_list (1); + policy_list.length (1); + + CORBA::Any sync_scope; + sync_scope <<= value; + + // @@ We need a helper class that automatically calls the + // destroy() method on each policy... + policy_list[0] = + orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE, + sync_scope + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + policy_manager->set_policy_overrides (policy_list, + CORBA::ADD_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list[0]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +SyncScope_Setup::~SyncScope_Setup (void) +{ +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.h new file mode 100644 index 00000000000..9de943cc419 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.h @@ -0,0 +1,53 @@ +/** + * @file SyncScope_Setup.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_SYNCSCOPE_SETUP_H +#define TAO_PERF_RTEC_SYNCSCOPE_SETUP_H + +#include "rtec_perf_export.h" +#include "tao/Messaging/Messaging.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class SyncScope_Setup + * + * @brief Simplify the initialization of performance tests. + * + */ +class TAO_RTEC_Perf_Export SyncScope_Setup +{ +public: + /// Constructor + SyncScope_Setup (CORBA::ORB_ptr orb + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + SyncScope_Setup (CORBA::ORB_ptr orb, + Messaging::SyncScope value + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// Destructor + /** + * It is a no-op, but it shuts up g++ + */ + ~SyncScope_Setup (void); + +private: + /// Implement the shared code between both constructors + void init (CORBA::ORB_ptr orb, + Messaging::SyncScope value + ACE_ENV_ARG_DECL); +}; + +#if defined(__ACE_INLINE__) +#include "SyncScope_Setup.inl" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_PERF_RTEC_SYNCSCOPE_SETUP_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.inl new file mode 100644 index 00000000000..1b47e4a8abf --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/SyncScope_Setup.inl @@ -0,0 +1,7 @@ +/** + * @file SyncScope_Setup.inl + * + * $Id$ + * + * @author Carlos O'Ryan + */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.cpp b/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.cpp new file mode 100644 index 00000000000..3eb00cee362 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.cpp @@ -0,0 +1,55 @@ +/** + * @file Task_Activator.cpp + * + * $Id$ + * + * @author Jody Hagins + * @author Carlos O'Ryan + */ +#ifndef TAO_PERF_RTEC_TASK_ACTIVATOR_CPP +#define TAO_PERF_RTEC_TASK_ACTIVATOR_CPP + +#include "Task_Activator.h" +#include "tao/Environment.h" +#include "ace/Log_Msg.h" + +#if !defined(__ACE_INLINE__) +#include "Task_Activator.inl" +#endif /* __ACE_INLINE__ */ + +template +Task_Activator::Task_Activator (int priority, + int scheduling_class, + int nthreads, + Task *task) + : task_ (task) +{ + if (this->task_ == 0) + return; + + // We explicitly ignore errors, this is exactly what we do in the + // test anyway. In a generic class we would need to throw an + // exception. + if (this->task_->activate (scheduling_class | THR_NEW_LWP | THR_JOINABLE, + nthreads, + 1, // force_activation + priority) == -1) + { + // Release, we cannot wait for it or anything like that... + this->task_ = 0; + ACE_DEBUG ((LM_DEBUG, + "Task_Activator failed %p\n", "")); + } +} + +template +Task_Activator::~Task_Activator (void) +{ + if (this->task_ == 0) + return; + + // Wait until the task terminates + this->task_->wait (); +} + +#endif /* TAO_PERF_RTEC_TASK_ACTIVATOR_CPP */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.h new file mode 100644 index 00000000000..f2f78836c29 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.h @@ -0,0 +1,86 @@ +/** + * @file Task_Activator.h + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#ifndef TAO_PERF_RTEC_TASK_ACTIVATOR_H +#define TAO_PERF_RTEC_TASK_ACTIVATOR_H + +#include "ace/Task.h" +#include "ace/Copy_Disabled.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class Task_Activator + * + * @brief Simplify the activation and destruction of tasks + * + */ +template +class Task_Activator : private ACE_Copy_Disabled +{ +public: + /// Constructor + /** + * @todo If we were to define a generic ACE class for this then we + * should certainly change the constructor. For example, we + * should pass an structure with all the thread activation + * arguments, like:
+ * Activation_Properties properties;
+ * Task_Activator activator (properties, foo);
+ *
+ * The advantage of using an structure instead of a long list + * of arguments is that the user can change some of the + * defaults without having to know all the other values, plus + * it evolves better: over time if arguments are added the + * client code does not change.
+ *
+ * With a little trickery we can even change the arguments in + * a single line:
+ * Activation_Properties props ().priority (x).stack_size (y);
+ *
+ * all you need to do is return *this from each + * modifier. + * + */ + Task_Activator (int priority, + int scheduling_class, + int nthreads, + Task *task); + + /// Destructor + /** + * Wait until the task terminates before returning, this is useful + * in programs that need to guarantee that the task object is not + * destroyed before the underlying threads finished. + * However, the use of this class implicitly requires that the task + * will eventually terminate! + * + * Sometimes it is better to derive from this class and implement a + * cooperative termination protocol in the destructor of the derived + * class. + */ + ~Task_Activator (void); + + /// Release the task, do not terminate it + void release (void); + +protected: + Task *task_; +}; + +#if defined(__ACE_INLINE__) +#include "Task_Activator.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Task_Activator.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#endif /* TAO_PERF_RTEC_TASK_ACTIVATOR_H */ diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.inl b/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.inl new file mode 100644 index 00000000000..147a3e53769 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/Task_Activator.inl @@ -0,0 +1,13 @@ +/** + * @file Task_Activator.inl + * +` * $Id$ + * + * @author Carlos O'Ryan + */ + +template ACE_INLINE void +Task_Activator::release () +{ + this->task_ = 0; +} diff --git a/TAO/orbsvcs/performance-tests/RTEvent/lib/rtec_perf_export.h b/TAO/orbsvcs/performance-tests/RTEvent/lib/rtec_perf_export.h new file mode 100644 index 00000000000..7a32929cf47 --- /dev/null +++ b/TAO/orbsvcs/performance-tests/RTEvent/lib/rtec_perf_export.h @@ -0,0 +1,40 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl +// ------------------------------ +#ifndef TAO_RTEC_PERF_EXPORT_H +#define TAO_RTEC_PERF_EXPORT_H + +#include "ace/config-all.h" + +#if defined (TAO_AS_STATIC_LIBS) +# if !defined (TAO_RTEC_PERF_HAS_DLL) +# define TAO_RTEC_PERF_HAS_DLL 0 +# endif /* ! TAO_RTEC_PERF_HAS_DLL */ +#else +# if !defined (TAO_RTEC_PERF_HAS_DLL) +# define TAO_RTEC_PERF_HAS_DLL 1 +# endif /* ! TAO_RTEC_PERF_HAS_DLL */ +#endif + +#if defined (TAO_RTEC_PERF_HAS_DLL) && (TAO_RTEC_PERF_HAS_DLL == 1) +# if defined (TAO_RTEC_PERF_BUILD_DLL) +# define TAO_RTEC_Perf_Export ACE_Proper_Export_Flag +# define TAO_RTEC_PERF_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_RTEC_PERF_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_RTEC_PERF_BUILD_DLL */ +# define TAO_RTEC_Perf_Export ACE_Proper_Import_Flag +# define TAO_RTEC_PERF_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_RTEC_PERF_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_RTEC_PERF_BUILD_DLL */ +#else /* TAO_RTEC_PERF_HAS_DLL == 1 */ +# define TAO_RTEC_Perf_Export +# define TAO_RTEC_PERF_SINGLETON_DECLARATION(T) +# define TAO_RTEC_PERF_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_RTEC_PERF_HAS_DLL == 1 */ + +#endif /* TAO_RTEC_PERF_EXPORT_H */ + +// End of auto generated file. -- cgit v1.2.1