TAO::PG_Object_Group Class Reference

#include <PG_Object_Group.h>

Collaboration diagram for TAO::PG_Object_Group:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PG_Object_Group (CORBA::ORB_ptr orb, PortableGroup::FactoryRegistry_ptr factory_registry, TAO::PG_Object_Group_Manipulator &manipulator, CORBA::Object_ptr empty_group, const PortableGroup::TagGroupTaggedComponent &tagged_component, const char *type_id, const PortableGroup::Criteria &the_criteria, TAO::PG_Property_Set *type_properties)
 ~PG_Object_Group ()
 Destructor.

PortableGroup::ObjectGroup_ptr reference () const
 return a duplicated reference to this group (IOGR)

void get_group_specific_factories (PortableGroup::FactoryInfos &result) const
const PortableGroup::Locationget_primary_location () const
PortableGroup::TypeId get_type_id () const
PortableGroup::MembershipStyleValue get_membership_style () const
PortableGroup::MinimumNumberMembersValue get_minimum_number_members () const
PortableGroup::InitialNumberMembersValue get_initial_number_members () const
void set_properties_dynamically (const PortableGroup::Properties &overrides) throw (CORBA::SystemException, PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)
void get_properties (PortableGroup::Properties_var &result) const throw (CORBA::SystemException)
PortableGroup::ObjectGroupId get_object_group_id () const
void add_member (const PortableGroup::Location &the_location, CORBA::Object_ptr member) throw (CORBA::SystemException, PortableGroup::ObjectNotAdded)
int set_primary_member (TAO_IOP::TAO_IOR_Property *prop, const PortableGroup::Location &the_location) throw ( CORBA::SystemException , PortableGroup::MemberNotFound )
void remove_member (const PortableGroup::Location &the_location) throw (CORBA::SystemException, PortableGroup::MemberNotFound)
void create_member (const PortableGroup::Location &the_location, const char *type_id, const PortableGroup::Criteria &the_criteria) throw (CORBA::SystemException, PortableGroup::MemberAlreadyPresent, PortableGroup::NoFactory, PortableGroup::ObjectNotCreated, PortableGroup::InvalidCriteria, PortableGroup::CannotMeetCriteria)
PortableGroup::Locationslocations_of_members () throw (CORBA::SystemException)
CORBA::Object_ptr get_member_reference (const PortableGroup::Location &the_location) throw ( CORBA::SystemException, PortableGroup::MemberNotFound)
void initial_populate ()
void minimum_populate ()
int has_member_at (const PortableGroup::Location &location)

Private Types

typedef TAO_SYNCH_MUTEX MemberMapMutex
typedef ACE_Hash_Map_Manager_Ex<
PortableGroup::Location,
MemberInfo *, TAO_PG_Location_Hash,
TAO_PG_Location_Equal_To,
MemberMapMutex
MemberMap
typedef ACE_Hash_Map_Entry<
PortableGroup::Location,
MemberInfo * > 
MemberMap_Entry
typedef ACE_Hash_Map_Iterator_Ex<
PortableGroup::Location,
MemberInfo *, TAO_PG_Location_Hash,
TAO_PG_Location_Equal_To,
MemberMapMutex
MemberMap_Iterator

Private Member Functions

int increment_version ()
void distribute_iogr ()
PortableGroup::ObjectGroup_ptr add_member_to_iogr (CORBA::Object_ptr member)
void create_members (size_t count) throw ( CORBA::SystemException, PortableGroup::NoFactory )
 PG_Object_Group ()
 PG_Object_Group (const PG_Object_Group &rhs)
PG_Object_Groupoperator= (const PG_Object_Group &rhs)

Private Attributes

TAO_SYNCH_MUTEX internals_
CORBA::ORB_var orb_
PortableGroup::FactoryRegistry_var factory_registry_
 Where to find the factories for replicas.

TAO::PG_Object_Group_Manipulatormanipulator_
int empty_
 boolean true if empty group

ACE_CString role_
PortableGroup::TypeId_var type_id_
PortableGroup::TagGroupTaggedComponent tagged_component_
PortableGroup::ObjectGroup_var reference_
PortableServer::ObjectId_var object_id_
MemberMap members_
PortableGroup::Location primary_location_
TAO::PG_Property_Set properties_
PortableGroup::InitialNumberMembersValue initial_number_members_
PortableGroup::MinimumNumberMembersValue minimum_number_members_
PortableGroup::FactoryInfos group_specific_factories_

Member Typedef Documentation

typedef ACE_Hash_Map_Manager_Ex< PortableGroup::Location, MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MemberMapMutex> TAO::PG_Object_Group::MemberMap [private]
 

Definition at line 104 of file PG_Object_Group.h.

typedef ACE_Hash_Map_Entry<PortableGroup::Location, MemberInfo *> TAO::PG_Object_Group::MemberMap_Entry [private]
 

Definition at line 105 of file PG_Object_Group.h.

typedef ACE_Hash_Map_Iterator_Ex< PortableGroup::Location, MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MemberMapMutex> TAO::PG_Object_Group::MemberMap_Iterator [private]
 

Definition at line 111 of file PG_Object_Group.h.

Referenced by distribute_iogr(), locations_of_members(), set_primary_member(), and ~PG_Object_Group().

typedef TAO_SYNCH_MUTEX TAO::PG_Object_Group::MemberMapMutex [private]
 

Definition at line 98 of file PG_Object_Group.h.


Constructor & Destructor Documentation

TAO::PG_Object_Group::PG_Object_Group CORBA::ORB_ptr  orb,
PortableGroup::FactoryRegistry_ptr  factory_registry,
TAO::PG_Object_Group_Manipulator manipulator,
CORBA::Object_ptr  empty_group,
const PortableGroup::TagGroupTaggedComponent &  tagged_component,
const char *  type_id,
const PortableGroup::Criteria the_criteria,
TAO::PG_Property_Set type_properties
 

@TODO DOC

Definition at line 63 of file PG_Object_Group.cpp.

References PortableGroup::Criteria, empty_, group_specific_factories_, initial_number_members_, members_, minimum_number_members_, primary_location_, properties_, reference_, and role_.

00072   : internals_()
00073   , orb_ (CORBA::ORB::_duplicate (orb))
00074   , factory_registry_ (PortableGroup::FactoryRegistry::_duplicate (factory_registry))
00075   , manipulator_ (manipulator)
00076   , empty_ (1)
00077   , role_ (type_id)
00078   , type_id_ (CORBA::string_dup (type_id))
00079   , tagged_component_ (tagged_component)
00080   , reference_ (CORBA::Object::_duplicate(empty_group))
00081   , members_ ()
00082   , primary_location_(0)
00083   , properties_ (the_criteria, type_properties)
00084   , initial_number_members_ (0)
00085   , minimum_number_members_ (0)
00086   , group_specific_factories_ ()
00087 {
00088 }

TAO::PG_Object_Group::~PG_Object_Group  ) 
 

Destructor.

Definition at line 90 of file PG_Object_Group.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 >::end(), MemberMap_Iterator, members_, and ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::unbind_all().

00091 {
00092   for (MemberMap_Iterator it = this->members_.begin();
00093       it != this->members_.end();
00094       ++it)
00095     {
00096       MemberInfo * member = (*it).int_id_;
00097       delete member;
00098     }
00099   this->members_.unbind_all ();
00100 }

TAO::PG_Object_Group::PG_Object_Group  )  [private]
 

TAO::PG_Object_Group::PG_Object_Group const PG_Object_Group rhs  )  [private]
 


Member Function Documentation

void TAO::PG_Object_Group::add_member const PortableGroup::Location the_location,
CORBA::Object_ptr  member
throw (CORBA::SystemException, PortableGroup::ObjectNotAdded)
 

Add a new member to the group.

Parameters:
the_location the location for the new member
member the member to be added

Definition at line 198 of file PG_Object_Group.cpp.

References ACE_CHECK, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD, ACE_NEW_THROW_EX, ACE_TEXT, ACE_THROW, LM_DEBUG, PortableGroup::Location, TAO_debug_level, and TAO_SYNCH_MUTEX.

00204 {
00205   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00206 
00207   /////////////////////////////////////////
00208   // Convert the new member to a string IOR
00209   // This keeps a clean IOR (not an IOGR!)
00210   // while we add it to a group.  We need a
00211   // IORs, not IOGRs to send new IOGRs out
00212   // to replicas.
00213 
00214   CORBA::String_var member_ior_string =
00215     orb_->object_to_string (member
00216                             ACE_ENV_ARG_PARAMETER);
00217   ACE_CHECK;
00218 
00219   PortableGroup::ObjectGroup_var new_reference =
00220     add_member_to_iogr (member
00221                         ACE_ENV_ARG_PARAMETER);
00222   ACE_CHECK;
00223 
00224   // Convert new member back to a (non group) ior.
00225   CORBA::Object_var member_ior =
00226     this->orb_->string_to_object (member_ior_string.in ()
00227                                   ACE_ENV_ARG_PARAMETER);
00228   ACE_CHECK;
00229 
00230   MemberInfo * info = 0;
00231   ACE_NEW_THROW_EX (info,
00232                     MemberInfo (member_ior.in (),
00233                                 the_location),
00234                     CORBA::NO_MEMORY());
00235 
00236   if (this->members_.bind (the_location, info) != 0)
00237     {
00238       // @@ Dale why this is a NO MEMORY exception?
00239       ACE_THROW(CORBA::NO_MEMORY());
00240     }
00241 
00242   this->reference_ = new_reference; // note var-to-var assignment does
00243                                     // a duplicate
00244   if (this->increment_version ())
00245     {
00246       this->distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER);
00247       ACE_CHECK;
00248     }
00249   else
00250     {
00251       ACE_THROW (PortableGroup::ObjectNotAdded ());
00252     }
00253 
00254   if (TAO_debug_level > 6)
00255     {
00256       ACE_DEBUG ((LM_DEBUG,
00257                   ACE_TEXT("PG (%P|%t) exit Object_Group add_member \n")));
00258     }
00259 }

PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::add_member_to_iogr CORBA::Object_ptr  member  )  [private]
 

Definition at line 153 of file PG_Object_Group.cpp.

References CORBA::Object::_duplicate(), ACE_CHECK_RETURN, ACE_ENV_ARG_PARAMETER, empty_, and reference_.

00155 {
00156   // assume internals is locked
00157 
00158   PortableGroup::ObjectGroup_var result;
00159 
00160  ////////////////////////////
00161   // @@ HACK ALERT
00162   // The PortableGroup::ObjectGroupManager creates an object reference
00163   // containing a dummy entry so it will have a place to store the
00164   // tagged group component. If this is the first entry, we need to
00165   // remove that entry once we have a *real* member. This can be
00166   // avoided when we get support for TAG_MULTIPLE_COMPONENTS.   For
00167   // now, we already have a copy of the tagGroupTagged component and
00168   // we're going to use it below wen we increment the group version so
00169   // we can clean out the dummy entry.
00170   PortableGroup::ObjectGroup_var cleaned =
00171     PortableGroup::ObjectGroup::_duplicate (this->reference_.in ());
00172   if (this->empty_)
00173     {
00174       // remove the original profile.  It's a dummy entry supplied by
00175       // create_object.
00176       cleaned =
00177         this->manipulator_.remove_profiles (cleaned.in (),
00178                                             this->reference_.in ()
00179                                             ACE_ENV_ARG_PARAMETER);
00180       ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil());
00181       this->empty_ = 0;
00182     }
00183 
00184   // create a list of references to be merged
00185   TAO_IOP::TAO_IOR_Manipulation::IORList iors (2);
00186   iors.length (2);
00187   iors [0] = CORBA::Object::_duplicate (cleaned.in());
00188   iors [1] = CORBA::Object::_duplicate (member);
00189 
00190   // Now merge the list into one new IOGR
00191   result =
00192     this->manipulator_.merge_iors (iors ACE_ENV_ARG_PARAMETER);
00193   ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil ());
00194   return result._retn ();
00195 }

void TAO::PG_Object_Group::create_member const PortableGroup::Location the_location,
const char *  type_id,
const PortableGroup::Criteria the_criteria
throw (CORBA::SystemException, PortableGroup::MemberAlreadyPresent, PortableGroup::NoFactory, PortableGroup::ObjectNotCreated, PortableGroup::InvalidCriteria, PortableGroup::CannotMeetCriteria)
 

@TODO DOC

Definition at line 636 of file PG_Object_Group.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD, ACE_NEW_THROW_EX, ACE_THROW, PortableGroup::Criteria, PortableGroup::Location, TAO_SYNCH_MUTEX, PortableGroup::FactoryInfo::the_factory, and PortableGroup::FactoryInfo::the_location.

00647 {
00648   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00649 
00650 
00651   if (0 != this->members_.find (the_location))
00652     {
00653       // @@ what if factories were passed as criteria?
00654 
00655       CORBA::String_var factory_type;
00656       PortableGroup::FactoryInfos_var factories =
00657         this->factory_registry_->list_factories_by_role (
00658           role_.c_str(),
00659           factory_type.out ()
00660           ACE_ENV_ARG_PARAMETER);
00661       ACE_CHECK;
00662 
00663       // @@ what if factory_type != type_id != this->type_id_
00664 
00665       int created = 0; // bool
00666       CORBA::ULong factory_count = factories->length ();
00667       for (CORBA::ULong factory_pos = 0;
00668            ! created && factory_pos < factory_count;
00669            ++factory_pos)
00670         {
00671           const PortableGroup::FactoryInfo & factory_info =
00672             (*factories)[factory_pos];
00673           if (factory_info.the_location == the_location)
00674             {
00675               // @@ should we merge the_criteria with
00676               // factory_info.the_criteria?
00677 
00678               PortableGroup::GenericFactory::FactoryCreationId_var fcid;
00679               CORBA::Object_var member =
00680                 factory_info.the_factory->create_object (
00681                   type_id,
00682                   the_criteria,
00683                   fcid. out()
00684                   ACE_ENV_ARG_PARAMETER);
00685               ACE_CHECK;
00686 
00687               // convert the new member to a stringified IOR to avoid
00688               // contamination with group info
00689               CORBA::String_var member_ior_string =
00690                 orb_->object_to_string (member.in ()
00691                                         ACE_ENV_ARG_PARAMETER);
00692               ACE_CHECK;
00693 
00694               PortableGroup::ObjectGroup_var new_reference =
00695                 this->add_member_to_iogr (member.in ()
00696                                           ACE_ENV_ARG_PARAMETER);
00697               ACE_CHECK;
00698 
00699               // Convert new member back to a (non group) ior.
00700               CORBA::Object_var member_ior =
00701                 this->orb_->string_to_object (member_ior_string.in ()
00702                                               ACE_ENV_ARG_PARAMETER);
00703               ACE_CHECK;
00704 
00705               MemberInfo * info = 0;
00706               ACE_NEW_THROW_EX (info, MemberInfo(
00707                                                  member_ior.in(),
00708                                                  the_location,
00709                                                  factory_info.the_factory,
00710                                                  fcid.in ()),
00711                                 CORBA::NO_MEMORY());
00712               ACE_CHECK;
00713 
00714               if (this->members_.bind (the_location, info) != 0)
00715                 {
00716                   ACE_THROW(CORBA::NO_MEMORY());
00717                 }
00718 
00719               this->reference_ = new_reference; // note var-to-var
00720                                                 // assignment does a
00721                                                 // duplicate
00722               if (this->increment_version ())
00723                 {
00724                   this->distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER);
00725                   ACE_CHECK;
00726                 }
00727               created = 1;
00728             }
00729         }
00730       if (! created)
00731         {
00732           ACE_THROW (PortableGroup::NoFactory ());
00733         }
00734     }
00735   else
00736     {
00737       ACE_THROW (PortableGroup::MemberAlreadyPresent ());
00738     }
00739 }

void TAO::PG_Object_Group::create_members size_t  count  )  throw ( CORBA::SystemException, PortableGroup::NoFactory ) [private]
 

Definition at line 742 of file PG_Object_Group.cpp.

References ACE_CATCHANY, ACE_CHECK, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_ERROR, ACE_NEW_THROW_EX, ACE_TEXT(), ACE_THROW, ACE_TRY_CHECK, ACE_TRY_NEW_ENV, ACE_TRY_THROW, LM_ERROR, PortableGroup::Location, TAO_debug_level, PortableGroup::FactoryInfo::the_criteria, PortableGroup::FactoryInfo::the_factory, and PortableGroup::FactoryInfo::the_location.

Referenced by initial_populate(), and minimum_populate().

00745 {
00746   // assume internals is locked
00747   // @@ what if factories were passed as criteria?
00748 
00749   CORBA::String_var factory_type;
00750   PortableGroup::FactoryInfos_var factories =
00751   this->factory_registry_->list_factories_by_role (
00752         role_.c_str(),
00753         factory_type.out ()
00754         ACE_ENV_ARG_PARAMETER);
00755   ACE_CHECK;
00756 
00757   CORBA::ULong factory_count = factories->length ();
00758   if (factory_count > 0)
00759     {
00760       CORBA::ULong factory_pos = 0;
00761       while (members_.current_size () < count && factory_pos < factory_count)
00762         {
00763           const PortableGroup::FactoryInfo & factory_info =
00764             (*factories)[factory_pos];
00765           const PortableGroup::Location & factory_location =
00766             factory_info.the_location;
00767           if (0 != this->members_.find (factory_location))
00768             {
00769               ///////////////////////////////////////////
00770               // If a factory refuses to create a replica
00771               // it's not fatal.
00772               ACE_TRY_NEW_ENV
00773                 {
00774                   PortableGroup::GenericFactory::FactoryCreationId_var fcid;
00775                   CORBA::Object_var member =
00776                     factory_info.the_factory->create_object (
00777                       this->type_id_.in (),
00778                       factory_info.the_criteria,
00779                       fcid. out()
00780                       ACE_ENV_ARG_PARAMETER);
00781                   ACE_TRY_CHECK;
00782 
00783                   // convert the new member to a stringified IOR to avoid
00784                   // contamination with group info
00785                   CORBA::String_var member_ior_string =
00786                     orb_->object_to_string (member.in ()
00787                                             ACE_ENV_ARG_PARAMETER);
00788                   ACE_TRY_CHECK;
00789 
00790                   PortableGroup::ObjectGroup_var new_reference =
00791                     this->add_member_to_iogr (member.in ()
00792                                               ACE_ENV_ARG_PARAMETER);
00793                   ACE_TRY_CHECK;
00794 
00795                   // Convert new member back to a (non group) ior.
00796                   CORBA::Object_var member_ior =
00797                     this->orb_->string_to_object (member_ior_string.in ()
00798                                                   ACE_ENV_ARG_PARAMETER);
00799                   ACE_TRY_CHECK;
00800 
00801                   MemberInfo * info = 0;
00802                   ACE_NEW_THROW_EX (info, MemberInfo(
00803                                                      member_ior.in(),
00804                                                      factory_location,
00805                                                      factory_info.the_factory,
00806                                                      fcid.in ()),
00807                                     CORBA::NO_MEMORY());
00808                   ACE_TRY_CHECK;
00809 
00810                   if (this->members_.bind (factory_location, info) != 0)
00811                     {
00812                       ACE_TRY_THROW(CORBA::NO_MEMORY());
00813                     }
00814                   this->reference_ =
00815                     new_reference; // note var-to-var assignment does
00816                                    // a duplicate
00817                 }
00818               ACE_CATCHANY
00819                 {
00820                   // log, but otherwise ignore the errorf
00821                   if (TAO_debug_level > 0)
00822                     {
00823                       ACE_ERROR ((LM_ERROR,
00824                                   ACE_TEXT ("PG (%P|%t) Replica Factory ")
00825                                   ACE_TEXT ("@ %s refused create_object ")
00826                                   ACE_TEXT ("request for type %s\n"),
00827                                   static_cast<const char *> (factory_info.the_location[0].id),
00828                                   static_cast<const char *> (this->type_id_.in ())
00829                                   ));
00830                     }
00831                 }
00832               ACE_ENDTRY;
00833             }
00834         }
00835 
00836       if (this->increment_version ())
00837         {
00838           this->distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER);
00839           ACE_CHECK;
00840         }
00841     }
00842   else
00843     {
00844       ACE_THROW (PortableGroup::NoFactory());
00845     }
00846 }

void TAO::PG_Object_Group::distribute_iogr  )  [private]
 

Definition at line 470 of file PG_Object_Group.cpp.

References ACE_CATCHANY, ACE_CHECK, ACE_DEBUG, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ERROR, ACE_TRY_CHECK, ACE_TRY_NEW_ENV, 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 >::end(), CORBA::is_nil(), TAO::PG_Object_Group::MemberInfo::is_primary_, LM_DEBUG, LM_ERROR, TAO::PG_Object_Group::MemberInfo::location_, TAO::PG_Object_Group::MemberInfo::member_, MemberMap_Iterator, members_, and TAO_debug_level.

00471 {
00472   // assume internals is locked
00473   CORBA::String_var iogr =
00474     this->orb_->object_to_string (this->reference_.in()
00475                                   ACE_ENV_ARG_PARAMETER);
00476   ACE_CHECK;
00477 
00478 //  size_t n_rep = 0; // for dump_ior below
00479   for (MemberMap_Iterator it = this->members_.begin();
00480        it != this->members_.end ();
00481        ++it)
00482     {
00483       MemberInfo const * info = (*it).int_id_;
00484       //
00485       // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface
00486       // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_);
00487       // but it doesn work: error message at replica is:
00488       // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0]
00489       // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed
00490       // back to using _narrow
00491       PortableGroup::TAO_UpdateObjectGroup_var uog =
00492         PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_.in ());
00493       if (!CORBA::is_nil (uog.in ()))
00494         {
00495           ACE_TRY_NEW_ENV
00496             {
00497               if (TAO_debug_level > 3)
00498                 {
00499                   ACE_DEBUG ((LM_DEBUG,
00500                               "PG (%P|%t) -  Object_Group pushing "
00501                               "IOGR to %s member: %s@%s.\n",
00502                               (info->is_primary_ ? "Primary" : "Backup"),
00503                               this->role_.c_str (),
00504                               static_cast<const char *> (info->location_[0].id)
00505                               ));
00506                 }
00507               //        dump_ior ("group", "iogr", this->tagged_component_.object_group_ref_version, iogr);
00508               //        CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in() ACE_ENV_ARG_PARAMETER);
00509               //        dump_ior (info->location_[0].id, "ior", (this->tagged_component_.object_group_ref_version * 100) + n_rep++, replica_ior);
00510               uog->tao_update_object_group (iogr.in (),
00511                                             this->tagged_component_.object_group_ref_version,
00512                                             info->is_primary_
00513                                             ACE_ENV_ARG_PARAMETER);
00514               ACE_TRY_CHECK;
00515             }
00516           ACE_CATCHANY
00517             {
00518               // we expect an exception
00519               // tao_update_object_group is not a real method
00520             }
00521           ACE_ENDTRY;
00522         }
00523       else
00524         {
00525           ACE_ERROR ((LM_ERROR,
00526                       "TAO::PG_Object_Group::distribute iogr can't "
00527                       "narrow member reference to "
00528                       "PortableGroup::TAO_UpdateObjectGroup.\n"
00529                       ));
00530         }
00531     }
00532 }

void TAO::PG_Object_Group::get_group_specific_factories PortableGroup::FactoryInfos result  )  const
 

Note the caller receives a copy of the factoryinfos in the result argument. inefficient, but thread safe.

Definition at line 131 of file PG_Object_Group.cpp.

References ACE_GUARD, PortableGroup::FactoryInfos, group_specific_factories_, and TAO_SYNCH_MUTEX.

00133 {
00134   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00135 
00136   // copy is needed to have some semblance of thread safeness.
00137   // if performance is an issue avoid this method.
00138   result = this->group_specific_factories_;
00139 }

PortableGroup::InitialNumberMembersValue TAO::PG_Object_Group::get_initial_number_members  )  const
 

@TODO DOC

Definition at line 623 of file PG_Object_Group.cpp.

References PortableGroup::InitialNumberMembersValue, properties_, and TAO_PG_INITIAL_NUMBER_MEMBERS.

Referenced by initial_populate().

00624 {
00625   PortableGroup::InitialNumberMembersValue initial_number_members = 0;
00626   if (!TAO::find (properties_,
00627                   PortableGroup::PG_INITIAL_NUMBER_MEMBERS,
00628                   initial_number_members))
00629     {
00630       initial_number_members = TAO_PG_INITIAL_NUMBER_MEMBERS;
00631     }
00632   return initial_number_members;
00633 }

CORBA::Object_ptr TAO::PG_Object_Group::get_member_reference const PortableGroup::Location the_location  )  throw ( CORBA::SystemException, PortableGroup::MemberNotFound)
 

@TODO DOC

Definition at line 568 of file PG_Object_Group.cpp.

References CORBA::Object::_duplicate(), ACE_GUARD_RETURN, ACE_THROW_RETURN, PortableGroup::Location, TAO::PG_Object_Group::MemberInfo::member_, and TAO_SYNCH_MUTEX.

00574 {
00575   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00576                     guard,
00577                     this->internals_,
00578                     CORBA::Object::_nil ());
00579 
00580   CORBA::Object_var result;
00581 
00582   MemberInfo * info = 0;
00583   if (this->members_.find (the_location, info) == 0)
00584     {
00585       result = CORBA::Object::_duplicate (info->member_.in ());
00586     }
00587   else
00588     {
00589       ACE_THROW_RETURN (PortableGroup::MemberNotFound(), result._retn ());
00590     }
00591   return result._retn ();
00592 }

PortableGroup::MembershipStyleValue TAO::PG_Object_Group::get_membership_style  )  const
 

@TODO DOC

Definition at line 596 of file PG_Object_Group.cpp.

References PortableGroup::MembershipStyleValue, properties_, and TAO_PG_MEMBERSHIP_STYLE.

Referenced by initial_populate(), and minimum_populate().

00597 {
00598   PortableGroup::MembershipStyleValue membership_style = 0;
00599   if (!TAO::find (properties_,
00600                   PortableGroup::PG_MEMBERSHIP_STYLE,
00601                   membership_style))
00602     {
00603       membership_style = TAO_PG_MEMBERSHIP_STYLE;
00604     }
00605   return membership_style;
00606 }

PortableGroup::MinimumNumberMembersValue TAO::PG_Object_Group::get_minimum_number_members  )  const
 

@TODO DOC

Definition at line 610 of file PG_Object_Group.cpp.

References PortableGroup::MinimumNumberMembersValue, properties_, and TAO_PG_MINIMUM_NUMBER_MEMBERS.

Referenced by minimum_populate().

00611 {
00612   PortableGroup::MinimumNumberMembersValue minimum_number_members = 0;
00613   if (!TAO::find (properties_,
00614                   PortableGroup::PG_MINIMUM_NUMBER_MEMBERS,
00615                   minimum_number_members))
00616     {
00617       minimum_number_members = TAO_PG_MINIMUM_NUMBER_MEMBERS;
00618     }
00619   return minimum_number_members;
00620 }

PortableGroup::ObjectGroupId TAO::PG_Object_Group::get_object_group_id  )  const
 

@TODO DOC

Definition at line 395 of file PG_Object_Group.cpp.

References ACE_GUARD_RETURN, and TAO_SYNCH_MUTEX.

Referenced by TAO::PG_Group_Factory::insert_group().

00396 {
00397   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00398                     guard,
00399                     this->internals_,
00400                     0);
00401   return this->tagged_component_.object_group_id;
00402 }

const PortableGroup::Location & TAO::PG_Object_Group::get_primary_location  )  const
 

get location of primary member

Definition at line 142 of file PG_Object_Group.cpp.

References ACE_GUARD_RETURN, primary_location_, and TAO_SYNCH_MUTEX.

00143 {
00144   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00145                     guard,
00146                     this->internals_,
00147                     this->primary_location_);
00148   return this->primary_location_;
00149 }

void TAO::PG_Object_Group::get_properties PortableGroup::Properties_var &  result  )  const throw (CORBA::SystemException)
 

@TODO DOC

Definition at line 420 of file PG_Object_Group.cpp.

References ACE_GUARD, and TAO_SYNCH_MUTEX.

00423 {
00424   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00425   this->properties_.export_properties(*result);
00426 }

PortableGroup::TypeId TAO::PG_Object_Group::get_type_id  )  const
 

returns a duplicate caller must release

Definition at line 430 of file PG_Object_Group.cpp.

References ACE_GUARD_RETURN, CORBA::string_dup(), and TAO_SYNCH_MUTEX.

00431 {
00432   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00433                     guard,
00434                     this->internals_,
00435                     0);
00436   return CORBA::string_dup (this->type_id_);
00437 }

int TAO::PG_Object_Group::has_member_at const PortableGroup::Location location  ) 
 

@TODO DOC

Definition at line 884 of file PG_Object_Group.cpp.

References ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), PortableGroup::Location, and members_.

Referenced by TAO::PG_Group_Factory::groups_at_location().

00885 {
00886   return (0 == this->members_.find (location));
00887 }

int TAO::PG_Object_Group::increment_version  )  [private]
 

Definition at line 444 of file PG_Object_Group.cpp.

References ACE_DEBUG, ACE_TEXT(), LM_DEBUG, TAO::PG_Utils::set_tagged_component(), and TAO_debug_level.

00445 {
00446   // assume internals is locked
00447   int result = 0;
00448   this->tagged_component_.object_group_ref_version += 1;
00449   if (TAO_debug_level > 3)
00450     {
00451       ACE_DEBUG ((LM_DEBUG,
00452                   ACE_TEXT ("%T %n (%P|%t) - Setting IOGR version to %u\n"),
00453                   static_cast<unsigned> (this->tagged_component_.object_group_ref_version)
00454                   ));
00455     }
00456 
00457   // Set the version
00458   if (TAO::PG_Utils::set_tagged_component (this->reference_,
00459                                            this->tagged_component_))
00460     {
00461       result = 1;
00462     }
00463   return result;
00464 }

void TAO::PG_Object_Group::initial_populate  ) 
 

@TODO DOC

Definition at line 849 of file PG_Object_Group.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_GUARD, create_members(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::current_size(), get_initial_number_members(), get_membership_style(), PortableGroup::InitialNumberMembersValue, members_, and TAO_SYNCH_MUTEX.

00850 {
00851   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00852 
00853   if (this->get_membership_style () == PortableGroup::MEMB_INF_CTRL)
00854     {
00855       PortableGroup::InitialNumberMembersValue initial_number_members =
00856         this->get_initial_number_members ();
00857 
00858       if (this->members_.current_size () < initial_number_members)
00859         {
00860           this->create_members (initial_number_members
00861                                 ACE_ENV_ARG_PARAMETER);
00862           ACE_CHECK;
00863         }
00864     }
00865 }

PortableGroup::Locations * TAO::PG_Object_Group::locations_of_members  )  throw (CORBA::SystemException)
 

@TODO DOC

Definition at line 535 of file PG_Object_Group.cpp.

References ACE_CHECK_RETURN, ACE_GUARD_RETURN, ACE_NEW_THROW_EX, PortableGroup::Location, PortableGroup::Locations, MemberMap_Iterator, and TAO_SYNCH_MUTEX.

00537 {
00538   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00539                     guard,
00540                     this->internals_,
00541                     0);
00542 
00543   PortableGroup::Locations * result = 0;
00544 
00545   size_t count = this->members_.current_size ();
00546 
00547   ACE_NEW_THROW_EX (
00548     result,
00549     PortableGroup::Locations (count),
00550     CORBA::NO_MEMORY() );
00551   ACE_CHECK_RETURN (0);
00552 
00553   result->length (count);
00554 
00555   size_t pos = 0;
00556   for (MemberMap_Iterator it = this->members_.begin();
00557       it != this->members_.end();
00558       ++it)
00559   {
00560     const PortableGroup::Location & location = (*it).ext_id_;
00561     PortableGroup::Location & out = (*result)[pos];
00562     out = location;
00563   }
00564   return result;
00565 }

void TAO::PG_Object_Group::minimum_populate  ) 
 

@TODO DOC

Definition at line 868 of file PG_Object_Group.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_GUARD, create_members(), ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::current_size(), get_membership_style(), get_minimum_number_members(), members_, PortableGroup::MinimumNumberMembersValue, and TAO_SYNCH_MUTEX.

00869 {
00870   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00871 
00872   if ( this->get_membership_style () == PortableGroup::MEMB_INF_CTRL )
00873     {
00874       PortableGroup::MinimumNumberMembersValue minimum_number_members =
00875         this->get_minimum_number_members ();
00876       if (members_.current_size () < minimum_number_members)
00877         {
00878           this->create_members (minimum_number_members ACE_ENV_ARG_PARAMETER);
00879         }
00880     }
00881 }

PG_Object_Group& TAO::PG_Object_Group::operator= const PG_Object_Group rhs  )  [private]
 

PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::reference  )  const
 

return a duplicated reference to this group (IOGR)

Definition at line 121 of file PG_Object_Group.cpp.

References ACE_GUARD_RETURN, and TAO_SYNCH_MUTEX.

Referenced by TAO::PG_Group_Factory::groups_at_location().

00122 {
00123   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00124                     guard,
00125                     this->internals_,
00126                     PortableGroup::ObjectGroup::_nil ());
00127   return PortableGroup::ObjectGroup::_duplicate (this->reference_);
00128 }

void TAO::PG_Object_Group::remove_member const PortableGroup::Location the_location  )  throw (CORBA::SystemException, PortableGroup::MemberNotFound)
 

@TODO DOC

Definition at line 343 of file PG_Object_Group.cpp.

References ACE_CHECK, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_GUARD, ACE_THROW, LM_DEBUG, PortableGroup::Location, TAO::PG_Object_Group::MemberInfo::member_, TAO_debug_level, and TAO_SYNCH_MUTEX.

00348 {
00349   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00350   MemberInfo * info = 0;
00351   if (this->members_.unbind (the_location, info) == 0)
00352     {
00353       if (this->members_.current_size() > 0)
00354         {
00355           this->reference_ =
00356             this->manipulator_.remove_profiles (this->reference_.in (),
00357                                                 info->member_.in ()
00358                                                 ACE_ENV_ARG_PARAMETER);
00359           ACE_CHECK;
00360         }
00361       else
00362         {
00363           empty_ = 1;
00364         }
00365 
00366       delete info;
00367 
00368       if (the_location == this->primary_location_)
00369         {
00370           this->primary_location_.length(0);
00371         }
00372 
00373       if (this->increment_version ())
00374         {
00375           this->distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER);
00376           ACE_CHECK;
00377         }
00378 
00379     }
00380   else
00381     {
00382       if (TAO_debug_level > 6)
00383         {
00384           ACE_DEBUG ((LM_DEBUG,
00385                       "TAO-PG (%P|%t) - "
00386                       "remove_member throwing MemberNotFound.\n"
00387                       ));
00388         }
00389       ACE_THROW (PortableGroup::MemberNotFound() );
00390     }
00391 }

int TAO::PG_Object_Group::set_primary_member TAO_IOP::TAO_IOR_Property *  prop,
const PortableGroup::Location the_location
throw ( CORBA::SystemException , PortableGroup::MemberNotFound )
 

set the replica at the given location to be primary. Note: This should return void and throw FT::PrimaryNotSet but to avoid dependancies between PortableGroup and FaultTolerance it returns a boolean result. A false return means caller should throw FT::PrimaryNot_Set.

Definition at line 262 of file PG_Object_Group.cpp.

References ACE_CHECK_RETURN, ACE_DEBUG, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_ERROR, ACE_GUARD_RETURN, ACE_TEXT(), ACE_THROW_RETURN, TAO::PG_Object_Group::MemberInfo::is_primary_, LM_DEBUG, LM_ERROR, PortableGroup::Location, TAO::PG_Object_Group::MemberInfo::member_, MemberMap_Iterator, TAO_debug_level, and TAO_SYNCH_MUTEX.

00268 {
00269   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00270                     guard,
00271                     this->internals_,
00272                     0);
00273   int result = 1;
00274   MemberInfo * info = 0;
00275   if (this->members_.find (the_location, info) == 0)
00276     {
00277       int cleared = 0;
00278       this->primary_location_ = the_location;
00279       for (MemberMap_Iterator it = this->members_.begin();
00280            !cleared && it != this->members_.end();
00281            ++it)
00282         {
00283           cleared = (*it).int_id_->is_primary_;
00284           (*it).int_id_->is_primary_ = 0;
00285         }
00286       info->is_primary_ = 1;
00287 
00288       int set_ok =
00289         this->manipulator_.set_primary (prop,
00290                                         this->reference_.in (),
00291                                         info->member_.in ()
00292                                         ACE_ENV_ARG_PARAMETER);
00293       ACE_CHECK_RETURN (0);
00294       if (!set_ok)
00295         {
00296           if (TAO_debug_level > 3)
00297             {
00298               ACE_ERROR ((LM_ERROR,
00299                           ACE_TEXT ("%T %n (%P|%t) - ")
00300                           ACE_TEXT ("Can't set primary in IOGR .\n")
00301                           ));
00302             }
00303 //@@: ACE_THROW (FT::PrimaryNotSet());
00304           result = 0;
00305         }
00306 
00307       if (result && this->increment_version ())
00308         {
00309           this->distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER);
00310           ACE_CHECK_RETURN (0);
00311         }
00312       else
00313         {
00314           if (TAO_debug_level > 3)
00315             {
00316               ACE_DEBUG ((LM_DEBUG,
00317                           ACE_TEXT("TAO-PG (%P|%t) - set_primary_location ")
00318                           ACE_TEXT("throwing PrimaryNotSet because increment")
00319                           ACE_TEXT("version failed.\n")
00320                           ));
00321             }
00322 //@@: ACE_THROW (FT::PrimaryNotSet());
00323           result = 0;
00324         }
00325     }
00326   else
00327     {
00328       if (TAO_debug_level > 3)
00329         {
00330           ACE_DEBUG ((LM_DEBUG,
00331                       ACE_TEXT ("TAO-PG (%P|%t) - set_primary_location ")
00332                       ACE_TEXT ("throwing MemberNotFound.\n")));
00333         }
00334       ACE_THROW_RETURN (PortableGroup::MemberNotFound(),
00335                         -1);
00336     }
00337 
00338   return result;
00339 }

void TAO::PG_Object_Group::set_properties_dynamically const PortableGroup::Properties overrides  )  throw (CORBA::SystemException, PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)
 

@TODO DOC

Definition at line 405 of file PG_Object_Group.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_GUARD, PortableGroup::Properties, and TAO_SYNCH_MUTEX.

00411 {
00412   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00413 
00414   this->properties_.decode (overrides ACE_ENV_ARG_PARAMETER);
00415 
00416   //@@ int todo_override_rather_than_replace?
00417 }


Member Data Documentation

int TAO::PG_Object_Group::empty_ [private]
 

boolean true if empty group

Definition at line 335 of file PG_Object_Group.h.

Referenced by add_member_to_iogr(), and PG_Object_Group().

PortableGroup::FactoryRegistry_var TAO::PG_Object_Group::factory_registry_ [private]
 

Where to find the factories for replicas.

Definition at line 328 of file PG_Object_Group.h.

PortableGroup::FactoryInfos TAO::PG_Object_Group::group_specific_factories_ [private]
 

Definition at line 373 of file PG_Object_Group.h.

Referenced by get_group_specific_factories(), and PG_Object_Group().

PortableGroup::InitialNumberMembersValue TAO::PG_Object_Group::initial_number_members_ [private]
 

Definition at line 371 of file PG_Object_Group.h.

Referenced by PG_Object_Group().

TAO_SYNCH_MUTEX TAO::PG_Object_Group::internals_ [mutable, private]
 

Protect internal state.

Definition at line 323 of file PG_Object_Group.h.

TAO::PG_Object_Group_Manipulator& TAO::PG_Object_Group::manipulator_ [private]
 

Definition at line 332 of file PG_Object_Group.h.

MemberMap TAO::PG_Object_Group::members_ [private]
 

Definition at line 361 of file PG_Object_Group.h.

Referenced by distribute_iogr(), has_member_at(), initial_populate(), minimum_populate(), PG_Object_Group(), and ~PG_Object_Group().

PortableGroup::MinimumNumberMembersValue TAO::PG_Object_Group::minimum_number_members_ [private]
 

Definition at line 372 of file PG_Object_Group.h.

Referenced by PG_Object_Group().

PortableServer::ObjectId_var TAO::PG_Object_Group::object_id_ [private]
 

The CORBA object id assigned to this object group

Definition at line 358 of file PG_Object_Group.h.

CORBA::ORB_var TAO::PG_Object_Group::orb_ [private]
 

Definition at line 325 of file PG_Object_Group.h.

PortableGroup::Location TAO::PG_Object_Group::primary_location_ [private]
 

Definition at line 363 of file PG_Object_Group.h.

Referenced by get_primary_location(), and PG_Object_Group().

TAO::PG_Property_Set TAO::PG_Object_Group::properties_ [private]
 

Definition at line 367 of file PG_Object_Group.h.

Referenced by get_initial_number_members(), get_membership_style(), get_minimum_number_members(), and PG_Object_Group().

PortableGroup::ObjectGroup_var TAO::PG_Object_Group::reference_ [private]
 

the reference (IOGR) to this group

Definition at line 353 of file PG_Object_Group.h.

Referenced by add_member_to_iogr(), and PG_Object_Group().

ACE_CString TAO::PG_Object_Group::role_ [private]
 

Definition at line 337 of file PG_Object_Group.h.

Referenced by PG_Object_Group().

PortableGroup::TagGroupTaggedComponent TAO::PG_Object_Group::tagged_component_ [private]
 

the GroupTaggedComponent that defines this group contains: GIOP::Version component_version; TAO::String_Manager group_domain_id; PortableGroup::ObjectGroupId object_group_id; PortableGroup::ObjectGroupRefVersion object_group_ref_version;

Definition at line 348 of file PG_Object_Group.h.

PortableGroup::TypeId_var TAO::PG_Object_Group::type_id_ [private]
 

Definition at line 338 of file PG_Object_Group.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:05:31 2006 for TAO_PortableGroup by doxygen 1.3.6