#include <Naming_Server.h>
Collaboration diagram for TAO_Naming_Server:
Public Member Functions | |
TAO_Naming_Server (void) | |
Default constructor. | |
TAO_Naming_Server (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, size_t context_size=ACE_DEFAULT_MAP_SIZE, ACE_Time_Value *timeout=0, int resolve_for_existing_naming_service=1, const ACE_TCHAR *persistence_location=0, void *base_addr=TAO_NAMING_BASE_ADDR, int enable_multicast=1, int use_storable_context=0, int round_trip_timeout=0, int use_round_trip_timeout=0) | |
int | init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, size_t context_size=ACE_DEFAULT_MAP_SIZE, ACE_Time_Value *timeout=0, int resolve_for_existing_naming_service=1, const ACE_TCHAR *persistence_location=0, void *base_addr=TAO_NAMING_BASE_ADDR, int enable_multicast=1, int use_storable_context=0, int round_trip_timeout=0, int use_round_trip_timeout=0) |
int | init_with_orb (int argc, ACE_TCHAR *argv[], CORBA::ORB_ptr orb) |
int | fini (void) |
Destroy the child POA created in . | |
~TAO_Naming_Server (void) | |
Destructor. | |
char * | naming_service_ior (void) |
Returns the IOR of the naming service. | |
CosNaming::NamingContext_ptr | operator-> (void) const |
Returns a for the root Naming Context. | |
Protected Member Functions | |
int | init_new_naming (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa, const ACE_TCHAR *persistence_location, void *base_addr, size_t context_size, int enable_multicast, int use_storable_context, int round_trip_timeout=0, int use_round_trip_timeout=0) |
int | parse_args (int argc, ACE_TCHAR *argv[]) |
parses the arguments. | |
Protected Attributes | |
CosNaming::NamingContext_var | naming_context_ |
Root NamingContext_ptr. | |
TAO_IOR_Multicast * | ior_multicast_ |
The ior_multicast event handler. | |
CORBA::String_var | naming_service_ior_ |
The IOR string of the root naming context. | |
TAO_Persistent_Context_Index * | context_index_ |
CORBA::ORB_var | orb_ |
The ORB. | |
PortableServer::POA_var | root_poa_ |
The Root POA. | |
PortableServer::POA_var | ns_poa_ |
The Naming Service POA. | |
const ACE_TCHAR * | ior_file_name_ |
File to output the Naming Service IOR. | |
const ACE_TCHAR * | pid_file_name_ |
File to output the process id. | |
size_t | context_size_ |
const ACE_TCHAR * | persistence_file_name_ |
void * | base_address_ |
int | multicast_ |
If not zero multicast is enabled. | |
int | use_storable_context_ |
If not zero use flat file persistence. | |
int | use_servant_activator_ |
TAO_Storable_Naming_Context_Activator * | servant_activator_ |
int | use_redundancy_ |
int | round_trip_timeout_ |
int | use_round_trip_timeout_ |
This class either finds an existing Naming Service (if the flag is set) or creates one (if flag isn't set or Naming Service was not found). This class also defines the operator-> so that functions like , .. can be called directly on a object, and be forwareded to the root Naming Context. This class is intended to simplify programs that want to play the role of a Naming Service server. To simplify programs that want to play the role of Naming Service clients, use . If a Naming Service is created locally, a TAO_IOR_Multicast event handler is created and installed on the ORB's reactor. This event handler allows other clients on the network to discover and use this Naming Service. Event handler listens on a multicast port for messages from clients looking for a Naming Service, and sends back the ior of the root Naming Context. For more information on how this bootstraping through a multicast process works, check out orbsvcs/orbsvcs/TAO_IOR_Multicast.*, implementation of , and orbsvcs/Naming/README.
Definition at line 62 of file Naming_Server.h.
|
Default constructor.
Definition at line 34 of file Naming_Server.cpp. References ACE_DEFAULT_MAP_SIZE, and TAO_NAMING_BASE_ADDR.
00035 : naming_context_ (), 00036 ior_multicast_ (0), 00037 naming_service_ior_ (), 00038 context_index_ (0), 00039 ior_file_name_ (0), 00040 pid_file_name_ (0), 00041 context_size_ (ACE_DEFAULT_MAP_SIZE), 00042 persistence_file_name_ (0), 00043 base_address_ (TAO_NAMING_BASE_ADDR), 00044 multicast_ (0), 00045 use_storable_context_ (0), 00046 use_servant_activator_ (false), 00047 servant_activator_ (0), 00048 use_redundancy_(0), 00049 round_trip_timeout_ (0), 00050 use_round_trip_timeout_ (0) 00051 { 00052 } |
|
Constructor. Attempts to find an existing Naming Service if is set to true. If it is false, or no Naming Service was found during a period, create the Naming Service in this process. If creating the Naming Service locally, make the root context of size , register it under the , and make the Naming Service persistent if is not 0. ( specifies name of the file to use for persistent storage, specifies the address used for memory mapping file). If is not zero then the service will respond to multicast location queries. Definition at line 54 of file Naming_Server.cpp. References ACE_DEFAULT_MAP_SIZE, ACE_ERROR, init(), LM_ERROR, and TAO_NAMING_BASE_ADDR.
00065 : naming_context_ (), 00066 ior_multicast_ (0), 00067 naming_service_ior_ (), 00068 context_index_ (0), 00069 ior_file_name_ (0), 00070 pid_file_name_ (0), 00071 context_size_ (ACE_DEFAULT_MAP_SIZE), 00072 persistence_file_name_ (0), 00073 base_address_ (TAO_NAMING_BASE_ADDR), 00074 multicast_ (0), 00075 use_storable_context_ (use_storable_context), 00076 use_servant_activator_ (false), 00077 servant_activator_ (0), 00078 use_redundancy_(0), 00079 round_trip_timeout_ (0), 00080 use_round_trip_timeout_ (0) 00081 { 00082 if (this->init (orb, 00083 poa, 00084 context_size, 00085 timeout, 00086 resolve_for_existing_naming_service, 00087 persistence_location, 00088 base_addr, 00089 enable_multicast, 00090 use_storable_context, 00091 round_trip_timeout, 00092 use_round_trip_timeout) == -1) 00093 ACE_ERROR ((LM_ERROR, 00094 "(%P|%t) %p\n", 00095 "TAO_Naming_Server::init")); 00096 } |
|
Destructor.
Definition at line 720 of file Naming_Server.cpp. References servant_activator_, and use_servant_activator_.
00721 { 00722 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) 00723 if (this->use_servant_activator_) 00724 delete this->servant_activator_; 00725 #endif /* TAO_HAS_MINIMUM_POA */ 00726 } |
|
Destroy the child POA created in .
Definition at line 669 of file Naming_Server.cpp. References ACE_ERROR, context_index_, ior_multicast_, CORBA::is_nil(), LM_ERROR, and ns_poa_. Referenced by TAO_Naming_Loader::fini().
00670 { 00671 // Destroy the child POA ns_poa that is created when initializing 00672 // the Naming Service 00673 try 00674 { 00675 this->ns_poa_->destroy (1, 1); 00676 00677 CORBA::Object_var table_object = 00678 this->orb_->resolve_initial_references ("IORTable"); 00679 00680 IORTable::Table_var adapter = 00681 IORTable::Table::_narrow (table_object.in ()); 00682 if (CORBA::is_nil (adapter.in ())) 00683 { 00684 ACE_ERROR ((LM_ERROR, "Nil IORTable\n")); 00685 } 00686 else 00687 { 00688 adapter->unbind ("NameService"); 00689 } 00690 } 00691 catch (const CORBA::Exception&) 00692 { 00693 // Ignore 00694 } 00695 00696 if (this->ior_multicast_ != 0) 00697 { 00698 orb_->orb_core()->reactor ()->remove_handler (this->ior_multicast_, 00699 ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL); 00700 delete this->ior_multicast_; 00701 } 00702 00703 delete this->context_index_; 00704 00705 return 0; 00706 } |
|
Initializer. Attempts to find an existing Naming Service if is set to true. If it is false, or no Naming Service was found during a period, create the Naming Service in this process. If creating the Naming Service locally, make the root context of size , register it under the , and make the Naming Service persistent if is not 0. ( specifies name of the file to use for persistent storage, specifies the address used for memory mapping file). If is not zero then the service will respond to multicast location queries. Definition at line 100 of file Naming_Server.cpp. References ACE_DEBUG, init_new_naming(), CORBA::is_nil(), LM_DEBUG, naming_service_ior_, and TAO_debug_level. Referenced by init_with_orb(), and TAO_Naming_Server().
00111 { 00112 if (resolve_for_existing_naming_service) 00113 { 00114 try 00115 { 00116 // Try to find an existing Naming Service. 00117 CORBA::Object_var naming_obj = 00118 orb->resolve_initial_references ("NameService", timeout); 00119 00120 if (!CORBA::is_nil (naming_obj.in ())) 00121 { 00122 // 00123 // Success in finding a Naming Service. 00124 // 00125 if (TAO_debug_level > 0) 00126 ACE_DEBUG ((LM_DEBUG, 00127 "\nNameService found!\n")); 00128 00129 this->naming_context_ = 00130 CosNaming::NamingContext::_narrow (naming_obj.in ()); 00131 00132 this->naming_service_ior_ = 00133 orb->object_to_string (naming_obj.in ()); 00134 00135 return 0; 00136 } 00137 } 00138 catch (const CORBA::Exception& ex) 00139 { 00140 ex._tao_print_exception ("TAO_Naming_Server::init"); 00141 } 00142 } 00143 00144 if (TAO_debug_level > 0) 00145 ACE_DEBUG ((LM_DEBUG, 00146 "\nWe'll become a NameService\n")); 00147 00148 // Become a Naming Service. 00149 return this->init_new_naming (orb, 00150 poa, 00151 persistence_location, 00152 base_addr, 00153 context_size, 00154 enable_multicast, 00155 use_storable_context, 00156 round_trip_timeout, 00157 use_round_trip_timeout); 00158 } |
|
Helper method: create Naming Service locally. Make the root context of size , register it under the , and make the Naming Service persistent if is not 0. ( specifies name of the file to use for persistent storage). If is not zero then the service will respond to multicast location queries. Definition at line 424 of file Naming_Server.cpp. References CORBA::Policy::_nil(), ACE_OS::access(), ACE_CString, ACE_DEBUG, ACE_DEFAULT_MULTICAST_ADDR, ACE_ERROR, ACE_NEW_RETURN, ACE_NEW_THROW_EX, ACE_TEXT, ACE_OS::atoi(), context_index_, ACE_Auto_Basic_Ptr< X >::get(), ACE_OS::getenv(), TAO_Persistent_Context_Index::init(), ior_multicast_, CORBA::is_nil(), LM_DEBUG, LM_ERROR, TAO_Transient_Naming_Context::make_new_context(), naming_service_ior_, ns_poa_, TAO_Persistent_Context_Index::open(), TAO_Storable_Naming_Context::recreate_all(), ACE_Reactor::register_handler(), ACE_Auto_Basic_Ptr< X >::release(), TAO_Persistent_Context_Index::root_context(), TAO_debug_level, TAO_DEFAULT_NAME_SERVER_REQUEST_PORT, TAO_ROOT_NAMING_CONTEXT, TAO_SERVICEID_NAMESERVICE, use_redundancy_, use_servant_activator_, W_OK, and X_OK. Referenced by init().
00433 { 00434 try 00435 { 00436 if (use_storable_context) 00437 { 00438 // In lieu of a fully implemented service configurator version 00439 // of this Reader and Writer, let's just take something off the 00440 // command line for now. 00441 TAO_Naming_Service_Persistence_Factory* pf = 0; 00442 ACE_NEW_RETURN(pf, TAO_NS_FlatFileFactory, -1); 00443 auto_ptr<TAO_Naming_Service_Persistence_Factory> persFactory(pf); 00444 // This instance will either get deleted after recreate all or, 00445 // in the case of a servant activator's use, on destruction of the 00446 // activator. 00447 00448 // Was a location specified? 00449 if (persistence_location == 0) 00450 { 00451 // No, assign the default location "NameService" 00452 persistence_location = ACE_TEXT("NameService"); 00453 } 00454 00455 // Now make sure this directory exists 00456 if (ACE_OS::access (persistence_location, W_OK|X_OK)) 00457 { 00458 ACE_ERROR ((LM_ERROR, "Invalid persistence directory\n")); 00459 return -1; 00460 } 00461 00462 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) 00463 if (this->use_servant_activator_) 00464 { 00465 ACE_NEW_THROW_EX (this->servant_activator_, 00466 TAO_Storable_Naming_Context_Activator (orb, 00467 persFactory.get(), 00468 persistence_location, 00469 context_size), 00470 CORBA::NO_MEMORY ()); 00471 this->ns_poa_->set_servant_manager(this->servant_activator_); 00472 } 00473 #endif /* TAO_HAS_MINIMUM_POA */ 00474 00475 this->naming_context_ = 00476 TAO_Storable_Naming_Context::recreate_all (orb, 00477 poa, 00478 TAO_ROOT_NAMING_CONTEXT, 00479 context_size, 00480 0, 00481 persFactory.get(), 00482 persistence_location, 00483 use_redundancy_); 00484 00485 if (this->use_servant_activator_) 00486 persFactory.release(); 00487 } 00488 else if (persistence_location != 0) 00489 // 00490 // Initialize Persistent Naming Service. 00491 // 00492 { 00493 // Allocate and initialize Persistent Context Index. 00494 ACE_NEW_RETURN (this->context_index_, 00495 TAO_Persistent_Context_Index (orb, poa), 00496 -1); 00497 00498 if (this->context_index_->open (persistence_location, 00499 base_addr) == -1 00500 || this->context_index_->init (context_size) == -1) 00501 { 00502 if (TAO_debug_level >0) 00503 ACE_DEBUG ((LM_DEBUG, 00504 "TAO_Naming_Server: context_index initialization failed\n")); 00505 return -1; 00506 } 00507 00508 // Set the root Naming Context reference. 00509 this->naming_context_ = 00510 this->context_index_->root_context (); 00511 } 00512 else 00513 { 00514 // 00515 // Initialize Transient Naming Service. 00516 // 00517 this->naming_context_ = 00518 TAO_Transient_Naming_Context::make_new_context (poa, 00519 TAO_ROOT_NAMING_CONTEXT, 00520 context_size); 00521 00522 } 00523 00524 // Register with the ORB's resolve_initial_references() 00525 // mechanism. Primarily useful for dynamically loaded Name 00526 // Services. 00527 orb->register_initial_reference ("NameService", 00528 this->naming_context_.in ()); 00529 00530 // Set the ior of the root Naming Context. 00531 this->naming_service_ior_= 00532 orb->object_to_string (this->naming_context_.in ()); 00533 00534 CORBA::Object_var table_object = 00535 orb->resolve_initial_references ("IORTable"); 00536 00537 IORTable::Table_var adapter = 00538 IORTable::Table::_narrow (table_object.in ()); 00539 if (CORBA::is_nil (adapter.in ())) 00540 { 00541 ACE_ERROR ((LM_ERROR, "Nil IORTable\n")); 00542 } 00543 else 00544 { 00545 CORBA::String_var ior = 00546 orb->object_to_string (this->naming_context_.in ()); 00547 adapter->bind ("NameService", ior.in ()); 00548 } 00549 00550 #if defined (ACE_HAS_IP_MULTICAST) 00551 if (enable_multicast) 00552 { 00553 // @@ Marina: is there anyway to implement this stuff 00554 // without using ORB_Core_instance()? For example can you 00555 // pass the ORB as an argument? 00556 00557 // 00558 // Install ior multicast handler. 00559 // 00560 // Get reactor instance from TAO. 00561 ACE_Reactor *reactor = orb->orb_core()->reactor (); 00562 00563 // See if the -ORBMulticastDiscoveryEndpoint option was specified. 00564 ACE_CString mde (orb->orb_core ()->orb_params ()->mcast_discovery_endpoint ()); 00565 00566 // First, see if the user has given us a multicast port number 00567 // on the command-line; 00568 u_short port = 00569 orb->orb_core ()->orb_params ()->service_port (TAO::MCAST_NAMESERVICE); 00570 00571 if (port == 0) 00572 { 00573 // Check environment var. for multicast port. 00574 const char *port_number = 00575 ACE_OS::getenv ("NameServicePort"); 00576 00577 if (port_number != 0) 00578 port = static_cast<u_short> (ACE_OS::atoi (port_number)); 00579 } 00580 00581 // Port wasn't specified on the command-line or in environment - 00582 // use the default. 00583 if (port == 0) 00584 port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT; 00585 00586 // Instantiate a handler which will handle client requests for 00587 // the root Naming Context ior, received on the multicast port. 00588 ACE_NEW_RETURN (this->ior_multicast_, 00589 TAO_IOR_Multicast (), 00590 -1); 00591 00592 if (mde.length () != 0) 00593 { 00594 if (this->ior_multicast_->init (this->naming_service_ior_.in (), 00595 mde.c_str (), 00596 TAO_SERVICEID_NAMESERVICE) == -1) 00597 return -1; 00598 } 00599 else 00600 { 00601 if (this->ior_multicast_->init (this->naming_service_ior_.in (), 00602 port, 00603 #if defined (ACE_HAS_IPV6) 00604 ACE_DEFAULT_MULTICASTV6_ADDR, 00605 #else 00606 ACE_DEFAULT_MULTICAST_ADDR, 00607 #endif /* ACE_HAS_IPV6 */ 00608 TAO_SERVICEID_NAMESERVICE) == -1) 00609 return -1; 00610 } 00611 00612 // Register event handler for the ior multicast. 00613 if (reactor->register_handler (this->ior_multicast_, 00614 ACE_Event_Handler::READ_MASK) == -1) 00615 { 00616 if (TAO_debug_level > 0) 00617 ACE_DEBUG ((LM_DEBUG, 00618 "TAO_Naming_Server: cannot register Event handler\n")); 00619 return -1; 00620 } 00621 00622 if (TAO_debug_level > 0) 00623 ACE_DEBUG ((LM_DEBUG, 00624 "TAO_Naming_Server: The multicast server setup is done.\n")); 00625 } 00626 #else 00627 ACE_UNUSED_ARG (enable_multicast); 00628 #endif /* ACE_HAS_IP_MULTICAST */ 00629 00630 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 00631 if (use_round_trip_timeout == 1) 00632 { 00633 TimeBase::TimeT roundTripTimeoutVal = round_trip_timeout; 00634 CORBA::Any anyObjectVal; 00635 anyObjectVal <<= roundTripTimeoutVal; 00636 CORBA::PolicyList polList (1); 00637 polList.length (1); 00638 polList[0] = orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE, 00639 anyObjectVal); 00640 00641 // set a timeout on the orb 00642 // 00643 CORBA::Object_var orbPolicyManagerObj = 00644 orb->resolve_initial_references ("ORBPolicyManager"); 00645 00646 CORBA::PolicyManager_var orbPolicyManager = 00647 CORBA::PolicyManager::_narrow (orbPolicyManagerObj.in ()); 00648 orbPolicyManager->set_policy_overrides (polList, CORBA::SET_OVERRIDE); 00649 00650 polList[0]->destroy (); 00651 polList[0] = CORBA::Policy::_nil (); 00652 } 00653 #else 00654 ACE_UNUSED_ARG (use_round_trip_timeout); 00655 ACE_UNUSED_ARG (round_trip_timeout); 00656 #endif /* TAO_HAS_CORBA_MESSAGING */ 00657 } 00658 catch (const CORBA::Exception& ex) 00659 { 00660 ex._tao_print_exception ( 00661 "TAO_Naming_Server::init_new_naming"); 00662 return -1; 00663 } 00664 00665 return 0; 00666 } |
|
Initialize the Naming Service with the command line arguments and the ORB. Definition at line 276 of file Naming_Server.cpp. References CORBA::ORB::_duplicate(), ACE_ERROR_RETURN, ACE_TEXT, context_size_, ACE_OS::fclose(), ACE_OS::fopen(), ACE_OS::fprintf(), init(), ior_file_name_, CORBA::is_nil(), LM_ERROR, multicast_, naming_service_ior(), ns_poa_, parse_args(), persistence_file_name_, round_trip_timeout_, use_round_trip_timeout_, use_servant_activator_, and use_storable_context_. Referenced by TAO_Naming_Loader::create_object().
00279 { 00280 int result; 00281 00282 try 00283 { 00284 // Duplicate the ORB 00285 this->orb_ = CORBA::ORB::_duplicate (orb); 00286 00287 // Get the POA from the ORB. 00288 CORBA::Object_var poa_object = 00289 orb->resolve_initial_references ("RootPOA"); 00290 00291 if (CORBA::is_nil (poa_object.in ())) 00292 { 00293 ACE_ERROR_RETURN ((LM_ERROR, 00294 ACE_TEXT(" (%P|%t) Unable to initialize the POA.\n")), 00295 -1); 00296 } 00297 00298 // Check the non-ORB arguments. this needs to come before we 00299 // initialize my_naming_server so that we can pass on some of 00300 // the command-line arguments. 00301 result = this->parse_args (argc, argv); 00302 00303 if (result < 0) 00304 return result; 00305 00306 // Get the POA object. 00307 this->root_poa_ = PortableServer::POA::_narrow (poa_object.in ()); 00308 00309 // Get the POA_Manager. 00310 PortableServer::POAManager_var poa_manager = 00311 this->root_poa_->the_POAManager (); 00312 00313 poa_manager->activate (); 00314 00315 int numPolicies = 2; 00316 #if (TAO_HAS_MINIMUM_POA == 0) 00317 if (this->use_storable_context_) 00318 { 00319 this->use_servant_activator_ = true; 00320 } 00321 00322 if (this->use_servant_activator_) { 00323 numPolicies += 2; 00324 } 00325 #endif /* TAO_HAS_MINIMUM_POA */ 00326 00327 CORBA::PolicyList policies (numPolicies); 00328 policies.length (numPolicies); 00329 00330 // Id Assignment policy 00331 policies[0] = 00332 this->root_poa_->create_id_assignment_policy (PortableServer::USER_ID); 00333 00334 // Lifespan policy 00335 policies[1] = 00336 this->root_poa_->create_lifespan_policy (PortableServer::PERSISTENT); 00337 00338 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) 00339 if (this->use_servant_activator_) 00340 { 00341 // Request Processing Policy 00342 policies[2] = 00343 this->root_poa_->create_request_processing_policy (PortableServer::USE_SERVANT_MANAGER); 00344 00345 // Servant Retention Policy 00346 policies[3] = 00347 this->root_poa_->create_servant_retention_policy (PortableServer::RETAIN); 00348 } 00349 #endif /* TAO_HAS_MINIMUM_POA */ 00350 00351 // We use a different POA, otherwise the user would have to change 00352 // the object key each time it invokes the server. 00353 this->ns_poa_ = this->root_poa_->create_POA ("NameService", 00354 poa_manager.in (), 00355 policies); 00356 // Warning! If create_POA fails, then the policies won't be 00357 // destroyed and there will be hell to pay in memory leaks! 00358 00359 // Creation of the new POAs over, so destroy the Policy_ptr's. 00360 for (CORBA::ULong i = 0; 00361 i < policies.length (); 00362 ++i) 00363 { 00364 CORBA::Policy_ptr policy = policies[i]; 00365 policy->destroy (); 00366 } 00367 00368 result = this->init (orb, 00369 this->ns_poa_.in (), 00370 this->context_size_, 00371 0, 00372 0, 00373 this->persistence_file_name_, 00374 this->base_address_, 00375 this->multicast_, 00376 this->use_storable_context_, 00377 this->round_trip_timeout_, 00378 this->use_round_trip_timeout_); 00379 if (result == -1) 00380 return result; 00381 } 00382 catch (const CORBA::Exception& ex) 00383 { 00384 ex._tao_print_exception ( 00385 "TAO_Naming_Server::init_with_orb"); 00386 return -1; 00387 } 00388 00389 if (this->ior_file_name_ != 0) 00390 { 00391 FILE *iorf = ACE_OS::fopen (this->ior_file_name_, ACE_TEXT("w")); 00392 if (iorf == 0) 00393 { 00394 ACE_ERROR_RETURN ((LM_ERROR, 00395 ACE_TEXT("Unable to open %s for writing:(%u) %p\n"), 00396 this->ior_file_name_, 00397 errno, 00398 ACE_TEXT("TAO_Naming_Server::init_with_orb")), 00399 -1); 00400 } 00401 00402 CORBA::String_var str = this->naming_service_ior (); 00403 00404 ACE_OS::fprintf (iorf, "%s\n", str.in ()); 00405 ACE_OS::fclose (iorf); 00406 } 00407 00408 if (this->pid_file_name_ != 0) 00409 { 00410 FILE *pidf = ACE_OS::fopen (this->pid_file_name_, ACE_TEXT("w")); 00411 if (pidf != 0) 00412 { 00413 ACE_OS::fprintf (pidf, 00414 "%ld\n", 00415 static_cast<long> (ACE_OS::getpid ())); 00416 ACE_OS::fclose (pidf); 00417 } 00418 } 00419 00420 return 0; 00421 } |
|
Returns the IOR of the naming service.
Definition at line 709 of file Naming_Server.cpp. References CORBA::string_dup(). Referenced by init_with_orb().
00710 { 00711 return CORBA::string_dup (this->naming_service_ior_.in ()); 00712 } |
|
Returns a for the root Naming Context.
Definition at line 715 of file Naming_Server.cpp.
00716 { 00717 return this->naming_context_.ptr (); 00718 } |
|
parses the arguments.
Definition at line 161 of file Naming_Server.cpp. References ACE_ERROR_RETURN, ACE_INT64_FORMAT_SPECIFIER, ACE_TCHAR, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, ACE_OS::atoi(), context_size_, ior_file_name_, LM_ERROR, multicast_, persistence_file_name_, round_trip_timeout_, TAO_debug_level, use_redundancy_, use_round_trip_timeout_, and use_storable_context_. Referenced by init_with_orb().
00163 { 00164 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) 00165 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("b:do:p:s:f:m:u:r:z:")); 00166 #else 00167 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("b:do:p:s:f:m:z:")); 00168 #endif /* TAO_HAS_MINIMUM_POA */ 00169 00170 int c; 00171 int size, result; 00172 00173 // This is declared this way to avoid warnings from 00174 // some compilers that complain about mismatching types 00175 // in the sscanf. 00176 #if ACE_SIZEOF_VOID_P == ACE_SIZEOF_LONG_LONG 00177 ptrdiff_t address; 00178 #else 00179 long int address; 00180 #endif /* ACE_SIZEOF_VOID_P */ 00181 00182 // Make sure only one persistence option is specified 00183 int f_opt_used = 0; 00184 int u_opt_used = 0; 00185 int r_opt_used = 0; 00186 00187 while ((c = get_opts ()) != -1) 00188 switch (c) 00189 { 00190 case 'd': // debug flag. 00191 TAO_debug_level++; 00192 break; 00193 case 'o': // outputs the naming service ior to a file. 00194 this->ior_file_name_ = get_opts.opt_arg (); 00195 break; 00196 case 'p': 00197 this->pid_file_name_ = get_opts.opt_arg (); 00198 break; 00199 case 's': 00200 size = ACE_OS::atoi (get_opts.opt_arg ()); 00201 if (size >= 0) 00202 this->context_size_ = size; 00203 break; 00204 case 'b': 00205 result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (get_opts.opt_arg ()), 00206 #if ACE_SIZEOF_VOID_P == ACE_SIZEOF_LONG_LONG 00207 ACE_INT64_FORMAT_SPECIFIER, 00208 #else 00209 "%ld", 00210 #endif /* ACE_SIZEOF_VOID_P */ 00211 &address); 00212 if (result == 0 || result == EOF) 00213 ACE_ERROR_RETURN ((LM_ERROR, 00214 "Unable to process <-b> option"), 00215 -1); 00216 this->base_address_ = (void *) address; 00217 break; 00218 case 'm': 00219 this->multicast_ = ACE_OS::atoi(get_opts.opt_arg ()); 00220 break; 00221 case 'f': 00222 this->persistence_file_name_ = get_opts.opt_arg (); 00223 f_opt_used = 1; 00224 break; 00225 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) 00226 case 'r': 00227 this->use_redundancy_ = 1; 00228 this->use_storable_context_ = 1; 00229 this->persistence_file_name_ = get_opts.opt_arg (); 00230 r_opt_used = 1; 00231 break; 00232 case 'u': 00233 this->use_storable_context_ = 1; 00234 this->persistence_file_name_ = get_opts.opt_arg (); 00235 u_opt_used = 1; 00236 break; 00237 #endif /* TAO_HAS_MINIMUM_POA == 0 */ 00238 case 'z': 00239 this->use_round_trip_timeout_ = 1; 00240 this->round_trip_timeout_ = (int)1.0e7 * ACE_OS::atoi (get_opts.opt_arg ()); 00241 break; 00242 case '?': 00243 default: 00244 const ACE_TCHAR *reqNonMinCorba= 00245 #if (TAO_HAS_MINIMUM_POA == 0) 00246 ACE_TEXT (" -u <storable_persistence_directory (not used with -f)> ") 00247 ACE_TEXT (" -r <redundant_persistence_directory> "); 00248 #else 00249 ACE_TEXT (""); 00250 #endif /* TAO_HAS_MINIMUM_POA */ 00251 ACE_ERROR_RETURN ((LM_ERROR, 00252 ACE_TEXT ("usage: %s ") 00253 ACE_TEXT ("-d ") 00254 ACE_TEXT ("-o <ior_output_file> ") 00255 ACE_TEXT ("-p <pid_file_name> ") 00256 ACE_TEXT ("-s <context_size> ") 00257 ACE_TEXT ("-b <base_address> ") 00258 ACE_TEXT ("-m <1=enable multicast, 0=disable multicast(default) ") 00259 ACE_TEXT ("-f <persistence_file_name> %s") 00260 ACE_TEXT ("-z <relative round trip timeout> ") 00261 ACE_TEXT ("\n"), 00262 argv [0], reqNonMinCorba), 00263 -1); 00264 } 00265 00266 if (f_opt_used + u_opt_used + r_opt_used > 1) 00267 ACE_ERROR_RETURN ((LM_ERROR, 00268 ACE_TEXT ("Only one persistence option can be passed") 00269 ACE_TEXT ("\n")), 00270 -1); 00271 00272 return 0; 00273 } |
|
Address to be used for memory mapping Naming Service state file, identified by the . Definition at line 205 of file Naming_Server.h. |
|
Pointer to the object used to create/initialize the Naming Service when local persistent Naming Service is desired. Definition at line 174 of file Naming_Server.h. Referenced by fini(), and init_new_naming(). |
|
Size of the hash_table allocated upon the creation of the Naming Service context (if one is created). Note: all the contexts created under the given context will use the same size for their initial hash table allocations. Definition at line 197 of file Naming_Server.h. Referenced by init_with_orb(), and parse_args(). |
|
File to output the Naming Service IOR.
Definition at line 186 of file Naming_Server.h. Referenced by init_with_orb(), and parse_args(). |
|
The ior_multicast event handler.
Definition at line 164 of file Naming_Server.h. Referenced by fini(), and init_new_naming(). |
|
If not zero multicast is enabled.
Definition at line 208 of file Naming_Server.h. Referenced by init_with_orb(), and parse_args(). |
|
Root NamingContext_ptr.
Definition at line 161 of file Naming_Server.h. |
|
The IOR string of the root naming context.
Definition at line 167 of file Naming_Server.h. Referenced by init(), and init_new_naming(). |
|
The Naming Service POA.
Definition at line 183 of file Naming_Server.h. Referenced by fini(), init_new_naming(), and init_with_orb(). |
|
The ORB.
Definition at line 177 of file Naming_Server.h. |
|
Path to the file to be used to store/read in Naming Service persistent state. Definition at line 201 of file Naming_Server.h. Referenced by init_with_orb(), and parse_args(). |
|
File to output the process id.
Definition at line 189 of file Naming_Server.h. |
|
The Root POA.
Definition at line 180 of file Naming_Server.h. |
|
Definition at line 230 of file Naming_Server.h. Referenced by init_with_orb(), and parse_args(). |
|
Need to retain the servant activator between calls to init_with_orb() and init_new_naming(). Definition at line 222 of file Naming_Server.h. Referenced by ~TAO_Naming_Server(). |
|
If not zero support redundant naming servers. Definition at line 227 of file Naming_Server.h. Referenced by init_new_naming(), and parse_args(). |
|
Definition at line 231 of file Naming_Server.h. Referenced by init_with_orb(), and parse_args(). |
|
If not zero use servant activator that uses flat file persistence. Definition at line 216 of file Naming_Server.h. Referenced by init_new_naming(), init_with_orb(), and ~TAO_Naming_Server(). |
|
If not zero use flat file persistence.
Definition at line 211 of file Naming_Server.h. Referenced by init_with_orb(), and parse_args(). |