Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes

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.

Classes

struct  MemberInfo

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)
void get_properties (PortableGroup::Properties_var &result) const
PortableGroup::ObjectGroupId get_object_group_id () const
void add_member (const PortableGroup::Location &the_location, CORBA::Object_ptr member)
int set_primary_member (TAO_IOP::TAO_IOR_Property *prop, const PortableGroup::Location &the_location)
void remove_member (const PortableGroup::Location &the_location)
void create_member (const PortableGroup::Location &the_location, const char *type_id, const PortableGroup::Criteria &the_criteria)
PortableGroup::Locationslocations_of_members (void)
CORBA::Object_ptr get_member_reference (const PortableGroup::Location &the_location)
void initial_populate (void)
void minimum_populate (void)
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 (void)
PortableGroup::ObjectGroup_ptr add_member_to_iogr (CORBA::Object_ptr member)
void create_members (size_t count)
 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_Manipulator & manipulator_
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_

Detailed Description

Definition at line 58 of file PG_Object_Group.h.


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.

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 51 of file PG_Object_Group.cpp.

  : internals_()
  , orb_ (CORBA::ORB::_duplicate (orb))
  , factory_registry_ (PortableGroup::FactoryRegistry::_duplicate (factory_registry))
  , manipulator_ (manipulator)
  , empty_ (1)
  , role_ (type_id)
  , type_id_ (CORBA::string_dup (type_id))
  , tagged_component_ (tagged_component)
  , reference_ (CORBA::Object::_duplicate(empty_group))
  , members_ ()
  , primary_location_(0)
  , properties_ (the_criteria, type_properties)
  , initial_number_members_ (0)
  , minimum_number_members_ (0)
  , group_specific_factories_ ()
{
}

TAO::PG_Object_Group::~PG_Object_Group ( void   ) 

Destructor.

Definition at line 78 of file PG_Object_Group.cpp.

{
  for (MemberMap_Iterator it = this->members_.begin();
      it != this->members_.end();
      ++it)
    {
      MemberInfo * member = (*it).int_id_;
      delete member;
    }
  this->members_.unbind_all ();
}

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 
)

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 182 of file PG_Object_Group.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);

  /////////////////////////////////////////
  // Convert the new member to a string IOR
  // This keeps a clean IOR (not an IOGR!)
  // while we add it to a group.  We need a
  // IORs, not IOGRs to send new IOGRs out
  // to replicas.

  CORBA::String_var member_ior_string =
    orb_->object_to_string (member);

  PortableGroup::ObjectGroup_var new_reference =
    add_member_to_iogr (member);

  // Convert new member back to a (non group) ior.
  CORBA::Object_var member_ior =
    this->orb_->string_to_object (member_ior_string.in ());

  MemberInfo * info = 0;
  ACE_NEW_THROW_EX (info,
                    MemberInfo (member_ior.in (),
                                the_location),
                    CORBA::NO_MEMORY());

  if (this->members_.bind (the_location, info) != 0)
    {
      // @@ Dale why this is a NO MEMORY exception?
      throw CORBA::NO_MEMORY();
    }

  this->reference_ = new_reference; // note var-to-var assignment does
                                    // a duplicate
  if (this->increment_version ())
    {
      this->distribute_iogr ();
    }
  else
    {
      throw PortableGroup::ObjectNotAdded ();
    }

  if (TAO_debug_level > 6)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT("PG (%P|%t) exit Object_Group add_member\n")));
    }
}

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

Definition at line 141 of file PG_Object_Group.cpp.

{
  // assume internals is locked

  PortableGroup::ObjectGroup_var result;

 ////////////////////////////
  // @@ HACK ALERT
  // The PortableGroup::ObjectGroupManager creates an object reference
  // containing a dummy entry so it will have a place to store the
  // tagged group component. If this is the first entry, we need to
  // remove that entry once we have a *real* member. This can be
  // avoided when we get support for TAG_MULTIPLE_COMPONENTS.   For
  // now, we already have a copy of the tagGroupTagged component and
  // we're going to use it below wen we increment the group version so
  // we can clean out the dummy entry.
  PortableGroup::ObjectGroup_var cleaned =
    PortableGroup::ObjectGroup::_duplicate (this->reference_.in ());
  if (this->empty_)
    {
      // remove the original profile.  It's a dummy entry supplied by
      // create_object.
      cleaned =
        this->manipulator_.remove_profiles (cleaned.in (),
                                            this->reference_.in ());
      this->empty_ = 0;
    }

  // create a list of references to be merged
  TAO_IOP::TAO_IOR_Manipulation::IORList iors (2);
  iors.length (2);
  iors [0] = CORBA::Object::_duplicate (cleaned.in());
  iors [1] = CORBA::Object::_duplicate (member);

  // Now merge the list into one new IOGR
  result =
    this->manipulator_.merge_iors (iors);
  return result._retn ();
}

void TAO::PG_Object_Group::create_member ( const PortableGroup::Location the_location,
const char *  type_id,
const PortableGroup::Criteria the_criteria 
)

@TODO DOC

Definition at line 581 of file PG_Object_Group.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);


  if (0 != this->members_.find (the_location))
    {
      // @@ what if factories were passed as criteria?

      CORBA::String_var factory_type;
      PortableGroup::FactoryInfos_var factories =
        this->factory_registry_->list_factories_by_role (
          role_.c_str(),
          factory_type.out ());

      // @@ what if factory_type != type_id != this->type_id_

      int created = 0; // bool
      CORBA::ULong factory_count = factories->length ();
      for (CORBA::ULong factory_pos = 0;
           ! created && factory_pos < factory_count;
           ++factory_pos)
        {
          const PortableGroup::FactoryInfo & factory_info =
            (*factories)[factory_pos];
          if (factory_info.the_location == the_location)
            {
              // @@ should we merge the_criteria with
              // factory_info.the_criteria?

              PortableGroup::GenericFactory::FactoryCreationId_var fcid;
              CORBA::Object_var member =
                factory_info.the_factory->create_object (
                  type_id,
                  the_criteria,
                  fcid. out());

              // convert the new member to a stringified IOR to avoid
              // contamination with group info
              CORBA::String_var member_ior_string =
                orb_->object_to_string (member.in ());

              PortableGroup::ObjectGroup_var new_reference =
                this->add_member_to_iogr (member.in ());

              // Convert new member back to a (non group) ior.
              CORBA::Object_var member_ior =
                this->orb_->string_to_object (member_ior_string.in ());

              MemberInfo * info = 0;
              ACE_NEW_THROW_EX (info, MemberInfo(
                                                 member_ior.in(),
                                                 the_location,
                                                 factory_info.the_factory,
                                                 fcid.in ()),
                                CORBA::NO_MEMORY());

              if (this->members_.bind (the_location, info) != 0)
                {
                  throw CORBA::NO_MEMORY();
                }

              this->reference_ = new_reference; // note var-to-var
                                                // assignment does a
                                                // duplicate
              if (this->increment_version ())
                {
                  this->distribute_iogr ();
                }
              created = 1;
            }
        }
      if (! created)
        {
          throw PortableGroup::NoFactory ();
        }
    }
  else
    {
      throw PortableGroup::MemberAlreadyPresent ();
    }
}

void TAO::PG_Object_Group::create_members ( size_t  count  )  [private]

Definition at line 668 of file PG_Object_Group.cpp.

{
  // assume internals is locked
  // @@ what if factories were passed as criteria?

  CORBA::String_var factory_type;
  PortableGroup::FactoryInfos_var factories =
  this->factory_registry_->list_factories_by_role (
        role_.c_str(),
        factory_type.out ());

  CORBA::ULong factory_count = factories->length ();
  if (factory_count > 0)
    {
      CORBA::ULong factory_pos = 0;
      while (members_.current_size () < count && factory_pos < factory_count)
        {
          const PortableGroup::FactoryInfo & factory_info =
            (*factories)[factory_pos];
          const PortableGroup::Location & factory_location =
            factory_info.the_location;
          if (0 != this->members_.find (factory_location))
            {
              ///////////////////////////////////////////
              // If a factory refuses to create a replica
              // it's not fatal.
              try
                {
                  PortableGroup::GenericFactory::FactoryCreationId_var fcid;
                  CORBA::Object_var member =
                    factory_info.the_factory->create_object (
                      this->type_id_.in (),
                      factory_info.the_criteria,
                      fcid. out());

                  // convert the new member to a stringified IOR to avoid
                  // contamination with group info
                  CORBA::String_var member_ior_string =
                    orb_->object_to_string (member.in ());

                  PortableGroup::ObjectGroup_var new_reference =
                    this->add_member_to_iogr (member.in ());

                  // Convert new member back to a (non group) ior.
                  CORBA::Object_var member_ior =
                    this->orb_->string_to_object (member_ior_string.in ());

                  MemberInfo * info = 0;
                  ACE_NEW_THROW_EX (info, MemberInfo(
                                                     member_ior.in(),
                                                     factory_location,
                                                     factory_info.the_factory,
                                                     fcid.in ()),
                                    CORBA::NO_MEMORY());

                  if (this->members_.bind (factory_location, info) != 0)
                    {
                      throw CORBA::NO_MEMORY();
                    }
                  this->reference_ =
                    new_reference; // note var-to-var assignment does
                                   // a duplicate
                }
              catch (const CORBA::Exception&)
                {
                  // log, but otherwise ignore the errorf
                  if (TAO_debug_level > 0)
                    {
                      ACE_ERROR ((LM_ERROR,
                                  ACE_TEXT ("PG (%P|%t) Replica Factory ")
                                  ACE_TEXT ("@ %s refused create_object ")
                                  ACE_TEXT ("request for type %s\n"),
                                  static_cast<const char *> (factory_info.the_location[0].id),
                                  static_cast<const char *> (this->type_id_.in ())
                                  ));
                    }
                }
            }
        }

      if (this->increment_version ())
        {
          this->distribute_iogr ();
        }
    }
  else
    {
      throw PortableGroup::NoFactory();
    }
}

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

Definition at line 426 of file PG_Object_Group.cpp.

{
  // assume internals is locked
  CORBA::String_var iogr =
    this->orb_->object_to_string (this->reference_.in());

//  size_t n_rep = 0; // for dump_ior below
  for (MemberMap_Iterator it = this->members_.begin();
       it != this->members_.end ();
       ++it)
    {
      MemberInfo const * info = (*it).int_id_;
      //
      // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface
      // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_);
      // but it doesn work: error message at replica is:
      // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0]
      // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed
      // back to using _narrow
      PortableGroup::TAO_UpdateObjectGroup_var uog =
        PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_.in ());
      if (!CORBA::is_nil (uog.in ()))
        {
          try
            {
              if (TAO_debug_level > 3)
                {
                  ACE_DEBUG ((LM_DEBUG,
                              "PG (%P|%t) -  Object_Group pushing "
                              "IOGR to %s member: %s@%s.\n",
                              (info->is_primary_ ? "Primary" : "Backup"),
                              this->role_.c_str (),
                              static_cast<const char *> (info->location_[0].id)
                              ));
                }
              //        dump_ior ("group", "iogr", this->tagged_component_.object_group_ref_version, iogr);
              //        CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in());
              //        dump_ior (info->location_[0].id, "ior", (this->tagged_component_.object_group_ref_version * 100) + n_rep++, replica_ior);
              uog->tao_update_object_group (iogr.in (),
                                            this->tagged_component_.object_group_ref_version,
                                            info->is_primary_);
            }
          catch (const CORBA::Exception&)
            {
              // we expect an exception
              // tao_update_object_group is not a real method
            }
        }
      else
        {
          ACE_ERROR ((LM_ERROR,
                      "TAO::PG_Object_Group::distribute iogr can't "
                      "narrow member reference to "
                      "PortableGroup::TAO_UpdateObjectGroup.\n"
                      ));
        }
    }
}

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 119 of file PG_Object_Group.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);

  // copy is needed to have some semblance of thread safeness.
  // if performance is an issue avoid this method.
  result = this->group_specific_factories_;
}

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

@TODO DOC

Definition at line 568 of file PG_Object_Group.cpp.

{
  PortableGroup::InitialNumberMembersValue initial_number_members = 0;
  if (!TAO::find (properties_,
                  PortableGroup::PG_INITIAL_NUMBER_MEMBERS,
                  initial_number_members))
    {
      initial_number_members = TAO_PG_INITIAL_NUMBER_MEMBERS;
    }
  return initial_number_members;
}

CORBA::Object_ptr TAO::PG_Object_Group::get_member_reference ( const PortableGroup::Location the_location  ) 

@TODO DOC

Definition at line 517 of file PG_Object_Group.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    CORBA::Object::_nil ());

  CORBA::Object_var result;

  MemberInfo * info = 0;
  if (this->members_.find (the_location, info) == 0)
    {
      result = CORBA::Object::_duplicate (info->member_.in ());
    }
  else
    {
      throw PortableGroup::MemberNotFound();
    }
  return result._retn ();
}

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

@TODO DOC

Definition at line 541 of file PG_Object_Group.cpp.

{
  PortableGroup::MembershipStyleValue membership_style = 0;
  if (!TAO::find (properties_,
                  PortableGroup::PG_MEMBERSHIP_STYLE,
                  membership_style))
    {
      membership_style = TAO_PG_MEMBERSHIP_STYLE;
    }
  return membership_style;
}

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

@TODO DOC

Definition at line 555 of file PG_Object_Group.cpp.

{
  PortableGroup::MinimumNumberMembersValue minimum_number_members = 0;
  if (!TAO::find (properties_,
                  PortableGroup::PG_MINIMUM_NUMBER_MEMBERS,
                  minimum_number_members))
    {
      minimum_number_members = TAO_PG_MINIMUM_NUMBER_MEMBERS;
    }
  return minimum_number_members;
}

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

@TODO DOC

Definition at line 356 of file PG_Object_Group.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    0);
  return this->tagged_component_.object_group_id;
}

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

get location of primary member

Definition at line 130 of file PG_Object_Group.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    this->primary_location_);
  return this->primary_location_;
}

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

@TODO DOC

Definition at line 377 of file PG_Object_Group.cpp.

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

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

returns a duplicate caller must release

Definition at line 386 of file PG_Object_Group.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    0);
  return CORBA::string_dup (this->type_id_);
}

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

@TODO DOC

Definition at line 793 of file PG_Object_Group.cpp.

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

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

Definition at line 400 of file PG_Object_Group.cpp.

{
  // assume internals is locked
  int result = 0;
  this->tagged_component_.object_group_ref_version += 1;
  if (TAO_debug_level > 3)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("%T %n (%P|%t) - Setting IOGR version to %u\n"),
                  static_cast<unsigned> (this->tagged_component_.object_group_ref_version)
                  ));
    }

  // Set the version
  if (TAO::PG_Utils::set_tagged_component (this->reference_,
                                           this->tagged_component_))
    {
      result = 1;
    }
  return result;
}

void TAO::PG_Object_Group::initial_populate ( void   ) 

@TODO DOC

Definition at line 760 of file PG_Object_Group.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);

  if (this->get_membership_style () == PortableGroup::MEMB_INF_CTRL)
    {
      PortableGroup::InitialNumberMembersValue initial_number_members =
        this->get_initial_number_members ();

      if (this->members_.current_size () < initial_number_members)
        {
          this->create_members (initial_number_members);
        }
    }
}

PortableGroup::Locations * TAO::PG_Object_Group::locations_of_members ( void   ) 

@TODO DOC

Definition at line 486 of file PG_Object_Group.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    0);

  PortableGroup::Locations * result = 0;

  size_t count = this->members_.current_size ();

  ACE_NEW_THROW_EX (
    result,
    PortableGroup::Locations (count),
    CORBA::NO_MEMORY() );

  result->length (count);

  size_t pos = 0;
  for (MemberMap_Iterator it = this->members_.begin();
      it != this->members_.end();
      ++it)
  {
    const PortableGroup::Location & location = (*it).ext_id_;
    PortableGroup::Location & out = (*result)[pos];
    out = location;
  }
  return result;
}

void TAO::PG_Object_Group::minimum_populate ( void   ) 

@TODO DOC

Definition at line 777 of file PG_Object_Group.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);

  if ( this->get_membership_style () == PortableGroup::MEMB_INF_CTRL )
    {
      PortableGroup::MinimumNumberMembersValue minimum_number_members =
        this->get_minimum_number_members ();
      if (members_.current_size () < minimum_number_members)
        {
          this->create_members (minimum_number_members);
        }
    }
}

PG_Object_Group& TAO::PG_Object_Group::operator= ( const PG_Object_Group rhs  )  [private]
PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::reference ( void   )  const

return a duplicated reference to this group (IOGR)

Definition at line 109 of file PG_Object_Group.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    PortableGroup::ObjectGroup::_nil ());
  return PortableGroup::ObjectGroup::_duplicate (this->reference_);
}

void TAO::PG_Object_Group::remove_member ( const PortableGroup::Location the_location  ) 

@TODO DOC

Definition at line 310 of file PG_Object_Group.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
  MemberInfo * info = 0;
  if (this->members_.unbind (the_location, info) == 0)
    {
      if (this->members_.current_size() > 0)
        {
          this->reference_ =
            this->manipulator_.remove_profiles (this->reference_.in (),
                                                info->member_.in ());
        }
      else
        {
          empty_ = 1;
        }

      delete info;

      if (the_location == this->primary_location_)
        {
          this->primary_location_.length(0);
        }

      if (this->increment_version ())
        {
          this->distribute_iogr ();
        }

    }
  else
    {
      if (TAO_debug_level > 6)
        {
          ACE_DEBUG ((LM_DEBUG,
                      "TAO-PG (%P|%t) - "
                      "remove_member throwing MemberNotFound.\n"
                      ));
        }
      throw PortableGroup::MemberNotFound();
    }
}

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

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 236 of file PG_Object_Group.cpp.

{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    0);
  int result = 1;
  MemberInfo * info = 0;
  if (this->members_.find (the_location, info) == 0)
    {
      int cleared = 0;
      this->primary_location_ = the_location;
      for (MemberMap_Iterator it = this->members_.begin();
           !cleared && it != this->members_.end();
           ++it)
        {
          cleared = (*it).int_id_->is_primary_;
          (*it).int_id_->is_primary_ = 0;
        }
      info->is_primary_ = 1;

      int set_ok =
        this->manipulator_.set_primary (prop,
                                        this->reference_.in (),
                                        info->member_.in ());
      if (!set_ok)
        {
          if (TAO_debug_level > 3)
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("%T %n (%P|%t) - ")
                          ACE_TEXT ("Can't set primary in IOGR .\n")
                          ));
            }
//@@: ACE_THROW (FT::PrimaryNotSet());
          result = 0;
        }

      if (result && this->increment_version ())
        {
          this->distribute_iogr ();
        }
      else
        {
          if (TAO_debug_level > 3)
            {
              ACE_DEBUG ((LM_DEBUG,
                          ACE_TEXT("TAO-PG (%P|%t) - set_primary_location ")
                          ACE_TEXT("throwing PrimaryNotSet because increment")
                          ACE_TEXT("version failed.\n")
                          ));
            }
//@@: ACE_THROW (FT::PrimaryNotSet());
          result = 0;
        }
    }
  else
    {
      if (TAO_debug_level > 3)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO-PG (%P|%t) - set_primary_location ")
                      ACE_TEXT ("throwing MemberNotFound.\n")));
        }
      throw PortableGroup::MemberNotFound();
    }

  return result;
}

void TAO::PG_Object_Group::set_properties_dynamically ( const PortableGroup::Properties overrides  ) 

@TODO DOC

Definition at line 366 of file PG_Object_Group.cpp.

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);

  this->properties_.decode (overrides);

  //@@ int todo_override_rather_than_replace?
}


Member Data Documentation

int TAO::PG_Object_Group::empty_ [private]

boolean true if empty group

Definition at line 303 of file PG_Object_Group.h.

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

Where to find the factories for replicas.

Definition at line 296 of file PG_Object_Group.h.

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

Definition at line 341 of file PG_Object_Group.h.

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

Definition at line 339 of file PG_Object_Group.h.

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

Protect internal state.

Definition at line 291 of file PG_Object_Group.h.

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

Definition at line 300 of file PG_Object_Group.h.

MemberMap TAO::PG_Object_Group::members_ [private]

Definition at line 329 of file PG_Object_Group.h.

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

Definition at line 340 of file PG_Object_Group.h.

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

The CORBA object id assigned to this object group

Definition at line 326 of file PG_Object_Group.h.

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

Definition at line 293 of file PG_Object_Group.h.

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

Definition at line 331 of file PG_Object_Group.h.

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

Definition at line 335 of file PG_Object_Group.h.

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

the reference (IOGR) to this group

Definition at line 321 of file PG_Object_Group.h.

ACE_CString TAO::PG_Object_Group::role_ [private]

Definition at line 305 of file PG_Object_Group.h.

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 316 of file PG_Object_Group.h.

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

Definition at line 306 of file PG_Object_Group.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines