#include <PG_ObjectGroupManager.h>
Collaboration diagram for TAO_PG_ObjectGroupManager:
Public Member Functions | |
TAO_PG_ObjectGroupManager (void) | |
Constructor. | |
~TAO_PG_ObjectGroupManager (void) | |
Destructor. | |
PortableGroup::ObjectGroup_ptr | _tao_add_member (PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location &the_location, CORBA::Object_ptr member, const char *type_id, const CORBA::Boolean propagate_member_already_present) |
TAO-specific member addition method. | |
PortableGroup::ObjectGroup_ptr | create_object_group (CORBA::ULong group_id, const PortableServer::ObjectId &oid, const char *type_id, const PortableGroup::Criteria &the_criteria) |
void | destroy_object_group (const PortableServer::ObjectId &oid) |
Destroy the object group corresponding to the given ObjectId. | |
PortableGroup::Properties * | get_properties (PortableGroup::ObjectGroup_ptr object_group) |
char * | type_id (PortableGroup::ObjectGroup_ptr object_group) |
Return the type_id for the given object group. | |
PortableGroup::ObjectGroup_ptr | object_group (const PortableServer::ObjectId &oid) |
Return the object group associated with the given ObjectId. | |
CORBA::ULong | member_count (PortableGroup::ObjectGroup_ptr group) |
Return the number of members in the given object group. | |
void | poa (PortableServer::POA_ptr p) |
void | generic_factory (TAO_PG_GenericFactory *generic_factory) |
PortableGroup::ObjectGroupManager methods | |
virtual PortableGroup::ObjectGroup_ptr | create_member (PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location &the_location, const char *type_id, const PortableGroup::Criteria &the_criteria) |
Create a member and add it to the given object group. | |
virtual PortableGroup::ObjectGroup_ptr | add_member (PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location &the_location, CORBA::Object_ptr member) |
Add an existing object to the ObjectGroup. | |
virtual PortableGroup::ObjectGroup_ptr | remove_member (PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location &the_location) |
virtual PortableGroup::Locations * | locations_of_members (PortableGroup::ObjectGroup_ptr object_group) |
Return the locations of the members in the given ObjectGroup. | |
virtual PortableGroup::ObjectGroups * | groups_at_location (const PortableGroup::Location &the_location) |
Return the locations of the members in the given ObjectGroup. | |
virtual PortableGroup::ObjectGroupId | get_object_group_id (PortableGroup::ObjectGroup_ptr object_group) |
virtual PortableGroup::ObjectGroup_ptr | get_object_group_ref (PortableGroup::ObjectGroup_ptr object_group) |
Does this method make sense for load balanced objects? | |
virtual CORBA::Object_ptr | get_member_ref (PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location &loc) |
virtual PortableGroup::ObjectGroup_ptr | get_object_group_ref_from_id (PortableGroup::ObjectGroupId group_id) |
Protected Member Functions | |
PortableGroup::ObjectGroup_ptr | add_member_i (PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location &the_location, CORBA::Object_ptr member, const CORBA::Boolean check_type_id) |
TAO_PG_ObjectGroup_Map_Entry * | get_group_entry (PortableGroup::ObjectGroup_ptr object_group) |
CORBA::Boolean | member_already_present (const TAO_PG_ObjectGroup_Array &groups, TAO_PG_ObjectGroup_Map_Entry *group_entry) |
size_t | get_object_group_position (const TAO_PG_ObjectGroup_Array &groups, TAO_PG_ObjectGroup_Map_Entry *group_entry) |
get the position of the object_group_map_entry | |
CORBA::Boolean | valid_type_id (PortableGroup::ObjectGroup_ptr object_group, TAO_PG_ObjectGroup_Map_Entry *group_entry, CORBA::Object_ptr member) |
Verify that the member type_id matches the object group type_id. | |
Private Attributes | |
PortableServer::POA_var | poa_ |
Reference to the POA that created the object group references. | |
TAO_PG_ObjectGroup_Map | object_group_map_ |
TAO_PG_Location_Map | location_map_ |
TAO_PG_GenericFactory * | generic_factory_ |
TAO_SYNCH_MUTEX | lock_ |
Lock used to synchronize access to the underlying tables. |
The ObjectGroupManager provides the interface necessary to facilitate application-controlled object group membership.
Definition at line 47 of file PG_ObjectGroupManager.h.
|
Constructor.
Definition at line 19 of file PG_ObjectGroupManager.cpp. References TAO_PG_MAX_LOCATIONS, and TAO_PG_MAX_OBJECT_GROUPS.
00020 : poa_ (), 00021 object_group_map_ (TAO_PG_MAX_OBJECT_GROUPS), 00022 location_map_ (TAO_PG_MAX_LOCATIONS), 00023 generic_factory_ (0), 00024 lock_ () 00025 { 00026 } |
|
Destructor.
Definition at line 28 of file PG_ObjectGroupManager.cpp. References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::begin(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::close(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::end(), location_map_, and object_group_map_.
00029 { 00030 for (TAO_PG_Location_Map::iterator i = this->location_map_.begin (); 00031 i != this->location_map_.end (); 00032 ++i) 00033 { 00034 // Destroy the group array 00035 delete (*i).int_id_; 00036 } 00037 (void) this->location_map_.close (); 00038 00039 for (TAO_PG_ObjectGroup_Map::iterator j = this->object_group_map_.begin (); 00040 j != this->object_group_map_.end (); 00041 ++j) 00042 { 00043 // Destroy the object group entry 00044 delete (*j).int_id_; 00045 } 00046 (void) this->object_group_map_.close (); 00047 } |
|
TAO-specific member addition method. This method is meant to be invoked by TAO's GenericFactory implementation. It is designed to allow only certain exceptions to be propagated to the caller, and to prevent redundant remote RepositoryId checking. Definition at line 86 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, add_member_i(), CORBA::is_nil(), PortableGroup::Location, and TAO_SYNCH_MUTEX. Referenced by TAO_PG_GenericFactory::create_member().
00092 { 00093 if (CORBA::is_nil (member)) 00094 throw CORBA::BAD_PARAM (); 00095 00096 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00097 guard, 00098 this->lock_, 00099 PortableGroup::ObjectGroup::_nil ()); 00100 00101 PortableGroup::ObjectGroup_var new_group; 00102 00103 try 00104 { 00105 // TypeId already checked by GenericFactory. 00106 const CORBA::Boolean check_type_id = 0; 00107 00108 new_group = this->add_member_i (object_group, 00109 the_location, 00110 member, 00111 check_type_id); 00112 } 00113 catch (const PortableGroup::ObjectGroupNotFound&) 00114 { 00115 throw CORBA::INTERNAL (); 00116 } 00117 catch (const PortableGroup::MemberAlreadyPresent&) 00118 { 00119 if (propagate_member_already_present) 00120 throw; 00121 else 00122 throw CORBA::INTERNAL (); 00123 } 00124 catch (const PortableGroup::ObjectNotAdded&) 00125 { 00126 throw PortableGroup::NoFactory (the_location, type_id); 00127 } 00128 00129 return new_group._retn (); 00130 } |
|
Add an existing object to the ObjectGroup.
Definition at line 60 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, add_member_i(), CORBA::is_nil(), PortableGroup::Location, and TAO_SYNCH_MUTEX.
00064 { 00065 if (CORBA::is_nil (member)) 00066 throw CORBA::BAD_PARAM (); 00067 00068 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00069 guard, 00070 this->lock_, 00071 PortableGroup::ObjectGroup::_nil ()); 00072 00073 // Verify that the member's RepositoryId matches the object group's 00074 // type ID. 00075 const CORBA::Boolean check_type_id = 1; 00076 00077 return this->add_member_i (object_group, 00078 the_location, 00079 member, 00080 check_type_id); 00081 00082 } |
|
Underlying and non-locking implementation of the add_member() and _tao_add_member() methods in this class. Definition at line 133 of file PG_ObjectGroupManager.cpp. References CORBA::Object::_duplicate(), ACE_NEW_THROW_EX, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), get_group_entry(), TAO_PG_MemberInfo::location, PortableGroup::Location, location_map_, TAO_PG_MemberInfo::member, member_already_present(), ACE_Auto_Basic_Ptr< X >::release(), ACE_Array_Base< T >::size(), TAO_PG_ObjectGroup_Array, and valid_type_id(). Referenced by _tao_add_member(), and add_member().
00138 { 00139 TAO_PG_ObjectGroup_Map_Entry * group_entry = 00140 this->get_group_entry (object_group); 00141 00142 if (check_type_id) 00143 { 00144 CORBA::Boolean right_type_id = 00145 this->valid_type_id (object_group, 00146 group_entry, 00147 member); 00148 00149 if (!right_type_id) 00150 { 00151 // The member's type_id does not match the object group's 00152 // type_id. 00153 throw PortableGroup::ObjectNotAdded (); 00154 } 00155 } 00156 00157 TAO_PG_ObjectGroup_Array * groups = 0; 00158 if (this->location_map_.find (the_location, groups) == 0 00159 && this->member_already_present (*groups, group_entry)) 00160 throw PortableGroup::MemberAlreadyPresent (); 00161 00162 TAO_PG_MemberInfo member_info; 00163 member_info.member = CORBA::Object::_duplicate (member); 00164 member_info.location = the_location; 00165 00166 if (groups == 0) 00167 { 00168 ACE_NEW_THROW_EX (groups, 00169 TAO_PG_ObjectGroup_Array, 00170 CORBA::NO_MEMORY ( 00171 CORBA::SystemException::_tao_minor_code ( 00172 TAO::VMCID, 00173 ENOMEM), 00174 CORBA::COMPLETED_NO)); 00175 00176 auto_ptr<TAO_PG_ObjectGroup_Array> safe_groups (groups); 00177 00178 // This should not fail! 00179 if (this->location_map_.bind (the_location, groups) != 0) 00180 { 00181 throw PortableGroup::ObjectNotAdded (); 00182 } 00183 00184 (void) safe_groups.release (); 00185 } 00186 00187 // No object group member of the object group with the given 00188 // ObjectGroupId resides at the location. Add the object group 00189 // entry to array of object groups residing at the location. 00190 const size_t groups_len = groups->size (); 00191 groups->size (groups_len + 1); 00192 (*groups)[groups_len] = group_entry; 00193 00194 // Don't bother checking for duplicates since a check is already 00195 // performed when binding to the location map above. 00196 if (group_entry->member_infos.insert_tail (member_info) != 0) 00197 throw PortableGroup::ObjectNotAdded (); 00198 00199 return PortableGroup::ObjectGroup::_duplicate (object_group); 00200 } |
|
Create a member and add it to the given object group.
Definition at line 50 of file PG_ObjectGroupManager.cpp. References PortableGroup::Criteria, and PortableGroup::Location.
00055 {
00056 throw CORBA::NO_IMPLEMENT ();
00057 }
|
|
Definition at line 459 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, ACE_NEW_THROW_EX, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::bind(), PortableGroup::Criteria, TAO_PG_ObjectGroup_Map_Entry::group_id, CORBA::is_nil(), TAO_PG_ObjectGroup_Map_Entry::object_group, object_group_map_, TAO_PG_ObjectGroup_Map_Entry::properties, ACE_Auto_Basic_Ptr< X >::release(), CORBA::string_dup(), TAO_SYNCH_MUTEX, and TAO_PG_ObjectGroup_Map_Entry::type_id. Referenced by TAO_PG_GenericFactory::create_object().
00464 { 00465 if (CORBA::is_nil (this->poa_.in ())) 00466 throw CORBA::INTERNAL (); 00467 00468 // Create a reference for the ObjectGroup corresponding to the 00469 // RepositoryId of the object being created. 00470 CORBA::Object_var object_group = 00471 this->poa_->create_reference_with_id (oid, 00472 type_id); 00473 00474 TAO_PG_ObjectGroup_Map_Entry * group_entry = 0; 00475 ACE_NEW_THROW_EX (group_entry, 00476 TAO_PG_ObjectGroup_Map_Entry, 00477 CORBA::NO_MEMORY ( 00478 CORBA::SystemException::_tao_minor_code ( 00479 TAO::VMCID, 00480 ENOMEM), 00481 CORBA::COMPLETED_NO)); 00482 00483 auto_ptr<TAO_PG_ObjectGroup_Map_Entry> safe_group_entry (group_entry); 00484 00485 // Set the RepositoryId associated with the created ObjectGroup_Map 00486 // entry. 00487 group_entry->type_id = CORBA::string_dup (type_id); 00488 00489 group_entry->group_id = group_id; 00490 00491 group_entry->object_group = object_group; 00492 00493 CORBA::ULong len = the_criteria.length (); 00494 group_entry->properties.length (len); 00495 for (CORBA::ULong i = 0; i < len; ++i) 00496 group_entry->properties[i] = the_criteria[i]; 00497 00498 { 00499 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00500 guard, 00501 this->lock_, 00502 0); 00503 00504 if (this->object_group_map_.bind (oid, group_entry) != 0) 00505 throw PortableGroup::ObjectNotCreated (); 00506 } 00507 00508 (void) safe_group_entry.release (); 00509 00510 return object_group._retn (); 00511 } |
|
Destroy the object group corresponding to the given ObjectId.
Definition at line 514 of file PG_ObjectGroupManager.cpp. References ACE_GUARD, object_group_map_, TAO_SYNCH_MUTEX, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind(). Referenced by TAO_PG_GenericFactory::create_object(), TAO_PG_GenericFactory::delete_object(), and TAO_PG_Group_Guard::~TAO_PG_Group_Guard().
00516 { 00517 ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_); 00518 00519 TAO_PG_ObjectGroup_Map_Entry * group_entry = 0; 00520 if (this->object_group_map_.unbind (oid, group_entry) != 0) 00521 throw PortableGroup::ObjectNotFound (); 00522 00523 delete group_entry; 00524 } |
|
The TAO_PG_GenericFactory will only be used when ObjectGroupManager::remove_member() is explicitly called so that the infrastructure may be given an opportunity to clean up any object group members it may have created. Definition at line 746 of file PG_ObjectGroupManager.cpp. Referenced by TAO_PG_GenericFactory::TAO_PG_GenericFactory().
00748 { 00749 this->generic_factory_ = generic_factory; 00750 } |
|
Obtain the ObjectGroup hash map entry corresponding to the given ObjectGroup reference. Referenced by add_member_i(), get_member_ref(), get_object_group_id(), get_object_group_ref(), get_properties(), locations_of_members(), member_count(), remove_member(), type_id(), and valid_type_id(). |
|
Return the reference corresponding to the member of a given ObjectGroup at the given location. Definition at line 385 of file PG_ObjectGroupManager.cpp. References CORBA::Object::_duplicate(), ACE_GUARD_RETURN, ACE_Unbounded_Set< T >::begin(), ACE_Unbounded_Set< T >::end(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), get_group_entry(), PortableGroup::Location, location_map_, member_already_present(), TAO_PG_ObjectGroup_Map_Entry::member_infos, TAO_PG_MemberInfo_Set, TAO_PG_ObjectGroup_Array, and TAO_SYNCH_MUTEX.
00388 { 00389 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00390 guard, 00391 this->lock_, 00392 CORBA::Object::_nil ()); 00393 00394 TAO_PG_ObjectGroup_Map_Entry * group_entry = 00395 this->get_group_entry (object_group); 00396 00397 // This method assumes that it is faster to check for non-existence 00398 // of an object group (and hence the member) at a given location, 00399 // instead of existence of a member at a given location. 00400 00401 TAO_PG_ObjectGroup_Array * groups = 0; 00402 if (this->location_map_.find (loc, groups) == 0 00403 && this->member_already_present (*groups, group_entry)) 00404 { 00405 TAO_PG_MemberInfo_Set & member_infos = group_entry->member_infos; 00406 00407 TAO_PG_MemberInfo_Set::iterator end = member_infos.end (); 00408 00409 // @todo If the object group contains a large number of members, 00410 // this loop could take a while. Explore potentially 00411 // faster containers for the list of PG_MemberInfos in the 00412 // future. 00413 for (TAO_PG_MemberInfo_Set::iterator i = member_infos.begin (); 00414 i != end; 00415 ++i) 00416 if ((*i).location == loc) 00417 return CORBA::Object::_duplicate ((*i).member.in ()); 00418 } 00419 00420 // No member of the given object group is present at the given 00421 // location. 00422 throw PortableGroup::MemberNotFound (); 00423 } |
|
Return the ObjectGroupId for the given ObjectGroup.
Definition at line 342 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, get_group_entry(), TAO_PG_ObjectGroup_Map_Entry::group_id, and TAO_SYNCH_MUTEX.
00344 { 00345 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00346 guard, 00347 this->lock_, 00348 0); 00349 00350 TAO_PG_ObjectGroup_Map_Entry * entry = 00351 this->get_group_entry (object_group); 00352 00353 if (entry == 0) 00354 throw CORBA::INTERNAL (); 00355 00356 // Only the lower 32 bits of the 64 bit PortableGroup::ObjectGroupId 00357 // are ever used. 00358 return entry->group_id; 00359 } |
|
get the position of the object_group_map_entry
Definition at line 670 of file PG_ObjectGroupManager.cpp. References TAO_PG_ObjectGroup_Map_Entry::group_id, ACE_Array_Base< T >::size(), and TAO_PG_ObjectGroup_Array. Referenced by remove_member().
00673 { 00674 // Multiple members from different object groups may reside at the 00675 // same location. Iterate through the list to attempt to find a 00676 // match. 00677 size_t len = groups.size (); 00678 for (size_t i = 0; i < len; ++i) 00679 { 00680 // It should be enough just to compare the group_entry pointers, 00681 // but that seems brittle. Better to check a controlled value, 00682 // like the ObjectGroupId. 00683 if (groups[i]->group_id == group_entry->group_id) 00684 { 00685 // Member with given type ID exists at the given 00686 // location. 00687 return i; 00688 } 00689 } 00690 00691 // No member with given type ID present at the given location. 00692 return 0; 00693 } |
|
Does this method make sense for load balanced objects?
Definition at line 362 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, get_group_entry(), and TAO_SYNCH_MUTEX.
00364 { 00365 TAO_PG_ObjectGroup_Map_Entry * entry = 0; 00366 00367 { 00368 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00369 guard, 00370 this->lock_, 00371 PortableGroup::ObjectGroup::_nil ()); 00372 00373 00374 entry = this->get_group_entry (object_group); 00375 } 00376 00377 if (entry == 0) 00378 throw CORBA::INTERNAL (); 00379 00380 // This implemenation does not change the object group reference. 00381 return PortableGroup::ObjectGroup::_duplicate (object_group); 00382 } |
|
TAO-specific extension. Return the ObjectGroup reference for the given ObjectGroupId. Definition at line 426 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), TAO_PG_ObjectGroup_Map_Entry::object_group, object_group_map_, and TAO_SYNCH_MUTEX.
00429 { 00430 //@@ If we change the PG's concept of ObjectGroupId from 00431 // PortableServer::ObjectId to PortableGroup::ObjectGroupId, can 00432 // just call TAO_PG_ObjectGroupManager::object_group() here. 00433 00434 TAO_PG_ObjectGroup_Map_Entry * group_entry = 0; 00435 { 00436 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00437 guard, 00438 this->lock_, 00439 PortableGroup::ObjectGroup::_nil ()); 00440 00441 if (this->object_group_map_.find (ACE_U64_TO_U32 (group_id), 00442 group_entry) 00443 != 0) 00444 { 00445 throw PortableGroup::ObjectGroupNotFound (); 00446 } 00447 } 00448 00449 if (group_entry == 0) 00450 { 00451 throw CORBA::INTERNAL (); 00452 } 00453 00454 return 00455 PortableGroup::ObjectGroup::_duplicate (group_entry->object_group.in ()); 00456 } |
|
Return the properties set when the object group was created, and the dynamic properties that may have overridden them. Definition at line 580 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, ACE_NEW_THROW_EX, get_group_entry(), TAO_PG_ObjectGroup_Map_Entry::properties, PortableGroup::Properties, and TAO_SYNCH_MUTEX. Referenced by TAO_PG_PropertyManager::get_properties().
00582 { 00583 PortableGroup::Properties * properties = 0; 00584 ACE_NEW_THROW_EX (properties, 00585 PortableGroup::Properties, 00586 CORBA::NO_MEMORY ( 00587 CORBA::SystemException::_tao_minor_code ( 00588 TAO::VMCID, 00589 ENOMEM), 00590 CORBA::COMPLETED_NO)); 00591 00592 PortableGroup::Properties_var safe_properties = properties; 00593 00594 { 00595 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00596 guard, 00597 this->lock_, 00598 0); 00599 00600 TAO_PG_ObjectGroup_Map_Entry * group_entry = 00601 this->get_group_entry (object_group); 00602 00603 *properties = group_entry->properties; 00604 } 00605 00606 return safe_properties._retn (); 00607 } |
|
Return the locations of the members in the given ObjectGroup.
Definition at line 311 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, ACE_NEW_THROW_EX, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), PortableGroup::Location, location_map_, PortableGroup::ObjectGroups, ACE_Array_Base< T >::size(), TAO_PG_ObjectGroup_Array, and TAO_SYNCH_MUTEX.
00313 { 00314 PortableGroup::ObjectGroups * ogs; 00315 ACE_NEW_THROW_EX (ogs, 00316 PortableGroup::ObjectGroups, 00317 CORBA::NO_MEMORY ()); 00318 00319 PortableGroup::ObjectGroups_var object_groups = ogs; 00320 00321 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, 0); 00322 00323 TAO_PG_ObjectGroup_Array * groups; 00324 if (this->location_map_.find (the_location, groups) == 0) 00325 { 00326 CORBA::ULong len = static_cast<CORBA::ULong> (groups->size ()); 00327 00328 ogs->length (len); 00329 00330 for (CORBA::ULong i = 0; i < len; ++i) 00331 { 00332 object_groups[i] = 00333 PortableGroup::ObjectGroup::_duplicate ( 00334 (*groups)[i]->object_group.in ()); 00335 } 00336 } 00337 00338 return object_groups._retn (); 00339 } |
|
Return the locations of the members in the given ObjectGroup.
Definition at line 276 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, ACE_NEW_THROW_EX, ACE_Unbounded_Set< T >::begin(), ACE_Unbounded_Set< T >::end(), get_group_entry(), PortableGroup::Locations, TAO_PG_ObjectGroup_Map_Entry::member_infos, ACE_Unbounded_Set< T >::size(), TAO_PG_MemberInfo_Set, and TAO_SYNCH_MUTEX.
00278 { 00279 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, 0); 00280 00281 TAO_PG_ObjectGroup_Map_Entry * group_entry = 00282 this->get_group_entry (object_group); 00283 00284 PortableGroup::Locations *temp = 0; 00285 ACE_NEW_THROW_EX (temp, 00286 PortableGroup::Locations, 00287 CORBA::NO_MEMORY ( 00288 CORBA::SystemException::_tao_minor_code ( 00289 TAO::VMCID, 00290 ENOMEM), 00291 CORBA::COMPLETED_NO)); 00292 00293 PortableGroup::Locations_var locations = temp; 00294 00295 TAO_PG_MemberInfo_Set & member_infos = group_entry->member_infos; 00296 00297 locations->length (static_cast<CORBA::ULong> (member_infos.size ())); 00298 00299 CORBA::ULong loc = 0; 00300 TAO_PG_MemberInfo_Set::iterator end = member_infos.end (); 00301 00302 for (TAO_PG_MemberInfo_Set::iterator i = member_infos.begin (); 00303 i != end; 00304 ++i) 00305 locations[loc++] = (*i).location; 00306 00307 return locations._retn (); 00308 } |
|
A member is actually represented by the object group to which it belongs. In this implementation, a pointer to a object group hash map entry is associated with a given a location. Definition at line 644 of file PG_ObjectGroupManager.cpp. References TAO_PG_ObjectGroup_Map_Entry::group_id, ACE_Array_Base< T >::size(), and TAO_PG_ObjectGroup_Array. Referenced by add_member_i(), and get_member_ref().
00647 { 00648 // Multiple members from different object groups may reside at the 00649 // same location. Iterate through the list to attempt to find a 00650 // match. 00651 size_t len = groups.size (); 00652 for (size_t i = 0; i < len; ++i) 00653 { 00654 // It should be enough just to compare the group_entry pointers, 00655 // but that seems brittle. Better to check a controlled value, 00656 // like the ObjectGroupId. 00657 if (groups[i]->group_id == group_entry->group_id) 00658 { 00659 // Member with given type ID exists at the given 00660 // location. 00661 return 1; 00662 } 00663 } 00664 00665 // No member with given type ID present at the given location. 00666 return 0; 00667 } |
|
Return the number of members in the given object group.
Definition at line 558 of file PG_ObjectGroupManager.cpp. References get_group_entry(), TAO_PG_ObjectGroup_Map_Entry::member_infos, and ACE_Unbounded_Set< T >::size(). Referenced by TAO_PG_GenericFactory::check_minimum_number_members().
00560 { 00561 // ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00562 // guard, 00563 // this->lock_, 00564 // 0); 00565 00566 TAO_PG_ObjectGroup_Map_Entry * group_entry = 00567 this->get_group_entry (group); 00568 00569 return static_cast<CORBA::ULong> (group_entry->member_infos.size ()); 00570 } |
|
Return the object group associated with the given ObjectId.
Definition at line 542 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), TAO_PG_ObjectGroup_Map_Entry::object_group, object_group_map_, and TAO_SYNCH_MUTEX.
00543 { 00544 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00545 guard, 00546 this->lock_, 00547 PortableGroup::ObjectGroup::_nil ()); 00548 00549 TAO_PG_ObjectGroup_Map_Entry * group_entry = 0; 00550 if (this->object_group_map_.find (oid, group_entry) == 0) 00551 return 00552 PortableGroup::ObjectGroup::_duplicate (group_entry->object_group.in ()); 00553 else 00554 return PortableGroup::ObjectGroup::_nil (); 00555 } |
|
Set the POA to use when converting object group references to ObjectIds. Definition at line 573 of file PG_ObjectGroupManager.cpp.
00574 { 00575 this->poa_ = PortableServer::POA::_duplicate (p); 00576 } |
|
Remove an object at a specific location from the given ObjectGroup. Deletion of application created objects must be deleted by the application. Objects created by the infrastructure (load balancer) will be deleted by the infrastructure. Definition at line 203 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, ACE_Unbounded_Set< T >::begin(), TAO_PG_GenericFactory::check_minimum_number_members(), TAO_PG_GenericFactory::delete_member(), ACE_Unbounded_Set< T >::end(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), get_group_entry(), get_object_group_position(), TAO_PG_ObjectGroup_Map_Entry::group_id, TAO_PG_MemberInfo::location, PortableGroup::Location, location_map_, TAO_PG_ObjectGroup_Map_Entry::member_infos, ACE_Unbounded_Set< T >::remove(), ACE_Array_Base< T >::size(), TAO_PG_MemberInfo_Set, TAO_PG_ObjectGroup_Array, TAO_SYNCH_MUTEX, and TAO_PG_ObjectGroup_Map_Entry::type_id.
00206 { 00207 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, 0); 00208 00209 TAO_PG_ObjectGroup_Map_Entry * group_entry = 00210 this->get_group_entry (object_group); 00211 00212 TAO_PG_ObjectGroup_Array * groups = 0; 00213 if (this->location_map_.find (the_location, groups) != 0) 00214 throw PortableGroup::ObjectGroupNotFound (); 00215 00216 // Multiple members from different object groups may reside at the 00217 // same location. Iterate through the list to attempt to find a 00218 // match for the exact object group. 00219 size_t to_be_removed = 0; 00220 00221 // get the position of the object group in the object_group_array 00222 to_be_removed = this->get_object_group_position (*groups, group_entry); 00223 00224 // remove the element from the array and resize the array. 00225 const size_t groups_len = groups->size (); 00226 size_t j; 00227 for (size_t i = to_be_removed; i < groups_len - 1; ++i) 00228 { 00229 j = i + 1; 00230 (*groups)[i] = (*groups)[j]; 00231 } 00232 00233 groups->size (groups_len - 1); 00234 00235 TAO_PG_MemberInfo_Set & member_infos = group_entry->member_infos; 00236 00237 TAO_PG_MemberInfo_Set::iterator end = member_infos.end (); 00238 00239 for (TAO_PG_MemberInfo_Set::iterator iter = member_infos.begin (); 00240 iter != end; 00241 ++iter) 00242 { 00243 const TAO_PG_MemberInfo & info = *iter; 00244 00245 if (info.location == the_location) 00246 { 00247 // Give the GenericFactory a chance to delete a member if 00248 // its membership is under infrastructure control. 00249 if (this->generic_factory_) 00250 { 00251 this->generic_factory_->delete_member (group_entry->group_id, 00252 the_location); 00253 } 00254 00255 if (member_infos.remove (info) == 0) 00256 { 00257 if (this->generic_factory_) 00258 { 00259 this->generic_factory_->check_minimum_number_members ( 00260 object_group, 00261 group_entry->group_id, 00262 group_entry->type_id.in ()); 00263 } 00264 00265 return PortableGroup::ObjectGroup::_duplicate (object_group); 00266 } 00267 else 00268 break; 00269 } 00270 } 00271 00272 throw PortableGroup::MemberNotFound (); 00273 } |
|
Return the type_id for the given object group.
Definition at line 527 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, get_group_entry(), CORBA::string_dup(), TAO_SYNCH_MUTEX, and TAO_PG_ObjectGroup_Map_Entry::type_id. Referenced by TAO_PG_PropertyManager::get_properties().
00529 { 00530 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00531 guard, 00532 this->lock_, 00533 0); 00534 00535 TAO_PG_ObjectGroup_Map_Entry * group_entry = 00536 this->get_group_entry (object_group); 00537 00538 return CORBA::string_dup (group_entry->type_id.in ()); 00539 } |
|
Verify that the member type_id matches the object group type_id.
Definition at line 696 of file PG_ObjectGroupManager.cpp. References ACE_GUARD_RETURN, get_group_entry(), CORBA::is_nil(), CORBA::string_dup(), and TAO_PG_ObjectGroup_Map_Entry::type_id. Referenced by add_member_i().
00700 { 00701 // @todo Strategize this -- e.g. strict type checking. 00702 00703 if (CORBA::is_nil (member)) 00704 throw CORBA::BAD_PARAM (); 00705 00706 // Before we can use this code, i.e. the reverse lock, the 00707 // TAO_PG_ObjectGroup_Entry should be made so that it is reference 00708 // counted. This is necessary since releasing the lock would 00709 // allow other threads to destroy/unbind the object group entry. 00710 // Another alternative is to simply attempt to reacquire the 00711 // object group map entry once the lock is reacquired, which is 00712 // easier to implement. 00713 00714 // Copy the type_id before releasing the lock to avoid a race 00715 // condition. 00716 CORBA::String_var type_id = 00717 CORBA::string_dup (group_entry->type_id.in ()); 00718 00719 CORBA::Boolean right_type_id = 0; 00720 { 00721 // Release the lock during the type_id check. No need to block 00722 // other threads during the invocation. 00723 ACE_Reverse_Lock<TAO_SYNCH_MUTEX> reverse_lock (this->lock_); 00724 00725 ACE_GUARD_RETURN (ACE_Reverse_Lock<TAO_SYNCH_MUTEX>, 00726 reverse_guard, 00727 reverse_lock, 00728 right_type_id); 00729 00730 // Make sure an Object of the correct type was created. It is 00731 // possible that an object of the wrong type was created if the 00732 // type_id parameter does not match the type of object the 00733 // GenericFactory creates. 00734 right_type_id = 00735 member->_is_a (type_id.in ()); 00736 } 00737 00738 // Make sure the group entry still exists. It may have been 00739 // destroyed by another thread. 00740 group_entry = this->get_group_entry (object_group); 00741 00742 return right_type_id; 00743 } |
|
Pointer to the TAO_PG_GenericFactory class responsible for object group creation/destruction. Definition at line 244 of file PG_ObjectGroupManager.h. |
|
Map that contains list of all members at a given location, in addition to the load monitor at that location. Definition at line 240 of file PG_ObjectGroupManager.h. Referenced by add_member_i(), get_member_ref(), groups_at_location(), remove_member(), and ~TAO_PG_ObjectGroupManager(). |
|
Lock used to synchronize access to the underlying tables.
Definition at line 247 of file PG_ObjectGroupManager.h. |
|
The underlying table that contains all object group information. Definition at line 236 of file PG_ObjectGroupManager.h. Referenced by create_object_group(), destroy_object_group(), get_object_group_ref_from_id(), object_group(), and ~TAO_PG_ObjectGroupManager(). |
|
Reference to the POA that created the object group references.
Definition at line 232 of file PG_ObjectGroupManager.h. |