summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Logging_Service
diff options
context:
space:
mode:
authorjtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-08-26 13:42:42 +0000
committerjtc <jtc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-08-26 13:42:42 +0000
commit3c921c770d98b8c09d726c2ef6e9748744a84046 (patch)
tree49b3b5482b221064674cf4599cc2920149989aeb /TAO/orbsvcs/Logging_Service
parent00439fb2fa717058e67745acae1de98a8196bc49 (diff)
downloadATCD-3c921c770d98b8c09d726c2ef6e9748744a84046.tar.gz
ChangeLogTag: Fri Aug 26 06:33:04 2005 J.T. Conklin <jtc@acorntoolworks.com>
Diffstat (limited to 'TAO/orbsvcs/Logging_Service')
-rw-r--r--TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Server.cpp77
-rw-r--r--TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp65
-rw-r--r--TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h25
-rw-r--r--TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Makefile.am1
-rw-r--r--TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Server.cpp79
-rw-r--r--TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.cpp85
-rw-r--r--TAO/orbsvcs/Logging_Service/Event_Logging_Service/Event_Logging_Service.h27
-rw-r--r--TAO/orbsvcs/Logging_Service/Event_Logging_Service/Makefile.am1
-rw-r--r--TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp65
-rw-r--r--TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp42
-rw-r--r--TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h37
11 files changed, 363 insertions, 141 deletions
diff --git a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Server.cpp b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Server.cpp
new file mode 100644
index 00000000000..ef3983f3f3b
--- /dev/null
+++ b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Server.cpp
@@ -0,0 +1,77 @@
+#include "Basic_Logging_Service.h"
+#include "ace/OS_main.h"
+
+#include "orbsvcs/Shutdown_Utilities.h"
+#include "tao/debug.h"
+
+ACE_RCSID (Basic_Logging_Service,
+ Basic_Logging_Server,
+ "$Id$")
+
+
+class Logging_Svc_Shutdown
+ : public Shutdown_Functor
+{
+public:
+ Logging_Svc_Shutdown (Basic_Logging_Service& svc);
+
+ void operator() (int which_signal);
+
+private:
+ Basic_Logging_Service& svc_;
+};
+
+Logging_Svc_Shutdown::Logging_Svc_Shutdown (Basic_Logging_Service& svc)
+ : svc_ (svc)
+{
+}
+
+void
+Logging_Svc_Shutdown::operator() (int which_signal)
+{
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "Basic_Logging_Service: shutting down on signal %d\n",
+ which_signal));
+ (void) this->svc_.shutdown ();
+}
+
+// Driver function for the Basic_Logging_Service
+
+int
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ Basic_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/Basic_Logging_Service/Basic_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp
index c8e2053832b..883b10c8b03 100644
--- a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp
+++ b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.cpp
@@ -2,7 +2,6 @@
#include "ace/Get_Opt.h"
#include "orbsvcs/Log/BasicLogFactory_i.h"
#include "tao/IORTable/IORTable.h"
-#include "ace/OS_main.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_unistd.h"
@@ -15,7 +14,8 @@ Basic_Logging_Service::Basic_Logging_Service (void)
: service_name_ ("BasicLogFactory"),
ior_file_name_ (0),
pid_file_name_ (0),
- bind_to_naming_service_ (1)
+ bind_to_naming_service_ (1),
+ nthreads_ (0)
{
// No-Op.
}
@@ -27,7 +27,7 @@ Basic_Logging_Service::~Basic_Logging_Service (void)
void
Basic_Logging_Service::init_ORB (int& argc, char *argv []
- ACE_ENV_ARG_DECL)
+ ACE_ENV_ARG_DECL)
{
this->orb_ = CORBA::ORB_init (argc,
argv,
@@ -56,7 +56,7 @@ Basic_Logging_Service::init_ORB (int& argc, char *argv []
int
Basic_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)
@@ -75,6 +75,10 @@ Basic_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;
@@ -86,6 +90,7 @@ Basic_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]));
@@ -97,8 +102,7 @@ Basic_Logging_Service::parse_args (int argc, char *argv[])
}
int
-Basic_Logging_Service::startup (int argc, char *argv[]
- ACE_ENV_ARG_DECL)
+Basic_Logging_Service::init (int argc, char *argv[] ACE_ENV_ARG_DECL)
{
// initalize the ORB.
this->init_ORB (argc, argv
@@ -203,7 +207,25 @@ Basic_Logging_Service::resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL)
}
int
-Basic_Logging_Service::run (void)
+Basic_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
+Basic_Logging_Service::svc ()
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
@@ -223,6 +245,8 @@ Basic_Logging_Service::run (void)
void
Basic_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->basic_log_factory_
@@ -233,6 +257,7 @@ Basic_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_)
{
@@ -249,29 +274,3 @@ Basic_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[])
-{
- ACE_DECLARE_NEW_CORBA_ENV;
-
- Basic_Logging_Service service;
-
- if (service.startup (argc, argv ACE_ENV_ARG_PARAMETER) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Failed to start the Basic Logging Service.\n"),
- 1);
-
- if (service.run () == -1)
- {
- service.shutdown ();
- ACE_ERROR_RETURN ((LM_ERROR,
- "Failed to run the Telecom Log Service.\n"),
- 1);
- }
-
- service.shutdown ();
-
- return 0;
-}
-
diff --git a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h
index 7c488a1dd80..57066ebf020 100644
--- a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h
+++ b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Basic_Logging_Service.h
@@ -6,7 +6,7 @@
*
* $Id$
*
- * Front End of the Telecom Log Service
+ * Front End of the Telecom Log Service
* Basic_Logging_Service
*
*
@@ -17,14 +17,16 @@
#ifndef BASIC_LOGGING_SERVICE_H
#define BASIC_LOGGING_SERVICE_H
+#include "ace/Task.h"
#include "orbsvcs/CosNamingC.h"
#include "orbsvcs/DsLogAdminC.h"
#include "orbsvcs/Log/BasicLogFactory_i.h"
class Basic_Logging_Service
+ : public ACE_Task_Base
{
// = TITLE
- // Logging_Service
+ // Basic_Logging_Service
//
// = DESCRIPTION
// Implementation of the Telecom Log Service
@@ -37,16 +39,15 @@ class Basic_Logging_Service
virtual ~Basic_Logging_Service (void);
// Destructor.
- int startup (int argc, char *argv[]
- ACE_ENV_ARG_DECL);
+ 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 Log 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_WITH_DEFAULTS);
+ void shutdown (ACE_ENV_SINGLE_ARG_DECL);
// Shutdown the Telecom Log Service.
// Returns 0 on success, -1 on error.
@@ -61,6 +62,9 @@ protected:
void resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL);
// Resolve the naming service.
+ int svc ();
+ // Run worker threads.
+
// = Data members
TAO_BasicLogFactory_i basic_log_factory_;
// The Basic Log Factory.
@@ -78,12 +82,15 @@ protected:
// 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 /* BASIC_LOGGING_SERVICE_H */
diff --git a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Makefile.am b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Makefile.am
index e5e73407eab..39d7e8ca534 100644
--- a/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Makefile.am
+++ b/TAO/orbsvcs/Logging_Service/Basic_Logging_Service/Makefile.am
@@ -25,6 +25,7 @@ Basic_Logging_Service_CPPFLAGS = \
-I$(TAO_BUILDDIR)/orbsvcs
Basic_Logging_Service_SOURCES = \
+ Basic_Logging_Server.cpp \
Basic_Logging_Service.cpp \
Basic_Logging_Service.h
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
diff --git a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp
index 45faecd1019..de16ec08bdb 100644
--- a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp
+++ b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Server.cpp
@@ -1,40 +1,77 @@
//$Id$
#include "Notify_Logging_Service.h"
#include "ace/OS_main.h"
+#include "orbsvcs/Shutdown_Utilities.h"
+#include "tao/debug.h"
ACE_RCSID (Notify_Logging_Service,
Notify_Logging_Server,
"$Id$")
-// Driver function for the TAO Notify Service.
+
+class Logging_Svc_Shutdown
+ : public Shutdown_Functor
+{
+public:
+ Logging_Svc_Shutdown (Notify_Logging_Service& svc);
+
+ void operator() (int which_signal);
+
+private:
+ Notify_Logging_Service& svc_;
+};
+
+Logging_Svc_Shutdown::Logging_Svc_Shutdown (Notify_Logging_Service& svc)
+ : svc_ (svc)
+{
+}
+
+void
+Logging_Svc_Shutdown::operator() (int which_signal)
+{
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "Notify_Logging_Service: shutting down on signal %d\n",
+ which_signal));
+ (void) this->svc_.shutdown ();
+}
+
+// Driver function for the Notify_Logging_Service.
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
- Notify_Logging_Service notify_logging_service;
-
- ACE_DECLARE_NEW_CORBA_ENV;
+ Notify_Logging_Service service;
- if (notify_logging_service.init (argc, argv ACE_ENV_ARG_PARAMETER) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "Failed to start the Notification Logging Service.\n"),
- 1);
+ Logging_Svc_Shutdown killer (service);
+ Service_Shutdown kill_contractor (killer);
+ ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
{
- notify_logging_service.run ();
- notify_logging_service.shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ 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
{
- notify_logging_service.shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Failed to start the Notification Logging Service\n");
+ "Failed to start the Telecom Log Service.\n");
return 1;
}
ACE_ENDTRY;
- ACE_CHECK_RETURN (1);
return 0;
}
diff --git a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp
index 464d6fd2d0e..6a5dfd67b6c 100644
--- a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp
+++ b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.cpp
@@ -1,7 +1,6 @@
#include "Notify_Logging_Service.h"
#include "ace/Get_Opt.h"
#include "ace/Dynamic_Service.h"
-//#include "ace/Arg_Shifter.h"
#include "tao/debug.h"
#include "tao/IORTable/IORTable.h"
#include "orbsvcs/Notify/Service.h"
@@ -17,7 +16,8 @@ Notify_Logging_Service::Notify_Logging_Service (void)
: service_name_ (NOTIFY_KEY),
ior_file_name_ (0),
pid_file_name_ (0),
- bind_to_naming_service_ (1)
+ bind_to_naming_service_ (1),
+ nthreads_ (0)
{
// No-Op.
}
@@ -29,7 +29,7 @@ Notify_Logging_Service::~Notify_Logging_Service (void)
int
Notify_Logging_Service::init_ORB (int& argc, char *argv []
- ACE_ENV_ARG_DECL)
+ ACE_ENV_ARG_DECL)
{
this->orb_ = CORBA::ORB_init (argc,
argv,
@@ -73,7 +73,7 @@ Notify_Logging_Service::init_ORB (int& argc, char *argv []
int
Notify_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)
@@ -92,6 +92,10 @@ Notify_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;
@@ -120,7 +124,7 @@ Notify_Logging_Service::init (int argc, char *argv[]
// initalize the ORB.
if (this->init_ORB (argc, argv
ACE_ENV_ARG_PARAMETER) != 0)
- return -1;
+ return -1;
if (this->parse_args (argc, argv) == -1)
return -1;
@@ -232,7 +236,25 @@ Notify_Logging_Service::resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL)
}
int
-Notify_Logging_Service::run ()
+Notify_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
+Notify_Logging_Service::svc ()
{
ACE_DECLARE_NEW_CORBA_ENV;
ACE_TRY
@@ -242,7 +264,7 @@ Notify_Logging_Service::run ()
}
ACE_CATCHANY
{
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "run"), -1);
+ return -1;
}
ACE_ENDTRY;
@@ -252,9 +274,11 @@ Notify_Logging_Service::run ()
void
Notify_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_->reference_to_id (this->notify_factory_.in ()
+ this->poa_->reference_to_id (this->notify_log_factory_.in ()
ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
@@ -262,6 +286,7 @@ Notify_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_)
{
@@ -278,5 +303,4 @@ Notify_Logging_Service::shutdown (ACE_ENV_SINGLE_ARG_DECL)
// shutdown the ORB.
if (!CORBA::is_nil (this->orb_.in ()))
this->orb_->shutdown ();
-
}
diff --git a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h
index 5cb59012033..c6d5f3a459b 100644
--- a/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h
+++ b/TAO/orbsvcs/Logging_Service/Notify_Logging_Service/Notify_Logging_Service.h
@@ -17,9 +17,10 @@
#ifndef NOTIFY_LOGGING_SERVICE_H
#define NOTIFY_LOGGING_SERVICE_H
+#include "ace/Task.h"
#include "tao/PortableServer/PortableServer.h"
#include "orbsvcs/CosNamingC.h"
-#include "../../orbsvcs/Notify/Service.h"
+#include "orbsvcs/Notify/Service.h"
#include "orbsvcs/DsLogAdminC.h"
#include "orbsvcs/DsNotifyLogAdminC.h"
#include "orbsvcs/Log/NotifyLogFactory_i.h"
@@ -27,12 +28,13 @@
#define NOTIFY_KEY "NotifyLogFactory"
class Notify_Logging_Service
+ : public ACE_Task_Base
{
// = TITLE
- // Notify_Service
+ // Notify_Logging_Service
//
// = DESCRIPTION
- // Implementation of the Notification Service front end.
+ // Implementation of the Telecom Log Service
public:
// = Initialization and termination methods.
@@ -42,21 +44,18 @@ class Notify_Logging_Service
virtual ~Notify_Logging_Service (void);
// Destructor.
- int init (int argc, char *argv[]
- ACE_ENV_ARG_DECL);
- // Initializes the 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 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_WITH_DEFAULTS);
- // Shutdown the Service.
+ void shutdown (ACE_ENV_SINGLE_ARG_DECL);
+ // Shutdown the Telecom Service.
// Returns 0 on success, -1 on error.
- // CosNotifyChannelAdmin::EventChannelFactory_var obj;
- //
protected:
int init_ORB (int& argc, char *argv []
ACE_ENV_ARG_DECL);
@@ -68,10 +67,13 @@ protected:
void resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL);
// Resolve the naming service.
- TAO_Notify_Service* notify_service_;
+ int svc ();
+ // Run worker threads.
// = Data members
+ TAO_Notify_Service* notify_service_;
+
CosNotifyChannelAdmin::EventChannelFactory_var notify_factory_;
// The Factory.
@@ -91,12 +93,15 @@ protected:
// 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 /* NOTIFY_SERVICE_H */
+#endif /* NOTIFY_LOGGING_SERVICE_H */