diff options
author | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-12-01 20:31:35 +0000 |
---|---|---|
committer | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-12-01 20:31:35 +0000 |
commit | a923bfba75c60f015cb10451f5cd598fade1ddb8 (patch) | |
tree | e1e7680d1c402dac17b8bd73b433384c4f28ef4e | |
parent | 7b5035c2ffab78d38bd6ef85466b32b6dad9781f (diff) | |
download | ATCD-a923bfba75c60f015cb10451f5cd598fade1ddb8.tar.gz |
ChangeLogTag: Mon Dec 1 13:24:15 2003 Dale Wilson <wilson_d@ociweb.com>
-rw-r--r-- | TAO/ChangeLog | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp | 32 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp | 119 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp | 333 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h | 104 |
6 files changed, 314 insertions, 292 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index a4943485d1c..eff8c04b3ca 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,12 @@ +Mon Dec 1 13:24:15 2003 Dale Wilson <wilson_d@ociweb.com> + + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp: + * orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp: + Honor initial and minimum member counts. + Mon Dec 1 09:16:28 2003 Dale Wilson <wilson_d@ociweb.com> * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp: diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp index cdc8741efd0..a18a67a074f 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp @@ -163,8 +163,15 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) this->factory_registry_.init (this->orb_.in (), this->poa_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + PortableGroup::FactoryRegistry_var factory_registry = this->factory_registry_.reference (); + // @@: do we want to use the same poa to create object groups? - this->group_factory_.init (this->orb_.in (), this->poa_.in ()); + this->group_factory_.init ( + this->orb_.in (), + this->poa_.in (), + factory_registry.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); // Activate ourself in the POA. PortableServer::ObjectId_var oid = this->poa_->activate_object ( @@ -700,7 +707,7 @@ TAO::FT_ReplicationManager::create_member ( if (TAO_debug_level > 0) { ACE_ERROR ( (LM_ERROR, - ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::create_member in unknown group\n") + ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::create_member: unknown group\n") )); } ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result._retn ()); @@ -764,8 +771,15 @@ TAO::FT_ReplicationManager::remove_member ( TAO::PG_Object_Group * group = 0; if (this->group_factory_.find_group (object_group, group)) { - group->remove_member(the_location ACE_ENV_ARG_PARAMETER); + group->remove_member (the_location ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (result._retn ()); + + group->minimum_populate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (result._retn ()); + //@@ how about the case where the member was removed successfully, + // but for one reason or another we were unable to bring the group + // back up to minimum_number_of_replicas? + result = group->reference (); } else @@ -961,7 +975,7 @@ TAO::FT_ReplicationManager::create_object ( ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); - TAO::PG_Object_Group * objectGroup + TAO::PG_Object_Group * group = this->group_factory_.create_group ( type_id, the_criteria, @@ -969,6 +983,12 @@ TAO::FT_ReplicationManager::create_object ( ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); + group->initial_populate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + //@@ on error we should remove the group from the Group_Factory + // doing this "right" will require a var-type pointer to the object group + // that knows about the factory, too. + // Allocate a new FactoryCreationId for use as an "out" parameter. PortableGroup::GenericFactory::FactoryCreationId_var factory_id = 0; ACE_NEW_THROW_EX (factory_id, @@ -979,11 +999,11 @@ TAO::FT_ReplicationManager::create_object ( ENOMEM), CORBA::COMPLETED_NO)); ACE_CHECK_RETURN (CORBA::Object::_nil ()); - PortableGroup::ObjectGroupId group_id = objectGroup->get_object_group_id (); + PortableGroup::ObjectGroupId group_id = group->get_object_group_id (); *factory_id <<= group_id; factory_creation_id = factory_id._retn(); - METHOD_RETURN (TAO::FT_ReplicationManager::create_object) objectGroup->reference (); + METHOD_RETURN (TAO::FT_ReplicationManager::create_object) group->reference (); } void diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp index 1832ddee8f7..8d6f3c0ae41 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp @@ -43,16 +43,22 @@ TAO::PG_Group_Factory::~PG_Group_Factory (void) void TAO::PG_Group_Factory::init ( CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) + PortableServer::POA_ptr poa, + PortableGroup::FactoryRegistry_ptr factory_registry + ACE_ENV_ARG_DECL) { ACE_ASSERT (CORBA::is_nil (this->orb_.in ())); ACE_ASSERT (CORBA::is_nil (this->poa_.in ())); + ACE_ASSERT (CORBA::is_nil (this->factory_registry_.in ())); this->orb_ = CORBA::ORB::_duplicate(orb); this->poa_ = PortableServer::POA::_duplicate (poa); + this->factory_registry_ = PortableGroup::FactoryRegistry::_duplicate (factory_registry); + ACE_ASSERT (!CORBA::is_nil (this->orb_.in ())); ACE_ASSERT (!CORBA::is_nil (this->poa_.in ())); + ACE_ASSERT (!CORBA::is_nil (this->factory_registry_.in ())); this->manipulator_.init (orb, poa ACE_ENV_ARG_PARAMETER); // ACE_CHECK; @@ -98,7 +104,7 @@ TAO::PG_Object_Group * TAO::PG_Group_Factory::create_group ( objectGroup, TAO::PG_Object_Group ( this->orb_.in (), -// this->poa_.in (), + this->factory_registry_.in (), this->manipulator_, empty_group.in (), tagged_component, @@ -116,115 +122,6 @@ TAO::PG_Object_Group * TAO::PG_Group_Factory::create_group ( return objectGroup; } - -#if 0 -Initialize object group - - PortableGroup::ObjectGroup_var object_group = PortableGroup::ObjectGroup::_nil(); - - PortableGroup::Properties_var properties = - this->property_manager_.get_type_properties (type_id - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - PortableGroup::MembershipStyleValue membership_style = - TAO_PG_MEMBERSHIP_STYLE; - PortableGroup::FactoriesValue factory_infos(0); - - PortableGroup::InitialNumberMembersValue initial_number_members = - TAO_PG_INITIAL_NUMBER_MEMBERS; - PortableGroup::MinimumNumberMembersValue minimum_number_members = - TAO_PG_MINIMUM_NUMBER_MEMBERS; - - // Make sure the criteria for the object group being created are - // valid. - this->process_criteria (type_id, - the_criteria, - membership_style, - factory_infos, - initial_number_members, - minimum_number_members - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - - PortableGroup::ObjectGroupId group_id; -// PortableGroup::ObjectGroup_var - object_group = - this->object_group_manager_.create_object_group (type_id, // in - this->domain_id_, // in - the_criteria, // in - group_id // out - ACE_ENV_ARG_PARAMETER); - - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - // Allocate a new FactoryCreationId for use as an "out" parameter. - PortableGroup::GenericFactory::FactoryCreationId_var factory_id = 0; - ACE_NEW_THROW_EX (factory_id, - PortableGroup::GenericFactory::FactoryCreationId, - CORBA::NO_MEMORY ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - *factory_id <<= group_id; - - - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - - TAO_PG_Factory_Set factory_set; - - const CORBA::ULong factory_infos_count = factory_infos.length (); - - ACE_TRY - { - if (factory_infos_count > 0 - && membership_style == PortableGroup::MEMB_INF_CTRL) - { - this->populate_object_group (object_group.in (), - type_id, - factory_infos, - minimum_number_members, - factory_set - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - CORBA::Object::_nil ()); - - - if (this->factory_map_.bind (group_id, factory_set) != 0) - ACE_TRY_THROW (PortableGroup::ObjectNotCreated ()); - } - } - ACE_CATCHANY - { - this->delete_object_i (factory_set, - 1 /* Ignore exceptions */ - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->object_group_manager_.destroy_object_group (group_id - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_RE_THROW; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - factory_creation_id = factory_id._retn(); - return result; -} -#endif - - void TAO::PG_Group_Factory::delete_group (PortableGroup::ObjectGroup_ptr object_group ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h index 95b6672c0fb..4ae831d0011 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h @@ -71,7 +71,11 @@ namespace TAO /// Destructor. ~PG_Group_Factory (); - void init (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); + void init ( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableGroup::FactoryRegistry_ptr factory_registry + ACE_ENV_ARG_DECL); TAO::PG_Object_Group * create_group ( @@ -166,6 +170,9 @@ namespace TAO /// Reference to the POA used to create object group references. PortableServer::POA_var poa_; + /// The factory registry for replica factories + PortableGroup::FactoryRegistry_var factory_registry_; + ::TAO::PG_Object_Group_Manipulator manipulator_; const char * domain_id_; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp index 5be39951948..633710c88d0 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp @@ -3,6 +3,7 @@ // $Id$ #include "PG_Object_Group.h" +#include "PG_conf.h" #include <ace/Get_Opt.h> #include <ace/Vector_T.h> @@ -56,85 +57,31 @@ TAO::PG_Object_Group::MemberInfo::~MemberInfo () TAO::PG_Object_Group::PG_Object_Group ( - CORBA::ORB_ptr orb, - 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::Properties_Decoder * type_properties) - : internals_() - , orb_ (CORBA::ORB::_duplicate (orb)) - , manipulator_ (manipulator) - , empty_ (1) - , role_ (type_id) - , tagged_component_ (tagged_component) - , reference_ (CORBA::Object::_duplicate(empty_group)) -// MemberMap members_ self initialized - , primary_location_(0) - , properties_ (the_criteria, type_properties) - , membership_style_ (0) - , initial_number_members_ (0) - , minimum_number_members_ (0) -// group_specific_factories_ self initialized -{ -} - -#if 0 -//static -TAO::PG_Object_Group * TAO::PG_Object_Group::create ( CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - CORBA::Object_ptr empty_group, // empty group as created by ObjectManager + 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::Properties_Decoder * type_properties - ACE_ENV_ARG_DECL) + TAO_PG::Properties_Decoder * type_properties) + : 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_Manipulator * manipulator = 0; - ACE_NEW_THROW_EX (manipulator, - TAO::PG_Object_Group_Manipulator (), - CORBA::NO_MEMORY ()); - int init_ok = manipulator->init (orb, poa ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); - if(init_ok) - { - if (TAO_debug_level > 3) - { - ACE_ERROR ( (LM_ERROR, - ACE_TEXT ( - "%T %n (%P|%t) - " - "Could not find an IOR Manipulator.\n"))); - } - return 0; - } - - // pick up the object group information as assigned by - // ObjectGroupManager - - PortableGroup::TagGroupTaggedComponent tagged_component; - - if (! TAO::PG_Utils::get_tagged_component (empty_group, tagged_component)) - { - ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound(), 0); - } - - TAO::PG_Object_Group * objectGroup = 0; - ACE_NEW_THROW_EX ( - objectGroup, - TAO::PG_Object_Group ( - orb, - manipulator, - empty_group, - tagged_component, - type_id, - the_criteria, - type_properties - ), - CORBA::NO_MEMORY()); - return objectGroup; } -#endif TAO::PG_Object_Group::~PG_Object_Group () { @@ -148,8 +95,6 @@ TAO::PG_Object_Group::~PG_Object_Group () } } - - #if 0 // may want this again someday ///////////////////// // q&d debug function @@ -171,52 +116,6 @@ PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::reference()const return PortableGroup::ObjectGroup::_duplicate (this->reference_); } -void TAO::PG_Object_Group::set_membership_style (PortableGroup::MembershipStyleValue style) -{ - InternalGuard guard(this->internals_); - this->membership_style_ = style; -} - -PortableGroup::MembershipStyleValue TAO::PG_Object_Group::get_membership_style () const -{ - // const cast to simulate mutable - InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); - return this->membership_style_; -} - -void TAO::PG_Object_Group::set_initial_number_members (PortableGroup::InitialNumberMembersValue count) -{ - InternalGuard guard(this->internals_); - this->initial_number_members_ = count; -} - -PortableGroup::InitialNumberMembersValue TAO::PG_Object_Group::get_initial_number_members () const -{ - // const cast to simulate mutable - InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); - return this->initial_number_members_; -} - -void TAO::PG_Object_Group::set_minimum_number_members (PortableGroup::MinimumNumberMembersValue count) -{ - InternalGuard guard(this->internals_); - this->minimum_number_members_ = count; -} - -PortableGroup::MinimumNumberMembersValue TAO::PG_Object_Group::get_minimum_number_members ()const -{ - // const cast to simulate mutable - InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); - return this->minimum_number_members_; -} - -void TAO::PG_Object_Group::set_group_specific_factories (const PortableGroup::FactoryInfos & infos) -{ - InternalGuard guard(this->internals_); - this->group_specific_factories_ = infos; -} - - void TAO::PG_Object_Group::get_group_specific_factories (PortableGroup::FactoryInfos & result) const { // const cast to simulate mutable @@ -226,8 +125,7 @@ void TAO::PG_Object_Group::get_group_specific_factories (PortableGroup::FactoryI result = this->group_specific_factories_; } - -const PortableGroup::Location & TAO::PG_Object_Group::primary_location() const +const PortableGroup::Location & TAO::PG_Object_Group::get_primary_location() const { // const cast to simulate mutable InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); @@ -560,6 +458,88 @@ void TAO::PG_Object_Group::distribute_iogr (ACE_ENV_ARG_DECL) } } +PortableGroup::Locations * TAO::PG_Object_Group::locations_of_members (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + InternalGuard guard(this->internals_); + PortableGroup::Locations * result = 0; + + size_t count = this->members_.current_size (); + + ACE_NEW_THROW_EX ( + result, + PortableGroup::Locations (count), + CORBA::NO_MEMORY() ); + ACE_CHECK_RETURN (0); + + result->length (count); + + size_t pos = 0; + for (MemberMap_Iterator it = this->members_.begin(); + it != this->members_.end(); + this->members_.begin()) + { + const PortableGroup::Location & location = (*it).ext_id_; + PortableGroup::Location & out = (*result)[pos]; + out = location; + } + return result; +} + +CORBA::Object_ptr TAO::PG_Object_Group::get_member_reference ( + const PortableGroup::Location & the_location + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableGroup::MemberNotFound)) +{ + InternalGuard guard(this->internals_); + CORBA::Object_var result = CORBA::Object::_nil (); + + MemberInfo * info; + if (this->members_.find (the_location, info) == 0) + { + result = CORBA::Object::_duplicate(info->member_.in ()); + } + else + { + ACE_THROW_RETURN (PortableGroup::MemberNotFound(), result._retn ()); + } + return result._retn (); +} + + +PortableGroup::MembershipStyleValue TAO::PG_Object_Group::get_membership_style () const +{ + PortableGroup::MembershipStyleValue membership_style = 0; + if (! TAO_PG::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 () const +{ + PortableGroup::MinimumNumberMembersValue minimum_number_members = 0; + if (! TAO_PG::find (properties_, PortableGroup::PG_MINIMUM_NUMBER_MEMBERS, minimum_number_members)) + { + minimum_number_members = TAO_PG_MINIMUM_NUMBER_MEMBERS; + } + return minimum_number_members; +} + +PortableGroup::InitialNumberMembersValue TAO::PG_Object_Group::get_initial_number_members () const +{ + PortableGroup::InitialNumberMembersValue initial_number_members = 0; + if (! TAO_PG::find (properties_, PortableGroup::PG_INITIAL_NUMBER_MEMBERS, initial_number_members)) + { + initial_number_members = TAO_PG_INITIAL_NUMBER_MEMBERS; + } + return initial_number_members; +} + void TAO::PG_Object_Group::create_member ( const PortableGroup::Location & the_location, const char * type_id, @@ -572,30 +552,105 @@ void TAO::PG_Object_Group::create_member ( PortableGroup::InvalidCriteria, PortableGroup::CannotMeetCriteria)) { - TODO -} + InternalGuard guard(this->internals_); -PortableGroup::Locations * TAO::PG_Object_Group::locations_of_members (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - PortableGroup::Locations * result = 0; +ACE_UNUSED_ARG (the_location); +ACE_UNUSED_ARG (type_id); +ACE_UNUSED_ARG (the_criteria); TODO - return result; } -CORBA::Object_ptr TAO::PG_Object_Group::get_member_reference ( - const PortableGroup::Location & the_location - ACE_ENV_ARG_DECL) +void TAO::PG_Object_Group::create_members (size_t count ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException, - PortableGroup::ObjectGroupNotFound, - PortableGroup::MemberNotFound)) + PortableGroup::NoFactory + )) { - CORBA::Object_var result = CORBA::Object::_nil (); - TODO - return result._retn (); + // 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 () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_ASSERT (!CORBA::_nil (factories.in ())); + + 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. + ACE_TRY_NEW_ENV + { + PortableGroup::GenericFactory::FactoryCreationId_var fcid; + factory_info.the_factory->create_object ( + this->type_id_.in (), + factory_info.the_criteria, + fcid. out() + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // log, but otherwise ignore the errorf + if (TAO_debug_level > 0) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("PG (%P|%t) Replica Factory @ %s refused create_object request for type %s\n"), + ACE_static_cast (const char *, factory_info.the_location[0].id), + ACE_static_cast (const char *, this->type_id_.in ()) + )); + } + } + ACE_ENDTRY; + } + } + } + else + { + ACE_THROW (PortableGroup::NoFactory()); + } +} + +void TAO::PG_Object_Group::initial_populate (ACE_ENV_SINGLE_ARG_DECL) +{ + InternalGuard guard(this->internals_); + if ( this->get_membership_style() == PortableGroup::MEMB_INF_CTRL ) + { + PortableGroup::InitialNumberMembersValue initial_number_members = this->get_initial_number_members (); + if (members_.current_size () < initial_number_members) + { + this->create_members (initial_number_members); + } + } +} + +void TAO::PG_Object_Group::minimum_populate (ACE_ENV_SINGLE_ARG_DECL) +{ + InternalGuard 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); + } + } } + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Hash_Map_Manager_Ex < diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h index 910a4694e4f..0d84beed4be 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h @@ -114,8 +114,12 @@ namespace TAO ///////////////////// // Construct/Destruct public: + /** + * @@TODO DOC + */ 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, @@ -131,27 +135,9 @@ namespace TAO // public methods public: - - /// Set object group id - void set_object_group_id (PortableGroup::ObjectGroupId oid); - - /// Set type ID - void set_typeid (PortableGroup::TypeId type_id); - /// return a duplicated reference to this group (IOGR) PortableGroup::ObjectGroup_ptr reference()const; - void set_membership_style (PortableGroup::MembershipStyleValue style); - PortableGroup::MembershipStyleValue get_membership_style () const; - - void set_initial_number_members (PortableGroup::InitialNumberMembersValue count); - PortableGroup::InitialNumberMembersValue get_initial_number_members () const; - - void set_minimum_number_members (PortableGroup::MinimumNumberMembersValue count); - PortableGroup::MinimumNumberMembersValue get_minimum_number_members ()const; - - void set_group_specific_factories (const PortableGroup::FactoryInfos & infos); - /** * Note the caller receives a copy of the factoryinfos in the result argument. * inefficient, but thread safe. @@ -161,7 +147,7 @@ namespace TAO /** * get location of primary member */ - const PortableGroup::Location & primary_location() const; + const PortableGroup::Location & get_primary_location() const; /** * returns a duplicate @@ -169,6 +155,27 @@ namespace TAO */ PortableGroup::TypeId get_type_id ()const; + + /** + * @@TODO DOC + */ + PortableGroup::MembershipStyleValue get_membership_style() const; + + /** + * @@TODO DOC + */ + PortableGroup::MinimumNumberMembersValue get_minimum_number_members () const; + + /** + * @@TODO DOC + */ + PortableGroup::InitialNumberMembersValue get_initial_number_members () const; + + + + /** + * @@TODO DOC + */ void set_properties_dynamically ( const PortableGroup::Properties & overrides ACE_ENV_ARG_DECL) @@ -176,9 +183,15 @@ namespace TAO PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)); + /** + * @@TODO DOC + */ void get_properties (PortableGroup::Properties_var & result) const ACE_THROW_SPEC ((CORBA::SystemException)); + /** + * @@TODO DOC + */ PortableGroup::ObjectGroupId get_object_group_id () const; /** @@ -209,6 +222,9 @@ namespace TAO , PortableGroup::MemberNotFound )); + /** + * @@TODO DOC + */ void remove_member ( const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) @@ -216,6 +232,9 @@ namespace TAO PortableGroup::MemberNotFound)); + /** + * @@TODO DOC + */ void create_member ( const PortableGroup::Location & the_location, const char * type_id, @@ -228,17 +247,34 @@ namespace TAO PortableGroup::InvalidCriteria, PortableGroup::CannotMeetCriteria)); + /** + * @@TODO DOC + */ PortableGroup::Locations * locations_of_members (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)); + /** + * @@TODO DOC + */ CORBA::Object_ptr get_member_reference ( const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException, - PortableGroup::ObjectGroupNotFound, PortableGroup::MemberNotFound)); + + /** + * @@TODO DOC + */ + void initial_populate (ACE_ENV_SINGLE_ARG_DECL); + + /** + * @@TODO DOC + */ + void minimum_populate (ACE_ENV_SINGLE_ARG_DECL); + + ///////////////////////// // Implementation methods private: @@ -246,6 +282,13 @@ namespace TAO int increment_version (); void distribute_iogr (ACE_ENV_ARG_DECL); + void create_members (size_t count ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + PortableGroup::NoFactory + )); + + ///////////////////////// // Forbidden methods private: @@ -257,19 +300,7 @@ namespace TAO ///////////////// // Static Methods public: -#if 0 - /** - * Static creation method needed because exceptions can happen. - */ - static PG_Object_Group * create ( - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - CORBA::Object_ptr empty_group, // empty group as created by ObjectManager - const char * type_id, - const PortableGroup::Criteria & the_criteria, - TAO_PG::Properties_Decoder * type_properties - ACE_ENV_ARG_DECL); -#endif + /////////////// // Static Data private: @@ -286,6 +317,10 @@ namespace TAO CORBA::ORB_var orb_; + /// Where to find the factories for replicas. + PortableGroup::FactoryRegistry_var factory_registry_; + + // The object group manipulator TAO::PG_Object_Group_Manipulator & manipulator_; @@ -293,7 +328,7 @@ namespace TAO int empty_; ACE_CString role_; - PortableGroup::TypeId type_id_; + PortableGroup::TypeId_var type_id_; /** * the GroupTaggedComponent that defines this group @@ -326,7 +361,6 @@ namespace TAO // Cached property information - PortableGroup::MembershipStyleValue membership_style_; PortableGroup::InitialNumberMembersValue initial_number_members_; PortableGroup::MinimumNumberMembersValue minimum_number_members_; PortableGroup::FactoryInfos group_specific_factories_; |