diff options
Diffstat (limited to 'TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp')
-rw-r--r-- | TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp | 175 |
1 files changed, 63 insertions, 112 deletions
diff --git a/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp b/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp index f5d171a3b4f..cf89d7d37c3 100644 --- a/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp +++ b/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp @@ -39,7 +39,7 @@ Object_Group_Factory_i::~Object_Group_Factory_i (void) } PortableServer::POA_ptr -Object_Group_Factory_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +Object_Group_Factory_i::_default_POA (void) ACE_THROW_SPEC ((CORBA::SystemException)) { return PortableServer::POA::_duplicate (this->poa_.in ()); @@ -47,8 +47,7 @@ Object_Group_Factory_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) Load_Balancer::Object_Group_ptr -Object_Group_Factory_i::make_round_robin (const char * id - ACE_ENV_ARG_DECL) +Object_Group_Factory_i::make_round_robin (const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::duplicate_group)) { @@ -60,7 +59,6 @@ Object_Group_Factory_i::make_round_robin (const char * id ACE_NEW_THROW_EX (this->rr_groups_, (hash_map) HASH_MAP (this->mem_pool_), CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); // Bind it in the mem pool with a name if (this->mem_pool_->bind (rr_name_bind, @@ -73,13 +71,11 @@ Object_Group_Factory_i::make_round_robin (const char * id } return this->make_group (0, - id - ACE_ENV_ARG_PARAMETER); + id); } void -Object_Group_Factory_i::unbind_round_robin (const char * id - ACE_ENV_ARG_DECL) +Object_Group_Factory_i::unbind_round_robin (const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_group)) { @@ -87,7 +83,7 @@ Object_Group_Factory_i::unbind_round_robin (const char * id { if (this->mem_pool_->find (rr_name_bind, (void *&)this->rr_groups_) == -1) - ACE_THROW (Load_Balancer::no_such_group ()); + throw Load_Balancer::no_such_group (); } char *int_id = 0; @@ -95,7 +91,7 @@ Object_Group_Factory_i::unbind_round_robin (const char * id // Throw an exception if not found in the HASH MAP if (this->rr_groups_->find (const_cast<char *> (id), this->mem_pool_) < 0) - ACE_THROW (Load_Balancer::no_such_group ()); + throw Load_Balancer::no_such_group (); // Unbind the entry this->rr_groups_->unbind (const_cast<char *> (id), @@ -119,8 +115,7 @@ Object_Group_Factory_i::unbind_round_robin (const char * id } Load_Balancer::Object_Group_ptr -Object_Group_Factory_i::make_random (const char * id - ACE_ENV_ARG_DECL) +Object_Group_Factory_i::make_random (const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::duplicate_group)) { @@ -132,7 +127,6 @@ Object_Group_Factory_i::make_random (const char * id ACE_NEW_THROW_EX (this->random_groups_, (hash_map) HASH_MAP (this->mem_pool_), CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); // Bind it in the mem pool with a name if (this->mem_pool_->bind (random_name_bind, @@ -145,14 +139,12 @@ Object_Group_Factory_i::make_random (const char * id } return this->make_group (1, - id - ACE_ENV_ARG_PARAMETER); + id); } void -Object_Group_Factory_i::unbind_random (const char * id - ACE_ENV_ARG_DECL) +Object_Group_Factory_i::unbind_random (const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_group)) { @@ -160,7 +152,7 @@ Object_Group_Factory_i::unbind_random (const char * id { if (this->mem_pool_->find (random_name_bind, (void *&)this->random_groups_) == -1) - ACE_THROW (Load_Balancer::no_such_group ()); + throw Load_Balancer::no_such_group (); } char *int_id = 0; @@ -168,7 +160,7 @@ Object_Group_Factory_i::unbind_random (const char * id // Throw an exception if not found in the HASH MAP if (this->random_groups_->find (const_cast<char *> (id), this->mem_pool_) < 0) - ACE_THROW (Load_Balancer::no_such_group ()); + throw Load_Balancer::no_such_group (); // Unbind the entry this->random_groups_->unbind (const_cast<char *> (id), @@ -192,8 +184,7 @@ Object_Group_Factory_i::unbind_random (const char * id Load_Balancer::Object_Group_ptr Object_Group_Factory_i::make_group (int random, - const char * id - ACE_ENV_ARG_DECL) + const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::duplicate_group)) { @@ -234,19 +225,14 @@ Object_Group_Factory_i::make_group (int random, RR_Object_Group (id, this->poa_.in ()), CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (group._retn ()); // Register with the poa, begin using ref. counting. - group = group_servant->_this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (group._retn ()); + group = group_servant->_this (); - group_servant->_remove_ref (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); + group_servant->_remove_ref (); CORBA::String_var ior = - this->orb_->object_to_string (group.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); + this->orb_->object_to_string (group.in ()); // Calculate and allocate the memory we need to store this name to @@ -286,9 +272,7 @@ Object_Group_Factory_i::make_group (int random, // Update the value of flags_ - this->update_flags (random - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); + this->update_flags (random); if (result == -1) { @@ -308,8 +292,7 @@ Object_Group_Factory_i::make_group (int random, Load_Balancer::Object_Group_ptr -Object_Group_Factory_i::resolve (const char * id - ACE_ENV_ARG_DECL) +Object_Group_Factory_i::resolve (const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_group)) { @@ -358,8 +341,7 @@ Object_Group_Factory_i::resolve (const char * id { this->mem_pool_->find (flags_name_bind, (void *&)this->flags_); - this->update_objects (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); + this->update_objects (); } char *ior = 0; @@ -374,15 +356,11 @@ Object_Group_Factory_i::resolve (const char * id 0); CORBA::Object_var objref = - this->orb_->string_to_object (ior - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); + this->orb_->string_to_object (ior); Load_Balancer::Object_Group_ptr - object_group = Load_Balancer::Object_Group::_narrow (objref.in () - ACE_ENV_ARG_PARAMETER); + object_group = Load_Balancer::Object_Group::_narrow (objref.in ()); - ACE_CHECK_RETURN (Load_Balancer::Object_Group::_nil ()); #if defined (DOORS_MEASURE_STATS) @@ -402,8 +380,7 @@ Object_Group_Factory_i::resolve (const char * id } Load_Balancer::Group_List * -Object_Group_Factory_i::list_groups (int random - ACE_ENV_ARG_DECL) +Object_Group_Factory_i::list_groups (int random) { Load_Balancer::Group_List * list; @@ -418,7 +395,6 @@ Object_Group_Factory_i::list_groups (int random ACE_NEW_THROW_EX (list, Load_Balancer::Group_List (len), CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (list); list->length (len); // Create an iterator for group structure to populate the list. @@ -444,23 +420,22 @@ Object_Group_Factory_i::list_groups (int random } Load_Balancer::Group_List * -Object_Group_Factory_i::round_robin_groups (ACE_ENV_SINGLE_ARG_DECL) +Object_Group_Factory_i::round_robin_groups (void) ACE_THROW_SPEC ((CORBA::SystemException)) { - return list_groups (0 ACE_ENV_ARG_PARAMETER); + return list_groups (0); } Load_Balancer::Group_List * -Object_Group_Factory_i::random_groups (ACE_ENV_SINGLE_ARG_DECL) +Object_Group_Factory_i::random_groups (void) ACE_THROW_SPEC ((CORBA::SystemException)) { - return list_groups (1 ACE_ENV_ARG_PARAMETER); + return list_groups (1); } void -Object_Group_Factory_i::update_flags (int random - ACE_ENV_ARG_DECL) +Object_Group_Factory_i::update_flags (int random) { //First check whether we have memory for flags_ if (!this->flags_) @@ -473,7 +448,6 @@ Object_Group_Factory_i::update_flags (int random ACE_NEW_THROW_EX (this->flags_, (value) CORBA::Short (0), CORBA::NO_MEMORY ()); - ACE_CHECK; // Initialize the variable this->mem_pool_->bind (flags_name_bind, @@ -503,7 +477,7 @@ Object_Group_Factory_i::update_flags (int random } void -Object_Group_Factory_i::update_objects (ACE_ENV_SINGLE_ARG_DECL) +Object_Group_Factory_i::update_objects (void) { // Create an appropriate servant. Object_Group_i * group_servant = 0; @@ -583,7 +557,7 @@ Object_Group_i::~Object_Group_i (void) PortableServer::POA_ptr -Object_Group_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +Object_Group_i::_default_POA (void) ACE_THROW_SPEC ((CORBA::SystemException)) { return PortableServer::POA::_duplicate (this->poa_.in ()); @@ -591,23 +565,21 @@ Object_Group_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) char * -Object_Group_i::id (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +Object_Group_i::id (void) ACE_THROW_SPEC ((CORBA::SystemException)) { return CORBA::string_dup (id_.c_str ()); } void -Object_Group_i::bind (const Load_Balancer::Member & member - ACE_ENV_ARG_DECL) +Object_Group_i::bind (const Load_Balancer::Member & member) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::duplicate_member)) { if (this->members_ == 0) { - ACE_CString id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + ACE_CString id = this->id (); id += server_id_name_bind; @@ -617,7 +589,6 @@ Object_Group_i::bind (const Load_Balancer::Member & member ACE_NEW_THROW_EX (this->members_, (hash_map) HASH_MAP (this->allocator_), CORBA::NO_MEMORY ()); - ACE_CHECK; // Bind it in the mem pool with a name if (this->allocator_->bind (id.c_str (), @@ -633,7 +604,7 @@ Object_Group_i::bind (const Load_Balancer::Member & member // Check whether the element already exists.. if (this->members_->find (const_cast<char *> ((const char *) member.id), this->allocator_) == 0) - ACE_THROW (Load_Balancer::duplicate_member ()); + throw Load_Balancer::duplicate_member (); size_t id_len = ACE_OS::strlen (member.id) + 1; size_t ref_len = ACE_OS::strlen (member.obj) + 1; @@ -641,7 +612,7 @@ Object_Group_i::bind (const Load_Balancer::Member & member char *mem_alloc = (char *)this->allocator_->malloc (id_len + ref_len); if (mem_alloc == 0) - ACE_THROW (CORBA::NO_MEMORY ()); + throw CORBA::NO_MEMORY (); char **id_ptr = (char **)this->allocator_->malloc (sizeof (char *)); *id_ptr = mem_alloc; @@ -656,16 +627,15 @@ Object_Group_i::bind (const Load_Balancer::Member & member ior_ptr); if (result == 1) - ACE_THROW (Load_Balancer::duplicate_member ()); + throw Load_Balancer::duplicate_member (); else if (result == -1) - ACE_THROW (CORBA::INTERNAL ()); + throw CORBA::INTERNAL (); // Search the list first from the mem mapp pool and then Insert new // member's id into <member_id_list_>. ACE_CString id = dll_name_bind; - id += this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + id += this->id (); if (this->allocator_->find (id.c_str (), @@ -676,7 +646,6 @@ Object_Group_i::bind (const Load_Balancer::Member & member ACE_NEW_THROW_EX (this->member_id_list_, (dll_list) LIST (this->allocator_), CORBA::NO_MEMORY ()); - ACE_CHECK; // Bind it in the mem pool with a name if (this->allocator_->bind (id.c_str (), @@ -689,7 +658,7 @@ Object_Group_i::bind (const Load_Balancer::Member & member } if (member_id_list_->insert_tail (id_ptr) == 0) - ACE_THROW (CORBA::NO_MEMORY ()); + throw CORBA::NO_MEMORY (); // Theoretically, we should deal with memory failures more // thoroughly. But, practically, the whole system is going to be @@ -697,29 +666,27 @@ Object_Group_i::bind (const Load_Balancer::Member & member } void -Object_Group_i::unbind (const char * id - ACE_ENV_ARG_DECL) +Object_Group_i::unbind (const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_member)) { // Check whether the this->member_ is NULL if (this->members_ == 0) { - ACE_CString id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + ACE_CString id = this->id (); id += server_id_name_bind; if (this->allocator_->find (id.c_str (), (void *&)this->members_) == -1) { - ACE_THROW (Load_Balancer::no_such_member ()); + throw Load_Balancer::no_such_member (); } } // Check to make sure we have it. if (this->members_->find (const_cast<char *> (id), this->allocator_) == -1) - ACE_THROW (Load_Balancer::no_such_member ()); + throw Load_Balancer::no_such_member (); // Remove all entries for this member. this->members_->unbind (const_cast<char *> (id), @@ -728,13 +695,12 @@ Object_Group_i::unbind (const char * id if (this->member_id_list_ == 0) { ACE_CString id = dll_name_bind; - id += this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + id += this->id (); if (this->allocator_->find (id.c_str (), (void *&)this->member_id_list_) == -1) - ACE_THROW (Load_Balancer::no_such_member ()); + throw Load_Balancer::no_such_member (); } @@ -751,8 +717,7 @@ Object_Group_i::unbind (const char * id } char * -Object_Group_i::resolve_with_id (const char * id - ACE_ENV_ARG_DECL) +Object_Group_i::resolve_with_id (const char * id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_member)) { @@ -771,13 +736,12 @@ Object_Group_i::resolve_with_id (const char * id } Load_Balancer::Member_ID_List * -Object_Group_i::members (ACE_ENV_SINGLE_ARG_DECL) +Object_Group_i::members (void) ACE_THROW_SPEC ((CORBA::SystemException)) { Load_Balancer::Member_ID_List * list = 0; - this->read_from_memory (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + this->read_from_memory (); // Figure out the length of the list. CORBA::ULong len = this->members_->current_size (); @@ -786,7 +750,6 @@ Object_Group_i::members (ACE_ENV_SINGLE_ARG_DECL) ACE_NEW_THROW_EX (list, Load_Balancer::Member_ID_List (len), CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (list); list->length (len); // Create an iterator for <member_id_list_> to populate the list. @@ -805,30 +768,24 @@ Object_Group_i::members (ACE_ENV_SINGLE_ARG_DECL) } void -Object_Group_i::destroy (ACE_ENV_SINGLE_ARG_DECL) +Object_Group_i::destroy (void) ACE_THROW_SPEC ((CORBA::SystemException)) { // Deregister with POA. PortableServer::POA_var poa = - this->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + this->_default_POA (); PortableServer::ObjectId_var id = - poa->servant_to_id (this - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + poa->servant_to_id (this); - poa->deactivate_object (id.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + poa->deactivate_object (id.in ()); } void -Object_Group_i::read_from_memory (ACE_ENV_SINGLE_ARG_DECL) +Object_Group_i::read_from_memory (void) { // Sanity check needs to be done in all the places - ACE_CString id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + ACE_CString id = this->id (); if (!this->members_) { @@ -846,8 +803,7 @@ Object_Group_i::read_from_memory (ACE_ENV_SINGLE_ARG_DECL) if (!this->member_id_list_) { id = dll_name_bind; - id += this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + id += this->id (); if (this->allocator_->find (id.c_str (), (void *&)this->member_id_list_) == -1) @@ -869,13 +825,12 @@ Random_Object_Group::Random_Object_Group (const char *id, } char * -Random_Object_Group::resolve (ACE_ENV_SINGLE_ARG_DECL) +Random_Object_Group::resolve (void) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_member)) { - this->read_from_memory (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + this->read_from_memory (); size_t group_size = this->members_->current_size (); if (group_size == 0) @@ -909,14 +864,13 @@ RR_Object_Group::RR_Object_Group (const char *id, } char * -RR_Object_Group::resolve (ACE_ENV_SINGLE_ARG_DECL) +RR_Object_Group::resolve (void) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_member)) { char *objref = 0; - this->read_from_memory (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + this->read_from_memory (); size_t group_size = this->members_->current_size (); if (group_size == 0) @@ -946,30 +900,28 @@ RR_Object_Group::resolve (ACE_ENV_SINGLE_ARG_DECL) } void -RR_Object_Group::unbind (const char *id - ACE_ENV_ARG_DECL) +RR_Object_Group::unbind (const char *id) ACE_THROW_SPEC ((CORBA::SystemException, Load_Balancer::no_such_member)) { if (this->members_ == 0) { - ACE_CString id = this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + ACE_CString id = this->id (); id += server_id_name_bind; if (this->allocator_->find (id.c_str (), (void *&)this->members_) == -1) { - ACE_THROW (Load_Balancer::no_such_member ()); + throw Load_Balancer::no_such_member (); } } // Check to make sure we have it. if (this->members_->find (const_cast<char *> (id), this->allocator_) == -1) - ACE_THROW (Load_Balancer::no_such_member ()); + throw Load_Balancer::no_such_member (); // Remove all entries for this member. this->members_->unbind (const_cast<char *> (id), @@ -980,13 +932,12 @@ RR_Object_Group::unbind (const char *id if (this->member_id_list_ == 0) { ACE_CString id = dll_name_bind; - id += this->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; + id += this->id (); if (this->allocator_->find (id.c_str (), (void *&)this->member_id_list_) == -1) - ACE_THROW (Load_Balancer::no_such_member ()); + throw Load_Balancer::no_such_member (); } |