summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/Naming_Service
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/orbsvcs/Naming_Service
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/orbsvcs/Naming_Service')
-rw-r--r--TAO/orbsvcs/Naming_Service/Naming_Service.cpp58
-rw-r--r--TAO/orbsvcs/Naming_Service/Naming_Service.h8
2 files changed, 59 insertions, 7 deletions
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 */