diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:11 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:11 +0000 |
commit | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (patch) | |
tree | da50d054f9c761c3f6a5923f6979e93306c56d68 /TAO/orbsvcs/Time_Service | |
parent | 0e555b9150d38e3b3473ba325b56db2642e6352b (diff) | |
download | ATCD-6b846cf03c0bcbd8c276cb0af61a181e5f98eaae.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/orbsvcs/Time_Service')
-rw-r--r-- | TAO/orbsvcs/Time_Service/.cvsignore | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Clerk_i.cpp | 562 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Clerk_i.h | 139 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Makefile.am | 80 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/README | 96 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Server_i.cpp | 286 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Server_i.h | 89 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Time_Service.mpc | 19 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp | 44 | ||||
-rw-r--r-- | TAO/orbsvcs/Time_Service/Time_Service_Server.cpp | 45 |
10 files changed, 0 insertions, 1362 deletions
diff --git a/TAO/orbsvcs/Time_Service/.cvsignore b/TAO/orbsvcs/Time_Service/.cvsignore deleted file mode 100644 index 8c4ee3c5b18..00000000000 --- a/TAO/orbsvcs/Time_Service/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Time_Service_Clerk -Time_Service_Server diff --git a/TAO/orbsvcs/Time_Service/Clerk_i.cpp b/TAO/orbsvcs/Time_Service/Clerk_i.cpp deleted file mode 100644 index ab42e2787f7..00000000000 --- a/TAO/orbsvcs/Time_Service/Clerk_i.cpp +++ /dev/null @@ -1,562 +0,0 @@ -// $Id$ - -#include "Clerk_i.h" -#include "tao/debug.h" -#include "ace/Read_Buffer.h" -#include "ace/Get_Opt.h" -#include "ace/Argv_Type_Converter.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_string.h" -#include "ace/OS_NS_fcntl.h" -#include "ace/os_include/os_netdb.h" - -ACE_RCSID(Time_Service, Clerk_i, "$Id$") - -// Constructor. - -Clerk_i::Clerk_i (void) - : ior_output_file_ (0), - timer_value_ (3), - timer_value_usecs_ (0), - server_ (Clerk_i::DEFAULT_SERVER_COUNT), - ior_fp_ (0) -{ - // no-op. -} - -// Destructor. - -Clerk_i::~Clerk_i (void) -{ - // no-op. -} - -// Reads the Time Service Server iors from a file instead of using a -// naming service. - -int -Clerk_i::read_ior (const ACE_TCHAR* filename) -{ - // Open the file for reading. - ACE_HANDLE f_handle = ACE_OS::open (filename, 0); - - if (f_handle == ACE_INVALID_HANDLE) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[CLIENT] Process/Thread Id : (%P/%t) Unable to open %s for writing: %p\n"), - filename), - -1); - else - this->ior_fp_ = 1; - - ACE_Read_Buffer ior_buffer (f_handle); - - char *data = ior_buffer.read (EOF,'\n','\n'); - if (data == 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[CLIENT] Process/Thread Id : (%P/%t) Unable to read ior: %p\n")), - -1); - - int result = 0; - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - for (char *str = ACE_OS::strtok (data, "\n"); - str != 0 ; - str = ACE_OS::strtok (0, "\n")) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("iors -> |%s|\n"), - ACE_TEXT_CHAR_TO_TCHAR(str))); - - CORBA::Object_var objref = - this->orb_->string_to_object (str - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Return if the server reference is nil. - if (CORBA::is_nil (objref.in ())) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT("IOR for the server is Null\n"))); - result = -1; - break; - } - - CosTime::TimeService_ptr server = - CosTime::TimeService::_narrow (objref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->insert_server (server); - } - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, ACE_TEXT("Exception")); - } - ACE_ENDTRY; - - ACE_OS::close (f_handle); - ior_buffer.alloc ()->free (data); - - return result; -} - -// Parse the command-line arguments and set options. - -int -Clerk_i::parse_args (int argc, - ACE_TCHAR* argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("dt:u:f:o:")); - - int c, result; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'd': // debug flag. - TAO_debug_level++; - break; - - case 't': // time in secs after which the clerk should update time. - this->timer_value_ = ACE_OS::atoi (get_opts.opt_arg ()); - break; - - case 'u': - // time in usecs after which the clerk should update time. - // Continues the precision of the -t option. - this->timer_value_usecs_ = ACE_OS::atoi (get_opts.opt_arg ()); - break; - - case 'f': // read the server IORs from a file. - result = this->read_ior (get_opts.opt_arg ()); - - if (result < 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[CLERK] Process/Thread Id : (%P/%t) Unable to read ior from %s : %p\n"), - get_opts.opt_arg ()), - -1); - break; - - case 'o': // output the Clerk IOR to a file. - this->ior_output_file_ = - ACE_OS::fopen (get_opts.opt_arg (), ACE_TEXT("w")); - - if (this->ior_output_file_ == 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t)Unable to open %s for writing: %\n"), - get_opts.opt_arg ()), -1); - break; - - case '?': // display help for use of the server. - /* FALLTHRU */ - default: - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t)") - ACE_TEXT("usage: %s") - ACE_TEXT(" [-d]") - ACE_TEXT(" [-t] <Timer value inn Secs>") - ACE_TEXT(" [-u] <Timer value in uSecs>") - ACE_TEXT(" [-f] <ior_input_file>") - ACE_TEXT(" [-o] <ior_output_file>") - ACE_TEXT("\n"), - argv[0]), - 1); - } - - // Indicates successful parsing of command line. - return 0; -} - -// Get a reference to the Server Naming context and the first IOR. -// The iterator returned from this is used to get the next n IORs. - -int -Clerk_i::get_first_IOR (void) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - char host_name[MAXHOSTNAMELEN]; - - ACE_OS::hostname (host_name, - MAXHOSTNAMELEN); - CosNaming::BindingList_var bindings_list; - CosNaming::BindingIterator_var iter; - - // Construct the server context name. - CosNaming::Name server_context_name; - server_context_name.length (1); - server_context_name[0].id = CORBA::string_dup ("ServerContext"); - - // Resolve name. - CORBA::Object_var temp_object = - this->naming_client_->resolve (server_context_name - ACE_ENV_ARG_PARAMETER); - - ACE_TRY_CHECK; - - CosNaming::NamingContext_var server_context = - CosNaming::NamingContext::_narrow (temp_object.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (server_context.in ())) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("TAO_Time_Service_Clerk::get_server_IORs:") - ACE_TEXT("No Active Servers in the Network\n"))); - - // Get the first element and an iterator over the other - // elements. - server_context->list (1, - bindings_list.out (), - iter.out ()); - CosNaming::Name server_name; - server_name.length (1); - server_name[0].id = bindings_list[0u].binding_name[0].id; - - temp_object = - server_context->resolve (server_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosTime::TimeService_var obj = - CosTime::TimeService::_narrow (temp_object.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (obj.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[CLERK] Process/Thread Id : (%P/%t) Unable to Resolve ") - ACE_TEXT("Server Reference\n")), - -1); - - // Insert the first server IOR into the unbounded set of server - // IORs. - - this->insert_server (obj.in ()); - - // Iterate over the server context to get the next N IORs. - if (next_n_IORs (iter, - server_context) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[CLERK] Process/Thread Id : (%P/%t) Unable to get next N IORs ")), - -1);; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, ACE_TEXT("Exception")); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -// Get the next n IORs of the time servers active in the Network and -// registered with the Naming Service. This is done by iterating over -// the naming context. - -int -Clerk_i::next_n_IORs (CosNaming::BindingIterator_var iter, - CosNaming::NamingContext_var server_context) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - CosNaming::Binding_var binding; - - if (!CORBA::is_nil (iter.in ())) - { - while (iter->next_one (binding.out () - ACE_ENV_ARG_PARAMETER)) - { - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("Getting IOR of the server: %s\n\n"), - ACE_TEXT_CHAR_TO_TCHAR(binding->binding_name[0].id.in ()))); - - CosNaming::Name server_name; - server_name.length (1); - server_name[0].id = binding->binding_name[0].id; - - CORBA::Object_var temp_object = - server_context->resolve (server_name - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosTime::TimeService_ptr server = - CosTime::TimeService::_narrow (temp_object.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->insert_server (server); - } - - ACE_TRY_CHECK; - } - - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT("Unexpected exception in next_n_IORs\n")); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -// Initialise the Naming Service. - -int -Clerk_i::init_naming_service () -{ - // Initialize the Naming Client. - return (this->naming_client_.init (this->orb_.in ())); -} - -// Create an instance of the clerk with appropriate parameters. - -int -Clerk_i::create_clerk (void) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - - // Create a new clerk object. Pass it the timer value, the set - // of server IORs and the no. of servers. - ACE_NEW_RETURN (this->time_service_clerk_impl_, - TAO_Time_Service_Clerk (this->timer_value_, - this->timer_value_usecs_, - this->server_), - 0); - - // Generate IOR of the Clerk and register with POA. - this->time_service_clerk_ = - this->time_service_clerk_impl_->_this (); - - // Convert the clerk reference to a string. - CORBA::String_var objref_clerk = - this->orb_->object_to_string (this->time_service_clerk_.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Print the clerk IOR on the console. - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t) The Time Service CLERK IOR is: <%s>\n"), - ACE_TEXT_CHAR_TO_TCHAR(objref_clerk.in ()))); - - // Print the Time Service clerk IOR to a file. - if (this->ior_output_file_) - { - ACE_OS::fprintf (this->ior_output_file_, - "%s", - objref_clerk.in ()); - ACE_OS::fclose (this->ior_output_file_); - } - - // Register the clerk implementation with the Interface - // Repository. init_IR(); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, ACE_TEXT("Exception")); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -// Binds the clerk in the context ClerkContext with the name -// Clerk:<hostname>. - -int -Clerk_i::register_clerk (void) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Bind the Clerk in its appropriate Context. - - CosNaming::Name clerk_context_name; - clerk_context_name.length (1); - clerk_context_name[0].id = CORBA::string_dup ("ClerkContext"); - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY_EX(bind_new_context) - { - CosNaming::NamingContext_var clerk_context = - this->naming_client_->bind_new_context(clerk_context_name); - ACE_TRY_CHECK_EX(bind_new_context); - } - ACE_CATCH(CosNaming::NamingContext::AlreadyBound, ex) - { - // OK, naming context already exists. - } - ACE_ENDTRY; - - char host_name[MAXHOSTNAMELEN]; - char clerk_mc_name[MAXHOSTNAMELEN]; - ACE_OS::hostname (host_name, MAXHOSTNAMELEN); - - //CosNaming::Name clerk_name (clerk_context_name); - CosNaming::Name clerk_name; - clerk_name.length (2); - - ACE_OS::strcpy (clerk_mc_name, "Clerk:"); - ACE_OS::strcat (clerk_mc_name, host_name); - - clerk_name[0].id = CORBA::string_dup ("ClerkContext"); - clerk_name[1].id = CORBA::string_dup (clerk_mc_name); - - this->naming_client_->rebind (clerk_name, - this->time_service_clerk_.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT("(%P|%t) Exception from init_naming_service ()\n")); - } - ACE_ENDTRY; - - return 0; -} - -// Initialize the Clerk. - -int -Clerk_i::init (int argc, - ACE_TCHAR *argv[] - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - // Make a copy of command line parameter. - ACE_Argv_Type_Converter command(argc, argv); - - // Set the size of the Server IOR Array. - this->server_.max_size (10); - this->server_.size (0); - - // Call the init of <TAO_ORB_Manager> to initialize the ORB and - // create a child POA under the root POA. - - - this->orb_manager_.init (command.get_argc(), - command.get_ASCII_argv() - ACE_ENV_ARG_PARAMETER); - - ACE_TRY_CHECK; - - if (this->orb_manager_.init_child_poa (command.get_argc(), - command.get_ASCII_argv(), - "child_poa" - ACE_ENV_ARG_PARAMETER) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("%p\n"), - ACE_TEXT("init_child_poa")), - -1); - ACE_TRY_CHECK; - - // Get the ORB. - this->orb_ = this->orb_manager_.orb (); - - // Parse commandline arguments. - if (this->parse_args (command.get_argc(), command.get_TCHAR_argv()) !=0 ) - return -1; - - // If IOR file has not been specified then try the Naming - // Service. - - if (!this->ior_fp_) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("IOR file not specified. Using the Naming Service instead\n"))); - - // Initialize the Naming Service. - if (this->init_naming_service () !=0 ) - return -1; - - // Get a reference to the Server Naming context and the - // first IOR. - if (this->get_first_IOR () != 0) - return -1; - - } - - // Create an instance of the Clerk. - if (this->create_clerk () != 0) - return -1; - - - // Register the clerk with the Naming Service. - if (this->ior_fp_ == 0) - { - if (this->register_clerk () != 0) - return -1; - } - - // Close the open file handler. - // ACE_OS::fclose (this->ior_fp_); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT("(%P|%t) Exception in Clerk_i::init ()\n")); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -int -Clerk_i::run (ACE_ENV_SINGLE_ARG_DECL) -{ - ACE_TRY - { - // Run the main event loop for the ORB. - int r = this->orb_manager_.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (r == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t) Clerk_i::run")), - -1); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT("(%P|%t) Exception in Clerk_i::run ()\n")); - } - ACE_ENDTRY; - - return 0; -} - -void -Clerk_i::insert_server (CosTime::TimeService_ptr server) -{ - // We duplicate the capacity of the Array. - size_t s = this->server_.size (); - - if (this->server_.max_size () == s) - this->server_.max_size (2 * s); - - this->server_[s] = - CosTime::TimeService::_duplicate (server); - - this->server_.size (s + 1); -} diff --git a/TAO/orbsvcs/Time_Service/Clerk_i.h b/TAO/orbsvcs/Time_Service/Clerk_i.h deleted file mode 100644 index 9f3f9283837..00000000000 --- a/TAO/orbsvcs/Time_Service/Clerk_i.h +++ /dev/null @@ -1,139 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO/orbsvcs/Time_Service -// -// = FILENAME -// Clerk_i.h -// -// = AUTHOR -// Vishal Kachroo <vishal@cs.wustl.edu> -// -// ============================================================================ - -#ifndef CLERK_I_H -#define CLERK_I_H - -#include "ace/Get_Opt.h" -#include "ace/Log_Msg.h" -#include "tao/Utils/ORB_Manager.h" -#include "orbsvcs/CosNamingC.h" -#include "orbsvcs/Naming/Naming_Client.h" -#include "orbsvcs/Time/TAO_Time_Service_Clerk.h" - -class Clerk_i -{ - // = TITLE - // CORBA Time Clerk implementation. - // - // = DESCRIPTION - // A CORBA server that initializes the TimeService clerk - // implementation and the ORB. -public: - - enum { - // Pre-allocate slots for this many servers. The capacity grows on - // demand. - DEFAULT_SERVER_COUNT = 8 - }; - - // = Initialization and termination methods. - Clerk_i (void); - // Constructor. - - ~Clerk_i (void); - // Destructor. - - typedef ACE_Array_Base<CosTime::TimeService_var> IORS; - // Set of available Time servers. - - int init (int argc, - ACE_TCHAR *argv[] - ACE_ENV_ARG_DECL); - // Initialize the Clerk state - parsing arguments and waiting. - - int run (ACE_ENV_SINGLE_ARG_DECL); - // Run the orb. - -private: - void insert_server (CosTime::TimeService_ptr server); - // Insert a server in the internal data structure (servers_). - -private: - - int read_ior (const ACE_TCHAR* filename); - // Read the server IORs from a file instead of using a naming - // service. - - int parse_args (int argc, - ACE_TCHAR* argv[]); - // Parses the commandline arguments. - - TAO_ORB_Manager orb_manager_; - // The ORB manager. - - FILE *ior_output_file_; - // File where the IOR of the Clerk object is stored. - - int init_naming_service (); - // Initialises the name client and registers the <TimeService> Clerk - // object with it. - - int create_clerk (void); - // Create an instance of the clerk to use. - - int register_clerk (void); - // Bind the clerk in the appropriate context in the Naming Service. - - int init_IR (void); - // Initialise the Interface Repository and register the clerk - // implementation with it. - - int get_first_IOR (void); - // Get the reference to the server naming context and the first - // server IOR. - - int next_n_IORs (CosNaming::BindingIterator_var iter, - CosNaming::NamingContext_var server_context); - // Iterate over the given server context to get the rest of the - // server IORs. - - TAO_Naming_Client naming_client_; - // An instance of the name server used for registering the - // <TimeService Clerk> object. The same instance is used by the - // Clerk to periodically iterate through the Server Naming Context - // and get IORs of the available servers. - - TAO_Time_Service_Clerk *time_service_clerk_impl_; - // Implementation of the <TimeService> Clerk object. - - CosTime::TimeService_var time_service_clerk_; - // Reference of the time service clerk. - - CosNaming::NamingContext_var time_service_clerk_context_; - // Naming context for the Naming Service. - - CORBA::ORB_var orb_; - // My orb. - - int timer_value_ ; - // Clerk seeks time periodically after this interval in secs. from the - // servers in the network. - - int timer_value_usecs_; - // Continues the precision of timer_value_ in microseconds. - - // IR_Helper *ir_helper_; - // Helper class for using the IR. - - IORS server_; - // The unbounded set of server IORS. - - int ior_fp_; - // Read IORs from a file. -}; - -#endif /* CLERK_I_H */ diff --git a/TAO/orbsvcs/Time_Service/Makefile.am b/TAO/orbsvcs/Time_Service/Makefile.am deleted file mode 100644 index 474b5debdad..00000000000 --- a/TAO/orbsvcs/Time_Service/Makefile.am +++ /dev/null @@ -1,80 +0,0 @@ -## 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_ROOT = $(top_srcdir) - -## Makefile.Time_Service_Clerk.am - -bin_PROGRAMS = Time_Service_Clerk - -Time_Service_Clerk_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -Time_Service_Clerk_SOURCES = \ - Clerk_i.cpp \ - Time_Service_Clerk.cpp \ - Clerk_i.h - -Time_Service_Clerk_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosTime.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -## Makefile.Time_Service_Server.am - -bin_PROGRAMS += Time_Service_Server - -Time_Service_Server_CPPFLAGS = \ - -I$(ACE_ROOT) \ - -I$(ACE_BUILDDIR) \ - -I$(TAO_ROOT) \ - -I$(TAO_BUILDDIR) \ - -I$(TAO_ROOT)/orbsvcs \ - -I$(TAO_BUILDDIR)/orbsvcs - -Time_Service_Server_SOURCES = \ - Server_i.cpp \ - Time_Service_Server.cpp \ - Server_i.h - -Time_Service_Server_LDADD = \ - $(TAO_BUILDDIR)/tao/libTAO_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PI.la \ - $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosTime.la \ - $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_Svc_Utils.la \ - $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ - $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ - $(TAO_BUILDDIR)/tao/libTAO.la \ - $(ACE_BUILDDIR)/ace/libACE.la - -## 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/Time_Service/README b/TAO/orbsvcs/Time_Service/README deleted file mode 100644 index 2ca9f457b45..00000000000 --- a/TAO/orbsvcs/Time_Service/README +++ /dev/null @@ -1,96 +0,0 @@ -$Id $ - -============================ TAO Time Service============================== - -This is a complete implementation of the CORBA time service spec. The -service offers a globally synchronized time to a requesting -client. The Time Service interface has been implemented as two servants: -the clerk and the server. Clients who wish to use the service talk to -clerks and the clerks in turn keep their time synchronized -globally. The clerks do this by talking to the servers running on -different machines. - -There needs to be at least one time server running in the network. The Clerks -update their time periodically from the servers. The servers and clerks -export their IORs through the - * Naming Service. - * Files -The Servers can also be activated on demand by the Clerks if they have been -registered with an Implementation Repository. - -If Naming Service is being used the clerks and servers are registered in -different Naming Contexts as : - -For the clerks : ClerkContext->Clerk:<local_host_name> -For the server : ServerContext->Server:<local_host_name> - -The machine name is included to make the object name unique and distinguish -between the various servers and clerks. - -A sample run of the TimeService can be done as follows : - -* Using the Naming Service : - -1. Run TAO/orbsvcs/Time_Service/server on different machines. -2. Run TAO/orbsvcs/Time_Service/clerk -t 5 on some machines. -3. Run the TAO/orbsvcs/tests/Time/client on one of the machines where a clerk - is running. - -* Using Files : - -1. Run TAO/orbsvcs/Time_Service/server -o server_ior on different machines. -2. Run TAO/orbsvcs/Time_Service/clerk -t 5 -f server_ior -o clerk_ior on some - machines. -3. Run the TAO/orbsvcs/tests/Time/client -f clerk_ior on one of the machines - where a clerk is running. - -* Using the Implementation Repository : - -1. Run the Implementation Repository service as : - - TAO/orbsvcs/Time_Service> ../ImplRepo_Service/ImplRepo_Service -ORBsvcconf - implrepo.conf -ORBobjrefstyle url -d 1 - -2. Run the Server as - - TAO/orbsvcs/Time_Service> server -o server_ior -r -i - -3. Run the Clerk as - - TAO/orbsvcs/Time_Service> clerk -f server_ior -t 5 -o clerk_ior - -4. Run the client as - - TAO/orbsvcs/tests/Time/client -f clerk_ior - -Algorithms ----------- - -Currently, updating the system time involves taking the average of all -the times received from the servers. This can be extended by using a -more elaborate distributed time synchronization algorithm. - -Version Updates : (10th March, 1999) ------------------ - -The TAO Time Service has been updated to include the timezone information -in the Universal Time Object. This object now also has an inaccuracy estimate -in it. The inaccuracy is a measure of the skew in the synchronization of -the clerks time. It is the difference between the highest and the lowest times -from the servers that the clerk synchronizes its time with. The high-inaccuracy -and the low-inaccuracy fields are also being calculated from the inaccuracy as -follows : - - Inaccuracy 64-bits - |------------------------------------| - | | inacchi | inacclo | - |------------------------------------| - 16-bits 16-bits 32-bits - -Thanks to Brian Dance <Brian_Dance@UECCS.co.uk> for reporting this. - -Future Versions of the service could include other measures of inaccuracy too, -say the one based on precision in the time reported by servers. In this case -the servers will have to supply an estimate of inaccuracy in their times. - - diff --git a/TAO/orbsvcs/Time_Service/Server_i.cpp b/TAO/orbsvcs/Time_Service/Server_i.cpp deleted file mode 100644 index b1c846e398f..00000000000 --- a/TAO/orbsvcs/Time_Service/Server_i.cpp +++ /dev/null @@ -1,286 +0,0 @@ -// $Id$ - -#include "Server_i.h" -#include "tao/debug.h" -#include "ace/Get_Opt.h" -#include "ace/Argv_Type_Converter.h" -#include "ace/OS_NS_stdio.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_string.h" -#include "ace/os_include/os_netdb.h" - -ACE_RCSID(Time_Service, Server_i, "$Id$") - -// Constructor. -Server_i::Server_i (void) - : ior_output_file_ (0) -{ - // no-op. -} - -// Destructor. - -Server_i::~Server_i (void) -{ - // no-op. -} - -// Parse the command-line arguments and set options. - -int -Server_i::parse_args (int argc, - ACE_TCHAR* argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("do:")); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'd': // debug flag. - TAO_debug_level++; - break; - case 'o': // output the IOR to a file. - this->ior_output_file_ = - ACE_OS::fopen (get_opts.opt_arg (), ACE_TEXT("a")); - - if (this->ior_output_file_ == 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t)Unable to open %s for writing: %p\n"), - get_opts.opt_arg ()), -1); - break; - case '?': // display help for use of the server. - default: - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t)") - ACE_TEXT("usage: %s") - ACE_TEXT(" [-d]") - ACE_TEXT(" [-o] <ior_output_file>") - ACE_TEXT("\n"), - argv[0]), - 1); - } - - // Indicates successful parsing of command line. - return 0; -} - -// Initialise the Naming Service and register the TimeService Object -// with it. - -int -Server_i::init_naming_service () -{ - // Initialize the Naming Client. - return (this->naming_client_.init (this->orb_.in ())); -} - -// Create a new time server object and register it with the child POA. -// Print the IOR of the registered server on the console and in a file. - -int -Server_i::create_server (void) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - - // Create a new server object. - ACE_NEW_RETURN (this->time_service_server_impl_, - TAO_Time_Service_Server, - 0); - - // Register a servant with the child poa. - CORBA::String_var server_str = - this->orb_manager_.activate_under_child_poa ("server", - this->time_service_server_impl_ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - PortableServer::ObjectId_var id = - PortableServer::string_to_ObjectId ("server"); - - CORBA::Object_var server_ref = - this->orb_manager_.child_poa ()->id_to_reference (id.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->time_service_server_ = CosTime::TimeService::_narrow (server_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // All this !! just to register a servant with the child poa. - // Instead of using _this (). - - //Convert the server reference to a string. - - CORBA::String_var objref_server = - this->orb_->object_to_string (server_ref.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // Print the server IOR on the console. - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t) The Time Service ") - ACE_TEXT("SERVER IOR: <%s>\n"), - ACE_TEXT_CHAR_TO_TCHAR(objref_server.in ()))); - - // Print the IOR to a file. - - if (this->ior_output_file_) - { - // Write the IOR to the file. - ACE_OS::fprintf (this->ior_output_file_, - "%s\n", - objref_server.in ()); - ACE_OS::fclose (this->ior_output_file_); - } - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT("Exception in Server_i::create_server ()")); - return -1; - } - ACE_ENDTRY; - return 0; -} - - -// Bind the Server in the context 'ServerContext' with the name -// 'Server:<hostname>'. - -int -Server_i::register_server (void) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - CosNaming::Name server_context_name; - server_context_name.length (1); - server_context_name[0].id = CORBA::string_dup ("ServerContext"); - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY_EX(bind_new_context) - { - CosNaming::NamingContext_var server_context = - this->naming_client_->bind_new_context(server_context_name); - ACE_TRY_CHECK_EX(bind_new_context); - } - ACE_CATCH (CosNaming::NamingContext::AlreadyBound, ex) - { - // OK, naming context already exists. - } - ACE_ENDTRY; - - char host_name[MAXHOSTNAMELEN]; - char server_mc_name[MAXHOSTNAMELEN]; - ACE_OS::hostname (host_name,MAXHOSTNAMELEN); - - CosNaming::Name server_name (server_context_name); - - server_name.length (2); - ACE_OS::strcpy (server_mc_name, "Server:"); - ACE_OS::strcat (server_mc_name, host_name); - server_name[1].id = CORBA::string_dup (server_mc_name); - - // Bind the compound name (ServerContext(Server:<hostname>)) - // to the Naming Server. - - this->naming_client_->rebind (server_name, - this->time_service_server_.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("Binding ServerContext -> %s\n"), - ACE_TEXT_CHAR_TO_TCHAR(server_name[1].id.in ()))); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT("(%P|%t) Exception from Register Server ()\n")); - return -1; - } - ACE_ENDTRY; - - return 0; -} - -// Initialize the server. If a filename is specified with the -f -// commandline option, the server writes its IOR to the file besides -// binding itself with the Naming Service. - -int -Server_i::init (int argc, - ACE_TCHAR *argv[] - ACE_ENV_ARG_DECL) -{ - ACE_TRY - { - // Make a copy of command line parameter. - ACE_Argv_Type_Converter command(argc, argv); - - // Call the init of <TAO_ORB_Manager> to initialize the ORB and - // create a child POA under the root POA. - - int retval = this->orb_manager_.init_child_poa ( - command.get_argc(), - command.get_ASCII_argv(), - "time_server" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (retval == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("%p\n"), - ACE_TEXT("init_child_poa")), - -1); - - // Activate the POA Manager. - this->orb_manager_.activate_poa_manager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - int result = this->parse_args (command.get_argc(), command.get_TCHAR_argv()); - - if (result != 0) - return result; - - // Get the orb. - this->orb_ = this->orb_manager_.orb (); - - // Initialize Naming Service. - this->init_naming_service (); - - // Create the server object. - this->create_server (); - - // Register the server object with the Naming Service. - this->register_server (); - - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, ACE_TEXT("Exception:")); - return -1; - } - ACE_ENDTRY; - - return 0; -} - - -// Run the event loop for ORB. - -int -Server_i::run (ACE_ENV_SINGLE_ARG_DECL) -{ - int retval = this->orb_manager_.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - if (retval == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT("[SERVER] Process/Thread Id : (%P/%t) Server_i::run")), - -1); - return 0; -} diff --git a/TAO/orbsvcs/Time_Service/Server_i.h b/TAO/orbsvcs/Time_Service/Server_i.h deleted file mode 100644 index 7889d95e37b..00000000000 --- a/TAO/orbsvcs/Time_Service/Server_i.h +++ /dev/null @@ -1,89 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO/orbsvcs/Time_Service -// -// = FILENAME -// Server_i.h -// -// = AUTHOR -// Vishal Kachroo <vishal@cs.wustl.edu> -// -// ============================================================================ - -#ifndef SERVER_I_H -#define SERVER_I_H - -#include "ace/Get_Opt.h" -#include "ace/Log_Msg.h" -#include "tao/Utils/ORB_Manager.h" -#include "orbsvcs/CosNamingC.h" -#include "orbsvcs/Naming/Naming_Client.h" -#include "orbsvcs/Time/TAO_Time_Service_Server.h" - -class Server_i -{ - // = TITLE - // CORBA Server implementation. - // - // = DESCRIPTION - // A CORBA server that initializes the <TimeService Server> - // servant implementation and the ORB. -public: - // = Initialization and termination methods. - Server_i (void); - // Constructor. - - ~Server_i (void); - // Destructor. - - int init (int argc, - ACE_TCHAR *argv[] - ACE_ENV_ARG_DECL); - // Initialize the Server state. - - int run (ACE_ENV_SINGLE_ARG_DECL); - // Run the orb. - - int init_naming_service (); - // Initialises the name client. - - int create_server (void); - // Create the time server object. - - int register_server (void); - // Register the time server object with the Naming Service. - - int parse_args (int argc, - ACE_TCHAR* argv[]); - // Parse the commandline arguments. - -private: - - CORBA::ORB_var orb_; - // My orb. - - TAO_ORB_Manager orb_manager_; - // The ORB manager. - - FILE *ior_output_file_; - // File where the IOR of the Clerk object is stored. - - TAO_Naming_Client naming_client_; - // An instance of the name server used for registering the - // <TimeService Server> object. - - TAO_Time_Service_Server *time_service_server_impl_; - // Implementation of the <TimeService> Server object. - - CosTime::TimeService_var time_service_server_; - // Reference of the time server. - - CosNaming::NamingContext_var time_service_server_context_; - // Naming context for the Naming Service. -}; - -#endif /* SERVER_I_H */ diff --git a/TAO/orbsvcs/Time_Service/Time_Service.mpc b/TAO/orbsvcs/Time_Service/Time_Service.mpc deleted file mode 100644 index b7342a0a223..00000000000 --- a/TAO/orbsvcs/Time_Service/Time_Service.mpc +++ /dev/null @@ -1,19 +0,0 @@ -// -*- MPC -*- -// $Id$ - -project(Time_Service_Server) : orbsvcsexe, core, time, naming, utils { - exename = Time_Service_Server - Source_Files { - Server_i.cpp - Time_Service_Server.cpp - } -} - -project(Time_Service_Clerk) : orbsvcsexe, core, time, naming, utils { - exename = Time_Service_Clerk - Source_Files { - Clerk_i.cpp - Time_Service_Clerk.cpp - } -} - diff --git a/TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp b/TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp deleted file mode 100644 index 97d8d30a3db..00000000000 --- a/TAO/orbsvcs/Time_Service/Time_Service_Clerk.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ - -#include "Clerk_i.h" -#include "ace/OS_main.h" - -ACE_RCSID(TimeService, Time_Service_Clerk, "$Id$") - -// This is the main driver program for the Time Service clerk. - -int -ACE_TMAIN (int argc, ACE_TCHAR* argv[]) -{ - Clerk_i clerk; - - ACE_DEBUG ((LM_DEBUG, - "[SERVER] Process/Thread Id : (%P/%t) Time Service clerk\n")); - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - int r = clerk.init (argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (r == -1) - return 1; - else - { - clerk.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - } - ACE_CATCH (CORBA::SystemException, sysex) - { - ACE_PRINT_EXCEPTION (sysex, "System Exception"); - return -1; - } - ACE_CATCH (CORBA::UserException, userex) - { - ACE_PRINT_EXCEPTION (userex, "User Exception"); - return -1; - } - ACE_ENDTRY; - - return 0; -} diff --git a/TAO/orbsvcs/Time_Service/Time_Service_Server.cpp b/TAO/orbsvcs/Time_Service/Time_Service_Server.cpp deleted file mode 100644 index a265a39ed35..00000000000 --- a/TAO/orbsvcs/Time_Service/Time_Service_Server.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// $Id$ - -#include "Server_i.h" -#include "ace/OS_main.h" - -ACE_RCSID(TimeService, Time_Service_Server, "$Id$") - -// This is the main driver program for the Time Service server. - -int -ACE_TMAIN (int argc, ACE_TCHAR* argv[]) -{ - Server_i server; - - ACE_DEBUG ((LM_DEBUG, - "[SERVER] Process/Thread Id : (%P/%t) Time Service server\n")); - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - int r = server.init (argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (r == -1) - return 1; - else - { - server.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - } - ACE_CATCH (CORBA::SystemException, sysex) - { - ACE_PRINT_EXCEPTION (sysex, "System Exception"); - return -1; - } - ACE_CATCH (CORBA::UserException, userex) - { - ACE_PRINT_EXCEPTION (userex, "User Exception"); - return -1; - } - ACE_ENDTRY; - - return 0; -} |