diff options
author | jtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-08-26 13:42:42 +0000 |
---|---|---|
committer | jtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-08-26 13:42:42 +0000 |
commit | 3c921c770d98b8c09d726c2ef6e9748744a84046 (patch) | |
tree | 49b3b5482b221064674cf4599cc2920149989aeb /TAO/orbsvcs/Logging_Service/Event_Logging_Service | |
parent | 00439fb2fa717058e67745acae1de98a8196bc49 (diff) | |
download | ATCD-3c921c770d98b8c09d726c2ef6e9748744a84046.tar.gz |
ChangeLogTag: Fri Aug 26 06:33:04 2005 J.T. Conklin <jtc@acorntoolworks.com>
Diffstat (limited to 'TAO/orbsvcs/Logging_Service/Event_Logging_Service')
4 files changed, 132 insertions, 60 deletions
diff --git a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Server.cpp b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Server.cpp new file mode 100644 index 00000000000..df39a45e79d --- /dev/null +++ b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Server.cpp @@ -0,0 +1,79 @@ +#include "Event_Logging_Service.h" +#include "ace/OS_main.h" + +#include "orbsvcs/Shutdown_Utilities.h" +#include "tao/debug.h" + +ACE_RCSID (Event_Logging_Service, + Event_Logging_Server, + "$Id$") + + +class Logging_Svc_Shutdown + : public Shutdown_Functor +{ +public: + Logging_Svc_Shutdown (Event_Logging_Service& svc); + + void operator() (int which_signal); + +private: + Event_Logging_Service& svc_; +}; + +Logging_Svc_Shutdown::Logging_Svc_Shutdown (Event_Logging_Service& svc) + : svc_ (svc) +{ +} + +void +Logging_Svc_Shutdown::operator() (int which_signal) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + "Event_Logging_Service: shutting down on signal %d\n", + which_signal)); + (void) this->svc_.shutdown (); +} + +// Driver function for the Event_Logging_Service + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + TAO_CEC_Default_Factory::init_svcs (); + + Event_Logging_Service service; + + Logging_Svc_Shutdown killer (service); + Service_Shutdown kill_contractor (killer); + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + int rc; + + rc = service.init (argc, argv ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (rc == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Failed to start the Telecom Log Service.\n"), + 1); + + rc = service.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + if (rc == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Failed to start the Telecom Log Service.\n"), + 1); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Failed to start the Telecom Log Service.\n"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp index 8ab0b316cf0..e97cc755572 100644 --- a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp +++ b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp @@ -3,7 +3,6 @@ #include "orbsvcs/Log/EventLogFactory_i.h" #include "orbsvcs/CosEvent/CEC_Default_Factory.h" #include "tao/IORTable/IORTable.h" -#include "ace/OS_main.h" #include "ace/OS_NS_stdio.h" #include "ace/OS_NS_unistd.h" @@ -16,7 +15,8 @@ Event_Logging_Service::Event_Logging_Service (void) : service_name_ ("EventLogFactory"), ior_file_name_ (0), pid_file_name_ (0), - bind_to_naming_service_ (1) + bind_to_naming_service_ (1), + nthreads_ (0) { // No-Op. } @@ -28,7 +28,7 @@ Event_Logging_Service::~Event_Logging_Service (void) void Event_Logging_Service::init_ORB (int& argc, char *argv [] - ACE_ENV_ARG_DECL) + ACE_ENV_ARG_DECL) { this->orb_ = CORBA::ORB_init (argc, argv, @@ -57,7 +57,7 @@ Event_Logging_Service::init_ORB (int& argc, char *argv [] int Event_Logging_Service::parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opt (argc, argv, ACE_LIB_TEXT("n:o:p:x")); + ACE_Get_Opt get_opt (argc, argv, ACE_LIB_TEXT("n:o:p:t:x")); int opt; while ((opt = get_opt ()) != EOF) @@ -76,6 +76,10 @@ Event_Logging_Service::parse_args (int argc, char *argv[]) pid_file_name_ = get_opt.opt_arg(); break; + case 't': + nthreads_ = ACE_OS::atoi (get_opt.opt_arg ()); + break; + case 'x': bind_to_naming_service_ = 0; break; @@ -87,6 +91,7 @@ Event_Logging_Service::parse_args (int argc, char *argv[]) "-n service_name " "-o ior_file_name " "-p pid_file_name " + "-t threads " "-x [disable naming service bind] " "\n", argv[0])); @@ -98,8 +103,7 @@ Event_Logging_Service::parse_args (int argc, char *argv[]) } int -Event_Logging_Service::startup (int argc, char *argv[] - ACE_ENV_ARG_DECL) +Event_Logging_Service::init (int argc, char *argv[] ACE_ENV_ARG_DECL) { // initalize the ORB. this->init_ORB (argc, argv @@ -111,9 +115,9 @@ Event_Logging_Service::startup (int argc, char *argv[] // Activate the event log factory ACE_NEW_THROW_EX (this->event_log_factory_, - TAO_EventLogFactory_i (), - CORBA::NO_MEMORY ()); - + TAO_EventLogFactory_i (), + CORBA::NO_MEMORY ()); + // CORBA::Object_var obj = DsEventLogAdmin::EventLogFactory_var obj = this->event_log_factory_->activate (this->orb_.in (), @@ -208,7 +212,25 @@ Event_Logging_Service::resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL) } int -Event_Logging_Service::run (void) +Event_Logging_Service::run (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->nthreads_ > 0) + { + if (this->activate ((THR_NEW_LWP | THR_JOINABLE), this->nthreads_) != 0) + return -1; + + this->thr_mgr ()->wait (); + return 0; + } + + this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + return 0; +} + +int +Event_Logging_Service::svc (void) { ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY @@ -228,6 +250,8 @@ Event_Logging_Service::run (void) void Event_Logging_Service::shutdown (ACE_ENV_SINGLE_ARG_DECL) { + // @@ JTC - factory object isn't activated on root poa. +#if 0 // Deactivate. PortableServer::ObjectId_var oid = this->poa_->servant_to_id (this->event_log_factory_ @@ -238,6 +262,7 @@ Event_Logging_Service::shutdown (ACE_ENV_SINGLE_ARG_DECL) this->poa_->deactivate_object (oid.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK; +#endif if (bind_to_naming_service_) { @@ -254,43 +279,3 @@ Event_Logging_Service::shutdown (ACE_ENV_SINGLE_ARG_DECL) if (!CORBA::is_nil (this->orb_.in ())) this->orb_->shutdown (); } - -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - TAO_CEC_Default_Factory::init_svcs (); - - ACE_DECLARE_NEW_CORBA_ENV; - - ACE_TRY - { - Event_Logging_Service service; - - service.startup (argc, - argv - ACE_ENV_ARG_PARAMETER); - - ACE_TRY_CHECK; - - if (service.run () == -1) - { - service.shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); - - ACE_ERROR_RETURN ((LM_ERROR, - "Failed to run the Telecom Log Service.\n"), - 1); - - ACE_TRY_CHECK; - } - - service.shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - // no -op - } - ACE_ENDTRY; - - return 0; -} diff --git a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h index 7d6b34eb030..de98deb20f9 100644 --- a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h +++ b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h @@ -6,7 +6,7 @@ * * $Id$ * - * Front End of the Telecom Log Service + * Front End of the Telecom Log Service * Event_Logging_Service * * @@ -17,18 +17,20 @@ #ifndef EVENT_LOGGING_SERVICE_H #define EVENT_LOGGING_SERVICE_H +#include "ace/Task.h" #include "orbsvcs/CosNamingC.h" #include "orbsvcs/DsLogAdminC.h" #include "orbsvcs/DsEventLogAdminC.h" #include "orbsvcs/Log/EventLogFactory_i.h" class Event_Logging_Service + : public ACE_Task_Base { // = TITLE // Event_Logging_Service // // = DESCRIPTION - // Implementation of the Telecom EventLog Service + // Implementation of the Telecom Log Service public: // = Initialization and termination methods. @@ -38,13 +40,12 @@ class Event_Logging_Service virtual ~Event_Logging_Service (void); // Destructor. - int startup (int argc, char *argv[] - ACE_ENV_ARG_DECL); - // Initializes the Telecom EventLog Service. + int init (int argc, char *argv[] ACE_ENV_ARG_DECL); + // Initializes the Telecom Log Service. // Returns 0 on success, -1 on error. - int run (void); - // run the Telecom EventLog Service. + int run (ACE_ENV_SINGLE_ARG_DECL); + // Run the Telecom Log Service. // Returns 0 on success, -1 on error. void shutdown (ACE_ENV_SINGLE_ARG_DECL); @@ -62,6 +63,9 @@ protected: void resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL); // Resolve the naming service. + int svc (); + // Run worker threads. + // = Data members TAO_EventLogFactory_i *event_log_factory_; // The Event Log Factory. @@ -74,17 +78,20 @@ protected: CosNaming::NamingContext_var naming_; // A naming context. - + const char* service_name_; // The name we use to bind with the NameService const char* ior_file_name_; - // The name of the file were we output the Event_Service IOR. + // The name of the file where we output the factory IOR. const char* pid_file_name_; - // The name of a file where the process stores its pid + // The name of the file where we output the process id. int bind_to_naming_service_; // If true, bind to naming service + + int nthreads_; + // Number of worker threads. }; #endif /* EVENT_LOGGING_SERVICE_H */ diff --git a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Makefile.am b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Makefile.am index 216da2b4c6f..af43a906ca8 100644 --- a/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Makefile.am +++ b/TAO/orbsvcs/Logging_Service/Event_Logging_Service/Makefile.am @@ -30,6 +30,7 @@ Event_Logging_Service_CPPFLAGS = \ -DTAO_HAS_TYPED_EVENT_CHANNEL Event_Logging_Service_SOURCES = \ + Event_Logging_Server.cpp \ Event_Logging_Service.cpp \ Event_Logging_Service.h |