#include <tao_imr_i.h>
Inheritance diagram for TAO_IMR_Op_Register:
Public Member Functions | |
TAO_IMR_Op_Register (bool is_add) | |
virtual int | parse (int argc, ACE_TCHAR **argv) |
virtual int | run (void) |
Do the work. | |
Protected Member Functions | |
void | addenv (ACE_TCHAR *opt) |
Sets one environment variable. | |
void | print_usage (void) |
Prints a message about the usage. | |
Protected Attributes | |
bool | is_add_ |
Enables pre-registration checks. | |
ACE_CString | server_name_ |
POA server name. | |
bool | set_command_line_ |
ACE_CString | command_line_ |
bool | set_environment_vars_ |
ImplementationRepository::EnvironmentList | environment_vars_ |
bool | set_working_dir_ |
ACE_CString | working_dir_ |
bool | set_activation_ |
ImplementationRepository::ActivationMode | activation_ |
bool | set_retry_count_ |
int | retry_count_ |
bool | set_activator_ |
ACE_CString | activator_ |
Register is used to update/add information for a server with the IMR.
Definition at line 281 of file tao_imr_i.h.
|
Definition at line 247 of file tao_imr_i.cpp.
00248 : is_add_ (is_add) 00249 , set_command_line_ (false) 00250 , set_environment_vars_(false) 00251 , set_working_dir_ (false) 00252 , set_activation_ (false) 00253 , activation_(ImplementationRepository::NORMAL) 00254 , set_retry_count_(false) 00255 , retry_count_ (0) 00256 , set_activator_ (false) 00257 { 00258 // Nothing 00259 } |
|
Sets one environment variable.
Definition at line 580 of file tao_imr_i.cpp. References ACE_CString, environment_vars_, and CORBA::string_dup(). Referenced by parse().
00581 { 00582 CORBA::ULong length = this->environment_vars_.length (); 00583 // Increase the length of the sequence 00584 this->environment_vars_.length (length + 1); 00585 ACE_CString tokens (opt); 00586 int index = tokens.find ("="); 00587 // Insert at position length since that is our new element 00588 this->environment_vars_ [length].name = 00589 CORBA::string_dup (tokens.substr (0, index).c_str ()); 00590 this->environment_vars_ [length].value = 00591 CORBA::string_dup (tokens.substr (index + 1).c_str ()); 00592 } |
|
hostname of the activator Implements TAO_IMR_Op. Definition at line 614 of file tao_imr_i.cpp. References ACE_ERROR, ACE_ERROR_RETURN, activator_, addenv(), ACE_OS::atoi(), LM_ERROR, print_usage(), retry_count_, set_activation_, set_activator_, set_command_line_, set_environment_vars_, set_retry_count_, set_working_dir_, and ACE_OS::strcasecmp().
00615 { 00616 // Check for enough arguments (we need at least one for the server name) 00617 if (argc < 2) 00618 { 00619 ACE_ERROR((LM_ERROR, "Error: Must supply at least a server name.\n")); 00620 this->print_usage (); 00621 return -1; 00622 } 00623 00624 // Skip both the program name and the "update" command 00625 ACE_Get_Opt get_opts (argc, argv, "hc:w:a:e:r:R:l:"); 00626 00627 this->server_name_ = argv[1]; 00628 int c; 00629 00630 while ((c = get_opts ()) != -1) 00631 { 00632 switch (c) 00633 { 00634 case 'c': // Command line arguments 00635 this->set_command_line_ = true; 00636 this->command_line_ = get_opts.opt_arg (); 00637 break; 00638 case 'e': // set environment variables 00639 this->set_environment_vars_ = true; 00640 this->addenv( get_opts.opt_arg () ); 00641 break; 00642 case 'w': // Working Directory 00643 this->set_working_dir_ = true; 00644 this->working_dir_ = get_opts.opt_arg (); 00645 break; 00646 case 'a': // Activation Mode 00647 this->set_activation_ = true; 00648 if (ACE_OS::strcasecmp (get_opts.opt_arg (), "NORMAL") == 0) 00649 this->activation_ = ImplementationRepository::NORMAL; 00650 else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "MANUAL") == 0) 00651 this->activation_ = ImplementationRepository::MANUAL; 00652 else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "PER_CLIENT") == 0) 00653 this->activation_ = ImplementationRepository::PER_CLIENT; 00654 else if (ACE_OS::strcasecmp (get_opts.opt_arg (), "AUTO_START") == 0) 00655 this->activation_ = ImplementationRepository::AUTO_START; 00656 else 00657 ACE_ERROR_RETURN ((LM_ERROR, 00658 "Unknown Activation Mode <%s>.\n", 00659 get_opts.opt_arg ()), 00660 -1); 00661 break; 00662 case 'r': 00663 case 'R': // startup/ping Retry Count 00664 { 00665 this->set_retry_count_ = true; 00666 int rc = ACE_OS::atoi(get_opts.optarg); 00667 if (rc > 0) 00668 this->retry_count_ = rc; 00669 } 00670 break; 00671 case 'l': /// hostname of the activator 00672 this->activator_ = get_opts.optarg; 00673 this->set_activator_ = true; 00674 break; 00675 case 'h': // display help 00676 this->print_usage (); 00677 return -1; 00678 default: 00679 ACE_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); 00680 this->print_usage (); 00681 return -1; 00682 } 00683 } 00684 return 0; 00685 } |
|
Prints a message about the usage.
Definition at line 595 of file tao_imr_i.cpp. References ACE_ERROR, and LM_ERROR. Referenced by parse().
00596 { 00597 ACE_ERROR ((LM_ERROR, 00598 "Adds/Updates a server entry\n" 00599 "\n" 00600 "Usage: tao_imr [options] <add|update> <name> [command-arguments]\n" 00601 " where [options] are ORB options\n" 00602 " where <name> is the POA name used by the server object\n" 00603 " where [command-arguments] can be\n" 00604 " -h Displays this\n" 00605 " -l Activator name.\n" 00606 " -c command Startup command\n" 00607 " -w dir Working directory\n" 00608 " -e name=value Set environment variables\n" 00609 " -a mode Set activate mode (NORMAL|MANUAL|PER_CLIENT|AUTO_START)\n" 00610 " -r count Set the startup/ping retry count to count\n")); 00611 } |
|
Do the work.
Implements TAO_IMR_Op. Definition at line 991 of file tao_imr_i.cpp. References ACE_ASSERT, ACE_DEBUG, ACE_ERROR, environment_vars_, ACE_OS::hostname(), is_add_, LM_DEBUG, LM_ERROR, MAXHOSTNAMELEN, retry_count_, set_activation_, set_activator_, set_command_line_, set_environment_vars_, set_retry_count_, set_working_dir_, and CORBA::string_dup().
00992 { 00993 ACE_ASSERT (! CORBA::is_nil(imr_)); 00994 00995 ImplementationRepository::ServerInformation_var server_information; 00996 ImplementationRepository::StartupOptions local; 00997 ImplementationRepository::StartupOptions* options = 0; 00998 00999 try 01000 { 01001 this->imr_->find(this->server_name_.c_str (), 01002 server_information.out()); 01003 01004 if (server_name_ == server_information->server.in()) 01005 { 01006 if (is_add_) 01007 { 01008 ACE_DEBUG((LM_DEBUG, "Server <%s> already registered.\n", this->server_name_.c_str ())); 01009 return ALREADY_REGISTERED; 01010 } 01011 options = &server_information->startup; 01012 } 01013 else // not found 01014 { 01015 if (!is_add_) 01016 { 01017 ACE_DEBUG((LM_DEBUG, "Adding Server <%s> on update command.\n", this->server_name_.c_str ())); 01018 is_add_ = true; 01019 } 01020 options = &local; 01021 } 01022 01023 if (this->set_command_line_) 01024 options->command_line = CORBA::string_dup (this->command_line_.c_str ()); 01025 01026 if (this->set_environment_vars_) 01027 options->environment = this->environment_vars_; 01028 01029 if (this->set_working_dir_) 01030 options->working_directory = CORBA::string_dup (this->working_dir_.c_str ()); 01031 01032 if (this->set_activation_ || is_add_) 01033 options->activation = this->activation_; 01034 01035 if (this->set_retry_count_ || is_add_) 01036 options->start_limit = this->retry_count_ + 1; 01037 01038 if (this->set_activator_) 01039 options->activator = CORBA::string_dup(this->activator_.c_str ()); 01040 // If the command line is set, we must have an activator 01041 else if (this->set_command_line_ && 01042 (options->activator.in () == 0 || *options->activator.in () == 0)) 01043 { 01044 char host_name[MAXHOSTNAMELEN + 1]; 01045 ACE_OS::hostname (host_name, MAXHOSTNAMELEN); 01046 options->activator = CORBA::string_dup (host_name); 01047 ACE_DEBUG ((LM_DEBUG, "Updating Server <%s> with default activator of <%s>.\n", 01048 this->server_name_.c_str (), options->activator.in ())); 01049 } 01050 01051 this->imr_->add_or_update_server (this->server_name_.c_str (), *options); 01052 01053 ACE_DEBUG((LM_DEBUG, "Successfully registered <%s>.\n", this->server_name_.c_str ())); 01054 } 01055 catch (const CORBA::NO_PERMISSION&) 01056 { 01057 ACE_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n")); 01058 return TAO_IMR_Op::NO_PERMISSION; 01059 } 01060 catch (const CORBA::Exception& ex) 01061 { 01062 ex._tao_print_exception ("Updating server"); 01063 return TAO_IMR_Op::UNKNOWN; 01064 } 01065 01066 return TAO_IMR_Op::NORMAL; 01067 } |
|
Definition at line 313 of file tao_imr_i.h. |
|
Definition at line 319 of file tao_imr_i.h. Referenced by parse(). |
|
Definition at line 304 of file tao_imr_i.h. |
|
Definition at line 307 of file tao_imr_i.h. |
|
Enables pre-registration checks.
Definition at line 292 of file tao_imr_i.h. Referenced by run(). |
|
Definition at line 316 of file tao_imr_i.h. |
|
POA server name.
Definition at line 301 of file tao_imr_i.h. |
|
Definition at line 312 of file tao_imr_i.h. |
|
Definition at line 318 of file tao_imr_i.h. |
|
Definition at line 303 of file tao_imr_i.h. |
|
Definition at line 306 of file tao_imr_i.h. |
|
Definition at line 315 of file tao_imr_i.h. |
|
Definition at line 309 of file tao_imr_i.h. |
|
Definition at line 310 of file tao_imr_i.h. |