summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
authorPhil Mesnier <mesnier_p@ociweb.com>2011-04-01 15:37:48 +0000
committerPhil Mesnier <mesnier_p@ociweb.com>2011-04-01 15:37:48 +0000
commit2899d1531c15d497b42cca388d87a5e40e786ee5 (patch)
tree96be5c8d3fb667a364626e43152b9d79fae45b36 /TAO
parentd36144056a9ea67dad942c3317e63311cf9e40be (diff)
downloadATCD-2899d1531c15d497b42cca388d87a5e40e786ee5.tar.gz
Fri Apr 1 15:10:04 UTC 2011 Phil Mesnier <mesnier_p@ociweb.com>
* orbsvcs/Naming_Service/Naming_Service.h: * orbsvcs/Naming_Service/Naming_Service.cpp: Added support for multi-thread operation. In environments where 100s of clients are resolving references, the single-threaded naming service becomes a real performance bottleneck. This patch adds a -n <numthreads> command line option. Threading is achieved by using an ACE_Task to call ORB::run() on multiple threads. Default is single threaded behavior. * orbsvcs/Notify_Service/Notify_Service.cpp: Added a try/catch to the naming service resolving function. It is possible that and execption is thrown while trying to connect, and that was causing the service to crash abrupty messing up some administrative scripts. Now an error is logged and shutdown happens gracefully. * orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp: Silenced some compiler warnings that complained about an infinite loop. The test added to break will never pass, so the behavior is unchanged, but pedantic gcc compilers are now satified.
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLog27
-rw-r--r--TAO/orbsvcs/Naming_Service/Naming_Service.cpp58
-rw-r--r--TAO/orbsvcs/Naming_Service/Naming_Service.h8
-rw-r--r--TAO/orbsvcs/Notify_Service/Notify_Service.cpp32
-rw-r--r--TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp2
5 files changed, 111 insertions, 16 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index ce522c708e6..41253286bf7 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,30 @@
+Fri Apr 1 15:10:04 UTC 2011 Phil Mesnier <mesnier_p@ociweb.com>
+
+ * orbsvcs/Naming_Service/Naming_Service.h:
+ * orbsvcs/Naming_Service/Naming_Service.cpp:
+
+ Added support for multi-thread operation. In environments where
+ 100s of clients are resolving references, the single-threaded
+ naming service becomes a real performance bottleneck. This patch
+ adds a -n <numthreads> command line option. Threading is
+ achieved by using an ACE_Task to call ORB::run() on multiple
+ threads. Default is single threaded behavior.
+
+ * orbsvcs/Notify_Service/Notify_Service.cpp:
+
+ Added a try/catch to the naming service resolving function. It
+ is possible that and execption is thrown while trying to
+ connect, and that was causing the service to crash abrupty
+ messing up some administrative scripts. Now an error is logged
+ and shutdown happens gracefully.
+
+ * orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp:
+
+ Silenced some compiler warnings that complained about an
+ infinite loop. The test added to break will never pass, so the
+ behavior is unchanged, but pedantic gcc compilers are now
+ satified.
+
Thu Mar 31 11:34:08 UTC 2011 Johnny Willemsen <jwillemsen@remedy.nl>
* TAO_IDL/tao_idl.mpc:
diff --git a/TAO/orbsvcs/Naming_Service/Naming_Service.cpp b/TAO/orbsvcs/Naming_Service/Naming_Service.cpp
index 6631c888b9e..bb1a7fe56d7 100644
--- a/TAO/orbsvcs/Naming_Service/Naming_Service.cpp
+++ b/TAO/orbsvcs/Naming_Service/Naming_Service.cpp
@@ -5,16 +5,19 @@
#include "orbsvcs/Daemon_Utilities.h"
#include "ace/Get_Opt.h"
#include "ace/Argv_Type_Converter.h"
+#include "ace/Task.h"
// Default Constructor.
TAO_Naming_Service::TAO_Naming_Service (void)
- : time_ (0)
+ : time_ (0),
+ num_threads_ (1)
{
}
// Constructor taking command-line arguments.
TAO_Naming_Service::TAO_Naming_Service (int argc, ACE_TCHAR* argv[])
- : time_ (0)
+ : time_ (0),
+ num_threads_ (1)
{
this->init (argc, argv);
}
@@ -59,7 +62,7 @@ TAO_Naming_Service::init (int argc, ACE_TCHAR* argv[])
int
TAO_Naming_Service::parse_args (int &argc, ACE_TCHAR* argv[])
{
- ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("-t:"));
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("-t:n:"));
int c;
while ((c = get_opts ()) != -1)
@@ -82,6 +85,23 @@ TAO_Naming_Service::parse_args (int &argc, ACE_TCHAR* argv[])
argc = argc - 2;
break;
}
+ case 'n':
+ {
+ int const nt = ACE_OS::atoi (get_opts.opt_arg ());
+ if (nt >= 1)
+ this->num_threads_ = nt;
+
+ // Remove the option '-n' from argv []
+ // to avoid any confusion that might result.
+ for (int i = get_opts.opt_ind (); i != argc; ++i)
+ argv [i-2 ] = argv [i];
+
+ // Decrement the value of argc to reflect the removal
+ // of '-n' option.
+ argc = argc - 2;
+ break;
+ }
+
case '?':
default:
// Don't do anything. The TAO_Naming_Server::parse_args ()
@@ -93,9 +113,17 @@ TAO_Naming_Service::parse_args (int &argc, ACE_TCHAR* argv[])
}
// Run the ORB event loop.
-int
-TAO_Naming_Service::run (void)
+
+class ORB_Runner : public ACE_Task_Base
{
+public:
+ ORB_Runner (CORBA::ORB_ptr o, long t)
+ : orb_(CORBA::ORB::_duplicate (o)),
+ time_(t)
+ {}
+
+ int svc (void)
+ {
if (!CORBA::is_nil (orb_.in ()))
{
if (time_ == 0)
@@ -110,6 +138,26 @@ TAO_Naming_Service::run (void)
}
return 0;
+ }
+
+private:
+ CORBA::ORB_var orb_;
+ long time_;
+};
+
+int
+TAO_Naming_Service::run (void)
+{
+ ORB_Runner runner (this->orb_.in(), time_);
+ if (this->num_threads_ == 1)
+ return runner.svc();
+ else
+ {
+ runner.activate ( THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED,
+ this->num_threads_);
+ runner.wait();
+ }
+ return 0;
}
void
diff --git a/TAO/orbsvcs/Naming_Service/Naming_Service.h b/TAO/orbsvcs/Naming_Service/Naming_Service.h
index 5503c9648cf..71a2eb6e211 100644
--- a/TAO/orbsvcs/Naming_Service/Naming_Service.h
+++ b/TAO/orbsvcs/Naming_Service/Naming_Service.h
@@ -1,5 +1,6 @@
+// -*- C++ -*-
-//=============================================================================
+//==========================================================================
/**
* @file Naming_Service.h
*
@@ -10,7 +11,7 @@
*
* @author Nagarajan Surendran (naga@cs.wustl.edu) Marina Spivak <marina@cs.wustl.edu>
*/
-//=============================================================================
+//==========================================================================
#ifndef TAO_NAMING_SERVICE_H
@@ -66,6 +67,9 @@ protected:
/// After how long the server should stop listening to requests (in
/// seconds).
long time_;
+
+ /// Number of threads for running the ORB. Default is 1
+ int num_threads_;
};
#endif /* TAO_NAMING_SERVICE_H */
diff --git a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp
index 776e1f32475..7e766b5cacc 100644
--- a/TAO/orbsvcs/Notify_Service/Notify_Service.cpp
+++ b/TAO/orbsvcs/Notify_Service/Notify_Service.cpp
@@ -338,17 +338,31 @@ TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[])
int
TAO_Notify_Service_Driver::resolve_naming_service (void)
{
- CORBA::Object_var naming_obj =
- this->orb_->resolve_initial_references ("NameService");
-
- // Need to check return value for errors.
- if (CORBA::is_nil (naming_obj.in ()))
- ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to resolve the Naming Service.\n"),
- -1);
+ try
+ {
+ CORBA::Object_var naming_obj =
+ this->orb_->resolve_initial_references ("NameService");
- this->naming_ = CosNaming::NamingContextExt::_narrow (naming_obj.in ());
+ // Need to check return value for errors.
+ if (CORBA::is_nil (naming_obj.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to resolve the Naming Service.\n"),
+ -1);
+ this->naming_ = CosNaming::NamingContextExt::_narrow (naming_obj.in ());
+ }
+ catch (CORBA::Exception &ex)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to resolve the Naming Service.\n"),
+ -1);
+ }
+ catch (...)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to resolve the Naming Service.\n"),
+ -1);
+ }
return 0;
}
diff --git a/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp b/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp
index cde5ca524e4..c6ad51dd4e8 100644
--- a/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp
+++ b/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp
@@ -301,6 +301,8 @@ int BasicLog_Test::write_records (CORBA::ULongLong numberOfRecords)
CORBA::String_var t(str.c_str ());
record[0] <<= t.in ();
basicLog_->write_records(record);
+ if (l == 0)
+ break; // silence an 'infinite loop' warning
}
}
else