diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2007-03-27 17:52:05 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2007-03-27 17:52:05 +0000 |
commit | dbe832aff19a1dc858b7700a666cd96d42db2c14 (patch) | |
tree | 1290a7a75464ddb02abc0d87d894616cf658625a /TAO/examples/Load_Balancing_persistent | |
parent | 91d549cf6b007bc1fa89b866a1b0367580e5506b (diff) | |
download | ATCD-dbe832aff19a1dc858b7700a666cd96d42db2c14.tar.gz |
ChangeLogTag:Tue Mar 27 17:50:38 UTC 2007 William R. Otte <wotte@dre.vanderbilt.edu>
Diffstat (limited to 'TAO/examples/Load_Balancing_persistent')
-rw-r--r-- | TAO/examples/Load_Balancing_persistent/Identity_Server.cpp | 22 | ||||
-rw-r--r-- | TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp | 149 |
2 files changed, 136 insertions, 35 deletions
diff --git a/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp b/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp index d3b78ac3686..409745deb33 100644 --- a/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp +++ b/TAO/examples/Load_Balancing_persistent/Identity_Server.cpp @@ -148,11 +148,22 @@ Identity_Server::register_groups (void) // We want to make two groups Random & Round Robin. Load_Balancer::Object_Group_var random_group = factory->make_random ("Random group"); - + + if (CORBA::is_nil (random_group)) + { + ACE_ERROR ((LM_ERROR, "Got nil random group from load balancer\n")); + return -1; + } + Load_Balancer::Object_Group_var rr_group = factory->make_round_robin ("Round Robin group"); - - + + if (CORBA::is_nil (rr_group)) + { + ACE_ERROR ((LM_ERROR, "Got nil round robin group from load balancer\n")); + return -1; + } + // Create the requested number of <Identity> objects, and // register them with the random and round robin // <Object_Group>s. @@ -243,7 +254,10 @@ main (int argc, char *argv[]) try { result = server.register_groups (); - + + if (result != 0) + return 1; + result = server.run (); } catch (const CORBA::Exception& ex) diff --git a/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp b/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp index 07f96faaa63..4171240eaf2 100644 --- a/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp +++ b/TAO/examples/Load_Balancing_persistent/Load_Balancer_i.cpp @@ -48,9 +48,15 @@ Object_Group_Factory_i::_default_POA (void) Load_Balancer::Object_Group_ptr Object_Group_Factory_i::make_round_robin (const char * id) { - + + void *tmp_rr (0); + if (this->mem_pool_->find (rr_name_bind, - (void *&)this->rr_groups_) == -1) + tmp_rr) == 0) + { + this->rr_groups_ = reinterpret_cast <HASH_MAP *> (tmp_rr); + } + else { void *hash_map = this->mem_pool_->malloc (sizeof (HASH_MAP)); ACE_NEW_THROW_EX (this->rr_groups_, @@ -76,9 +82,13 @@ Object_Group_Factory_i::unbind_round_robin (const char * id) { if (this->rr_groups_ == 0) { + void *tmp_rr (0); + if (this->mem_pool_->find (rr_name_bind, - (void *&)this->rr_groups_) == -1) + tmp_rr) == -1) throw Load_Balancer::no_such_group (); + + this->rr_groups_ = reinterpret_cast <HASH_MAP *> (tmp_rr); } char *int_id = 0; @@ -99,9 +109,13 @@ Object_Group_Factory_i::unbind_round_robin (const char * id) // Change the FLAGS variable if (this->flags_ == 0) { + void *tmp_flags (0); + if (this->mem_pool_->find (flags_name_bind, - (void *&)this->flags_) == -1) + tmp_flags) == -1) return; + + this->flags_ = reinterpret_cast <CORBA::Short *> (tmp_flags); } // Bump down the flags value @@ -112,8 +126,13 @@ Object_Group_Factory_i::unbind_round_robin (const char * id) Load_Balancer::Object_Group_ptr Object_Group_Factory_i::make_random (const char * id) { - - if (this->mem_pool_->find (random_name_bind, (void * &)this->random_groups_) == -1) + void *tmp_random (0); + + if (this->mem_pool_->find (random_name_bind, tmp_random) == 0) + { + this->random_groups_ = reinterpret_cast <HASH_MAP *> (tmp_random); + } + else { void *hash_map = this->mem_pool_->malloc (sizeof (HASH_MAP)); @@ -141,9 +160,13 @@ Object_Group_Factory_i::unbind_random (const char * id) { if (this->random_groups_ == 0) { + void *tmp_random (0); + if (this->mem_pool_->find (random_name_bind, - (void *&)this->random_groups_) == -1) + tmp_random) == -1) throw Load_Balancer::no_such_group (); + + this->random_groups_ = reinterpret_cast <HASH_MAP *> (tmp_random); } char *int_id = 0; @@ -164,9 +187,13 @@ Object_Group_Factory_i::unbind_random (const char * id) // Change the FLAGS variable if (this->flags_ == 0) { + void *tmp_flags (0); + if (this->mem_pool_->find (flags_name_bind, - (void *&)this->flags_) == -1) + tmp_flags) == -1) return; + + this->flags_ = reinterpret_cast <CORBA::Short *> (tmp_flags); } // Bump down the flags value @@ -297,8 +324,14 @@ Object_Group_Factory_i::resolve (const char * id) // MMAP file for the relevant info.. if (!this->rr_groups_) { + void *tmp_rr (0); + if (this->mem_pool_->find (rr_name_bind, - (void *&)this->rr_groups_) == -1) + tmp_rr) == 0) + { + this->rr_groups_ = reinterpret_cast <HASH_MAP *> (tmp_rr); + } + else { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%N|%l) The factory does not have any references ") @@ -309,8 +342,14 @@ Object_Group_Factory_i::resolve (const char * id) if (!this->random_groups_) { + void *tmp_random (0); + if (this->mem_pool_->find (random_name_bind, - (void *&)this->random_groups_) == -1) + tmp_random) == 0) + { + this->random_groups_ = reinterpret_cast <HASH_MAP *> (tmp_random); + } + else { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%N|%l) The factory does not have any references ") @@ -322,8 +361,12 @@ Object_Group_Factory_i::resolve (const char * id) if (!this->flags_) { + void *tmp_flags (0); + this->mem_pool_->find (flags_name_bind, - (void *&)this->flags_); + tmp_flags); + this->flags_ = reinterpret_cast <CORBA::Short *> (tmp_flags); + this->update_objects (); } @@ -420,8 +463,14 @@ Object_Group_Factory_i::update_flags (int random) //First check whether we have memory for flags_ if (!this->flags_) { + void *tmp_flags (0); + if (this->mem_pool_->find (flags_name_bind, - (void *&) this->flags_) == -1) + tmp_flags) == 0) + { + this->flags_ = reinterpret_cast <CORBA::Short *> (tmp_flags); + } + else { void *value = this->mem_pool_->malloc (sizeof (CORBA::Short)); @@ -558,8 +607,14 @@ Object_Group_i::bind (const Load_Balancer::Member & member) ACE_CString id = this->id (); id += server_id_name_bind; - - if (this->allocator_->find (id.c_str (), (void *&)this->members_) == -1) + + void *tmp_members (0); + + if (this->allocator_->find (id.c_str (), tmp_members) == 0) + { + this->members_ = reinterpret_cast <HASH_MAP *> (tmp_members); + } + else { void *hash_map = this->allocator_->malloc (sizeof (HASH_MAP)); ACE_NEW_THROW_EX (this->members_, @@ -613,10 +668,16 @@ Object_Group_i::bind (const Load_Balancer::Member & member) ACE_CString id = dll_name_bind; id += this->id (); - + + void *tmp_id_list (0); + if (this->allocator_->find (id.c_str (), - (void *&)this->member_id_list_) - == -1) + tmp_id_list) + == 0) + { + this->member_id_list_ = reinterpret_cast <LIST *> (tmp_id_list); + } + else { void *dll_list = this->allocator_->malloc (sizeof (LIST)); ACE_NEW_THROW_EX (this->member_id_list_, @@ -650,12 +711,16 @@ Object_Group_i::unbind (const char * id) ACE_CString id = this->id (); id += server_id_name_bind; - + + void *tmp_members (0); + if (this->allocator_->find (id.c_str (), - (void *&)this->members_) == -1) + tmp_members) == -1) { throw Load_Balancer::no_such_member (); } + + this->members_ = reinterpret_cast <HASH_MAP *> (tmp_members); } // Check to make sure we have it. if (this->members_->find (const_cast<char *> (id), @@ -670,12 +735,15 @@ Object_Group_i::unbind (const char * id) { ACE_CString id = dll_name_bind; id += this->id (); - + + void *tmp_id_list (0); + if (this->allocator_->find (id.c_str (), - (void *&)this->member_id_list_) + tmp_id_list) == -1) throw Load_Balancer::no_such_member (); - + + this->member_id_list_ = reinterpret_cast <LIST *> (tmp_id_list); } @@ -759,9 +827,15 @@ Object_Group_i::read_from_memory (void) if (!this->members_) { id += server_id_name_bind; - + + void *tmp_members (0); + if (this->allocator_->find (id.c_str (), - (void *&)this->members_) == -1) + tmp_members) == 0) + { + this->members_ = reinterpret_cast <HASH_MAP *> (tmp_members); + } + else { ACE_ERROR ((LM_ERROR, "Unable to find tha HASH MAP in the MMAP file \n")); @@ -773,9 +847,15 @@ Object_Group_i::read_from_memory (void) { id = dll_name_bind; id += this->id (); - + + void *tmp_id_list (0); + if (this->allocator_->find (id.c_str (), - (void *&)this->member_id_list_) == -1) + tmp_id_list) == 0) + { + this->member_id_list_ = reinterpret_cast <LIST *> (tmp_id_list); + } + else { ACE_ERROR ((LM_ERROR, "Unable to find tha HASH MAP in the MMAP file \n")); @@ -870,12 +950,16 @@ RR_Object_Group::unbind (const char *id) ACE_CString id = this->id (); id += server_id_name_bind; - + + void *tmp_members (0); + if (this->allocator_->find (id.c_str (), - (void *&)this->members_) == -1) + tmp_members) == -1) { throw Load_Balancer::no_such_member (); } + + this->members_ = reinterpret_cast <HASH_MAP *> (tmp_members); } // Check to make sure we have it. @@ -893,12 +977,15 @@ RR_Object_Group::unbind (const char *id) { ACE_CString id = dll_name_bind; id += this->id (); - + + void *tmp_id_list (0); + if (this->allocator_->find (id.c_str (), - (void *&)this->member_id_list_) + tmp_id_list) == -1) throw Load_Balancer::no_such_member (); - + + this->member_id_list_ = reinterpret_cast <LIST *> (tmp_id_list); } size_t position = 0; |