diff options
author | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-21 02:25:33 +0000 |
---|---|---|
committer | brunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-21 02:25:33 +0000 |
commit | ae7e853349502069d848371e3dab48921d4c03ea (patch) | |
tree | 7a274333a7c64a15c47b660b41f87d70f476dd2b | |
parent | 2eb66ab678034be8d54430f7db4a3105f72107fa (diff) | |
download | ATCD-ae7e853349502069d848371e3dab48921d4c03ea.tar.gz |
Activation and Shutdown now work from tao_ir.
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp | 84 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp | 186 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h | 34 |
3 files changed, 268 insertions, 36 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp index 4c5473bf9bd..65f36f74a7f 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImplRepo_i.cpp @@ -6,7 +6,6 @@ #include "ace/Read_Buffer.h" #include "ace/Process.h" #include "tao/IIOP_Profile.h" -//#include "ace/Hash_Map_Manager.h" #include "ace/Auto_Ptr.h" // Constructor @@ -54,8 +53,6 @@ ImplRepo_i::activate_server (const char *server, ACE_TRY_ENV); ACE_TRY_CHECK; - // @@ We shouldn't have to narrow. - ImplementationRepository::ServerObject_var server_object = ImplementationRepository::ServerObject::_narrow (object.in (), ACE_TRY_ENV); ACE_TRY_CHECK; @@ -600,24 +597,6 @@ ImplRepo_i::list (CORBA::ULong how_many, CORBA::String_var str = this->orb_manager_.activate (ir_iter, ACE_TRY_ENV) ACE_TRY_CHECK; - /* - - char poa_id[BUFSIZ]; - ACE_OS::sprintf (poa_id, - "%s_%ld", - this->poa_id_.c_str (), - this->counter_++); - - PortableServer::ObjectId_var id = - PortableServer::string_to_ObjectId (poa_id); - - this->poa_->activate_object_with_id (id.in (), - bind_iter, - ACE_TRY_ENV); - ACE_TRY_CHECK; - - bi = bind_iter->_this (ACE_TRY_ENV); - ACE_TRY_CHECK;*/ server_iterator = ir_iter->_this (ACE_TRY_ENV); ACE_TRY_CHECK; } @@ -638,7 +617,62 @@ void ImplRepo_i::shutdown_server (const char *server, CORBA::Environment &ACE_TRY_ENV) { - // @@ Nothing yet + ACE_TString server_object_ior, host; + unsigned short port; + + // Find out if it is already running + if (this->repository_.get_running_info (server, host, port, server_object_ior) != 0) + { + // If we had problems getting the server_object_ior, probably meant that + // there is no <server> registered + ACE_ERROR ((LM_ERROR, + "Error: Cannot find ServerObject IOR for server <%s>\n", + server)); + ACE_THROW (ImplementationRepository::Administration::NotFound ()); + } + + // Check to see if there is one running (if there is a server_object_ior) + if (server_object_ior.length () != 0) + { + // It is running, so shut it down + ACE_TRY + { + CORBA::Object_var object = + this->orb_manager_.orb ()->string_to_object (server_object_ior.c_str (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + ImplementationRepository::ServerObject_var server_object = + ImplementationRepository::ServerObject::_narrow (object.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil (server_object.in ())) + { + ACE_ERROR ((LM_ERROR, + "Error: Invalid ServerObject IOR: <%s>\n", + server_object_ior)); + ACE_TRY_THROW (ImplementationRepository::Administration::NotFound ()); + } + + // Call shutdown + server_object->shutdown (ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Remove running info from repository + if (this->repository_.update (server, "", 0, "") != 0) + { + ACE_ERROR ((LM_ERROR, + "Error: Could not update information for unknown server <%s>\n", + server)); + ACE_TRY_THROW (ImplementationRepository::Administration::NotFound ()); + } + } + ACE_CATCHANY + { + ACE_RETHROW; + } + ACE_ENDTRY; + } } @@ -733,15 +767,15 @@ IR_Forwarder::IR_Forwarder (CORBA::ORB_ptr orb_ptr, } CORBA::RepositoryId -IR_Forwarder::_primary_interface (const PortableServer::ObjectId & /* oid */, - PortableServer::POA_ptr /* poa */, +IR_Forwarder::_primary_interface (const PortableServer::ObjectId &, + PortableServer::POA_ptr, CORBA::Environment &) { return 0; } void -IR_Forwarder::invoke (CORBA::ServerRequest_ptr /* request */, +IR_Forwarder::invoke (CORBA::ServerRequest_ptr , CORBA::Environment &ACE_TRY_ENV) { // Get the POA Current object reference diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp index f05f0c1178a..eba6a41000e 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.cpp @@ -123,14 +123,16 @@ TAO_IR_i::parse_args (void) void TAO_IR_i::print_usage (void) { - ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] command [command-arguments]\n")); - ACE_ERROR ((LM_ERROR, " where [options] are ORB options\n")); - ACE_ERROR ((LM_ERROR, " where command is one of the following:\n")); - ACE_ERROR ((LM_ERROR, " add Add an entry to the IR\n")); - ACE_ERROR ((LM_ERROR, " remove Remove an entry from the IR\n")); - ACE_ERROR ((LM_ERROR, " update Update an entry in the IR\n")); - ACE_ERROR ((LM_ERROR, " list List the entries in the IR\n")); - ACE_ERROR ((LM_ERROR, " where [command-arguments] depend on the command\n")); + ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] command [command-arguments]\n" + " where [options] are ORB options\n" + " where command is one of the following:\n" + " activate Activates a server through the IR\n" + " add Add an entry to the IR\n" + " list List the entries in the IR\n" + " remove Remove an entry from the IR\n" + " shutdown Shuts down a server through the IR\n" + " update Update an entry in the IR\n" + " where [command-arguments] depend on the command\n")); } @@ -139,12 +141,16 @@ TAO_IR_i::print_usage (void) TAO_IR_Op * TAO_IR_Op::make_op (const ASYS_TCHAR *op_name, ImplementationRepository::Administration_ptr ir) { - if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("add")) == 0) + if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("activate")) == 0) + return new TAO_IR_Op_Activate (ir); + else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("add")) == 0) return new TAO_IR_Op_Add (ir); else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("list")) == 0) return new TAO_IR_Op_List (ir); else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("remove")) == 0) return new TAO_IR_Op_Remove (ir); + else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("shutdown")) == 0) + return new TAO_IR_Op_Shutdown (ir); else if (ACE_OS::strcasecmp (op_name, ASYS_TEXT ("update")) == 0) return new TAO_IR_Op_Update (ir); @@ -162,6 +168,12 @@ TAO_IR_Op::TAO_IR_Op (ImplementationRepository::Administration_ptr implrepo) // Nothing } +TAO_IR_Op_Activate::TAO_IR_Op_Activate (ImplementationRepository::Administration_ptr implrepo) +: TAO_IR_Op (implrepo) +{ + // Nothing +} + TAO_IR_Op_Add::TAO_IR_Op_Add (ImplementationRepository::Administration_ptr implrepo) : TAO_IR_Op (implrepo) { @@ -181,6 +193,12 @@ TAO_IR_Op_Remove::TAO_IR_Op_Remove (ImplementationRepository::Administration_ptr // Nothing } +TAO_IR_Op_Shutdown::TAO_IR_Op_Shutdown (ImplementationRepository::Administration_ptr implrepo) +: TAO_IR_Op (implrepo) +{ + // Nothing +} + TAO_IR_Op_Update::TAO_IR_Op_Update (ImplementationRepository::Administration_ptr implrepo) : TAO_IR_Op (implrepo), set_command_line_ (0), @@ -199,6 +217,11 @@ TAO_IR_Op::~TAO_IR_Op () // Nothing } +TAO_IR_Op_Activate::~TAO_IR_Op_Activate (void) +{ + // Nothing +} + TAO_IR_Op_Add::~TAO_IR_Op_Add (void) { // Nothing @@ -214,6 +237,11 @@ TAO_IR_Op_Remove::~TAO_IR_Op_Remove (void) // Nothing } +TAO_IR_Op_Shutdown::~TAO_IR_Op_Shutdown (void) +{ + // Nothing +} + TAO_IR_Op_Update::~TAO_IR_Op_Update (void) { // Nothing @@ -224,6 +252,35 @@ TAO_IR_Op_Update::~TAO_IR_Op_Update (void) // = Parse methods +int +TAO_IR_Op_Activate::parse (int argc, ASYS_TCHAR **argv) +{ + // Check for enough arguments (we need at least one for the server name) + if (argc < 1) + { + this->print_usage (); + return -1; + } + + // Skip both the program name and the "activate" command + ACE_Get_Opt get_opts (argc, argv, "h"); + + this->server_name_ = argv[0]; + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'h': // display help + default: + this->print_usage (); + return -1; + } + + // Success + return 0; +} + int TAO_IR_Op_Add::parse (int argc, ASYS_TCHAR **argv) { @@ -301,7 +358,36 @@ TAO_IR_Op_Remove::parse (int argc, ASYS_TCHAR **argv) return -1; } - // Skip both the program name and the "add" command + // Skip both the program name and the "remove" command + ACE_Get_Opt get_opts (argc, argv, "h"); + + this->server_name_ = argv[0]; + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'h': // display help + default: + this->print_usage (); + return -1; + } + + // Success + return 0; +} + +int +TAO_IR_Op_Shutdown::parse (int argc, ASYS_TCHAR **argv) +{ + // Check for enough arguments (we need at least one for the server name) + if (argc < 1) + { + this->print_usage (); + return -1; + } + + // Skip both the program name and the "shutdown" command ACE_Get_Opt get_opts (argc, argv, "h"); this->server_name_ = argv[0]; @@ -330,7 +416,7 @@ TAO_IR_Op_Update::parse (int argc, ASYS_TCHAR **argv) return -1; } - // Skip both the program name and the "add" command + // Skip both the program name and the "update" command ACE_Get_Opt get_opts (argc, argv, "hc:w:"); this->server_name_ = argv[0]; @@ -363,6 +449,33 @@ TAO_IR_Op_Update::parse (int argc, ASYS_TCHAR **argv) int +TAO_IR_Op_Activate::run (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + this->implrepo_->activate_server (this->server_name_.c_str (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Successfully Activated server <%s>\n", this->server_name_.c_str ())); + } + ACE_CATCH (ImplementationRepository::Administration::NotFound, ex) + { + ACE_ERROR ((LM_ERROR, "Could not find server <%s>!\n", this->server_name_.c_str ())); + return -1; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Activating Server"); + return -1; + } + ACE_ENDTRY; + + // Success + return 0; +} + +int TAO_IR_Op_Add::run (void) { ImplementationRepository::StartupOptions startup_options; @@ -487,6 +600,33 @@ TAO_IR_Op_Remove::run (void) } int +TAO_IR_Op_Shutdown::run (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + this->implrepo_->shutdown_server (this->server_name_.c_str (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "Successfully shut down server <%s>\n", this->server_name_.c_str ())); + } + ACE_CATCH (ImplementationRepository::Administration::NotFound, ex) + { + ACE_ERROR ((LM_ERROR, "Could not find server <%s>!\n", this->server_name_.c_str ())); + return -1; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Shutting Down Server"); + return -1; + } + ACE_ENDTRY; + + // Success + return 0; +} + +int TAO_IR_Op_Update::run (void) { ImplementationRepository::ServerInformation_var server_information; @@ -535,6 +675,18 @@ TAO_IR_Op_Update::run (void) void +TAO_IR_Op_Activate::print_usage (void) +{ + ACE_ERROR ((LM_ERROR, "Activates a server\n" + "\n" + "Usage: tao_ir [options] activate <name> [command-arguments]\n" + " where [options] are ORB options\n" + " where <name> is the POA name used by the server object\n" + " where [command-arguments] can be\n" + " -h Displays this\n")); +} + +void TAO_IR_Op_Add::print_usage (void) { ACE_ERROR ((LM_ERROR, "Usage: tao_ir [options] add <name> [command-arguments]\n" @@ -573,6 +725,18 @@ TAO_IR_Op_Remove::print_usage (void) } void +TAO_IR_Op_Shutdown::print_usage (void) +{ + ACE_ERROR ((LM_ERROR, "Shuts down a server\n" + "\n" + "Usage: tao_ir [options] shutdown <name> [command-arguments]\n" + " where [options] are ORB options\n" + " where <name> is the POA name used by the server object\n" + " where [command-arguments] can be\n" + " -h Displays this\n")); +} + +void TAO_IR_Op_Update::print_usage (void) { ACE_ERROR ((LM_ERROR, "Updates a server entry\n" diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h index 038a808c2a4..ad424c2e313 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h +++ b/TAO/orbsvcs/ImplRepo_Service/tao_ir_i.h @@ -95,6 +95,23 @@ protected: // Prints out the information contained in a ServerInformation structure. }; +class TAO_IR_Op_Activate : public TAO_IR_Op +{ +public: + TAO_IR_Op_Activate (ImplementationRepository::Administration_ptr implrepo); + ~TAO_IR_Op_Activate (void); + + virtual int parse (int argc, ASYS_TCHAR **argv); + virtual int run (void); + +protected: + void print_usage (void); + // Prints a message about the usage + + ACE_TString server_name_; + // POA server name. +}; + class TAO_IR_Op_Add : public TAO_IR_Op { public: @@ -162,6 +179,23 @@ protected: // POA server name. }; +class TAO_IR_Op_Shutdown : public TAO_IR_Op +{ +public: + TAO_IR_Op_Shutdown (ImplementationRepository::Administration_ptr implrepo); + ~TAO_IR_Op_Shutdown (void); + + virtual int parse (int argc, ASYS_TCHAR **argv); + virtual int run (void); + +protected: + void print_usage (void); + // Prints a message about the usage + + ACE_TString server_name_; + // POA server name. +}; + class TAO_IR_Op_Update : public TAO_IR_Op { public: |