diff options
author | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-12-01 23:03:20 +0000 |
---|---|---|
committer | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-12-01 23:03:20 +0000 |
commit | 4188f20303ce27f8c3a4d52a172027d5239a0e73 (patch) | |
tree | 916d66b22bf8f52f7e86c8b0db87fe29a95d6e11 | |
parent | 0c8df4451969e67d6a5dcf97984549268e1b48ad (diff) | |
download | ATCD-4188f20303ce27f8c3a4d52a172027d5239a0e73.tar.gz |
ChangeLogTag: Mon Dec 1 16:52:25 2003 Dale Wilson <wilson_d@ociweb.com>
-rw-r--r-- | TAO/ChangeLog | 17 | ||||
-rw-r--r-- | TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp | 4 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp | 35 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h | 7 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp | 188 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h | 9 |
6 files changed, 222 insertions, 38 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 159b1637eee..4a389fe4d9b 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,20 @@ +Mon Dec 1 16:52:25 2003 Dale Wilson <wilson_d@ociweb.com> + + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp: + Implement (by delegation) groups_at_location + + * orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp: + Implement groups_at_location + + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp: + New method: has_member_at to support groups_at_location. + New method: add_member_to_iogr refactor support for updating IOGR + Complete implementations of add_member, create_member, + and *populate methods. + + Mon Dec 1 15:24:27 2003 Dale Wilson <wilson_d@ociweb.com> * orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h: diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp index a18a67a074f..e0150deb73c 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp @@ -825,9 +825,7 @@ TAO::FT_ReplicationManager::groups_at_location ( ACE_ENV_ARG_DECL) ACE_THROW_SPEC ( (CORBA::SystemException)) { - TODO - ACE_UNUSED_ARG (the_location); - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + return this->group_factory_.groups_at_location (the_location ACE_ENV_ARG_PARAMETER); } PortableGroup::ObjectGroupId diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp index 7e91bc1d445..fb0b6ca62dd 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.cpp @@ -197,6 +197,41 @@ int TAO::PG_Group_Factory::destroy_group (PortableGroup::ObjectGroup_ptr object_ return destroy_group (tc.object_group_id); } + + +PortableGroup::ObjectGroups * +TAO::PG_Group_Factory::groups_at_location ( + const PortableGroup::Location & the_location + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ( (CORBA::SystemException)) +{ + size_t upper_limit = this->group_map_.current_size (); + PortableGroup::ObjectGroups * result = 0; + ACE_NEW_THROW_EX ( + result, + PortableGroup::ObjectGroups (upper_limit), + CORBA::NO_MEMORY()); + ACE_CHECK_RETURN (0); + + result->length(upper_limit); + + size_t group_count = 0; + for (Group_Map_Iterator it = this->group_map_.begin (); + it != this->group_map_.end (); + ++it) + { + TAO::PG_Object_Group * group = (*it).int_id_; + if (group->has_member_at (the_location)) + { + (*result)[group_count] = group->reference (); + ++group_count; + } + } + result->length (group_count); + return result; +} + + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Hash_Map_Manager_Ex< diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h index 8f4252783bb..f4990016e17 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Factory.h @@ -102,6 +102,13 @@ namespace TAO ACE_THROW_SPEC ((CORBA::SystemException, PortableGroup::ObjectNotFound)); + PortableGroup::ObjectGroups * + groups_at_location ( + const PortableGroup::Location & the_location + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ( (CORBA::SystemException)); + + /** * insert existing group. Take ownership diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp index ce2dde39017..90f871875a4 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp @@ -87,12 +87,12 @@ TAO::PG_Object_Group::~PG_Object_Group () { for (MemberMap_Iterator it = this->members_.begin(); it != this->members_.end(); - this->members_.begin()) + ++it) { MemberInfo * member = (*it).int_id_; delete member; - this->members_.unbind((*it).ext_id_); } + this->members_.unbind_all (); } #if 0 // may want this again someday @@ -132,33 +132,14 @@ const PortableGroup::Location & TAO::PG_Object_Group::get_primary_location() con return this->primary_location_; } -void TAO::PG_Object_Group::add_member ( - const PortableGroup::Location & the_location, - CORBA::Object_ptr member - ACE_ENV_ARG_PARAMETER) - ACE_THROW_SPEC ( (CORBA::SystemException, - PortableGroup::ObjectNotAdded)) +PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::add_member_to_iogr( + CORBA::Object_ptr member + ACE_ENV_ARG_DECL) { - InternalGuard guard(this->internals_); - - if (TAO_debug_level > 6) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("PG (%P|%t) enter Object_Group add_member \n") - )); - } - - ///////////////////////////////////////// - // Convert the new member to a string IOR - // This keeps a clean IOR (not and 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 ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + // assume internals is locked + PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil(); //////////////////////////// // @@ HACK ALERT // The PortableGroup::ObjectGroupManager creates an object reference containing @@ -173,7 +154,7 @@ void TAO::PG_Object_Group::add_member ( // remove the original profile. It's a dummy entry supplied by create_object. cleaned = this->manipulator_.remove_profiles (cleaned.in (), this->reference_.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); this->empty_ = 0; } @@ -184,10 +165,37 @@ void TAO::PG_Object_Group::add_member ( iors [1] = CORBA::Object::_duplicate (member); // Now merge the list into one new IOGR - PortableGroup::ObjectGroup_var new_reference = + result = this->manipulator_.merge_iors (iors ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil ()); + return result._retn (); +} + +void TAO::PG_Object_Group::add_member ( + const PortableGroup::Location & the_location, + CORBA::Object_ptr member + ACE_ENV_ARG_PARAMETER) + ACE_THROW_SPEC ( (CORBA::SystemException, + PortableGroup::ObjectNotAdded)) + +{ + InternalGuard guard(this->internals_); + + ///////////////////////////////////////// + // Convert the new member to a string IOR + // This keeps a clean IOR (not and 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 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + PortableGroup::ObjectGroup_var new_reference = add_member_to_iogr (member ACE_ENV_ARG_PARAMETER); ACE_CHECK; + + // Convert new member back to a (non group) ior. CORBA::Object_var member_ior = this->orb_->string_to_object (member_ior_string ACE_ENV_ARG_PARAMETER); ACE_CHECK; @@ -354,8 +362,7 @@ void TAO::PG_Object_Group::set_properties_dynamically ( { InternalGuard guard(this->internals_); this->properties_.decode (overrides ACE_ENV_ARG_PARAMETER); - //@@ int todo_parse_properties_for_special_value; - //@@ int todo_override_rather_than_replace_question; + //@@ int todo_override_rather_than_replace? } void TAO::PG_Object_Group::get_properties (PortableGroup::Properties_var & result ACE_ENV_ARG_DECL) const @@ -554,10 +561,81 @@ void TAO::PG_Object_Group::create_member ( { InternalGuard guard(this->internals_); -ACE_UNUSED_ARG (the_location); -ACE_UNUSED_ARG (type_id); -ACE_UNUSED_ARG (the_criteria); - TODO + 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 () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + 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) + { + 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() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + + // 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 ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + PortableGroup::ObjectGroup_var new_reference = this->add_member_to_iogr (member + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Convert new member back to a (non group) ior. + CORBA::Object_var member_ior = this->orb_->string_to_object (member_ior_string ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + MemberInfo * info = 0; + ACE_NEW_THROW_EX (info, MemberInfo( + member_ior.in(), + the_location, + factory_info.the_factory, + fcid.in ()), + CORBA::NO_MEMORY()); + ACE_CHECK; + + if (this->members_.bind (the_location, info) != 0) + { + ACE_THROW(CORBA::NO_MEMORY()); + } + + this->reference_ = new_reference; // note var-to-var assignment does a duplicate + if (this->increment_version ()) + { + this->distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + created = 1; + } + } + if (! created) + { + ACE_THROW (PortableGroup::NoFactory ()); + } + } + else + { + ACE_THROW (PortableGroup::MemberAlreadyPresent ()); + } + } void TAO::PG_Object_Group::create_members (size_t count ACE_ENV_ARG_DECL) @@ -593,12 +671,39 @@ void TAO::PG_Object_Group::create_members (size_t count ACE_ENV_ARG_DECL) ACE_TRY_NEW_ENV { PortableGroup::GenericFactory::FactoryCreationId_var fcid; - factory_info.the_factory->create_object ( + CORBA::Object_var member = factory_info.the_factory->create_object ( this->type_id_.in (), factory_info.the_criteria, fcid. out() ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; + + // 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 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableGroup::ObjectGroup_var new_reference = this->add_member_to_iogr (member + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Convert new member back to a (non group) ior. + CORBA::Object_var member_ior = this->orb_->string_to_object (member_ior_string ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + MemberInfo * info = 0; + ACE_NEW_THROW_EX (info, MemberInfo( + member_ior.in(), + factory_location, + factory_info.the_factory, + fcid.in ()), + CORBA::NO_MEMORY()); + ACE_TRY_CHECK; + + if (this->members_.bind (factory_location, info) != 0) + { + ACE_TRY_THROW(CORBA::NO_MEMORY()); + } + this->reference_ = new_reference; // note var-to-var assignment does a duplicate } ACE_CATCHANY { @@ -615,6 +720,12 @@ void TAO::PG_Object_Group::create_members (size_t count ACE_ENV_ARG_DECL) ACE_ENDTRY; } } + + if (this->increment_version ()) + { + this->distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } } else { @@ -648,6 +759,13 @@ void TAO::PG_Object_Group::minimum_populate (ACE_ENV_SINGLE_ARG_DECL) } } +int TAO::PG_Object_Group::has_member_at (const PortableGroup::Location & location ) +{ + return (0 == this->members_.find (location)); +} + + + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h index 0d84beed4be..31f8c2afa22 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h @@ -275,13 +275,22 @@ namespace TAO void minimum_populate (ACE_ENV_SINGLE_ARG_DECL); + /** + * @@TODO DOC + */ + int has_member_at (const PortableGroup::Location & location ); + ///////////////////////// // Implementation methods private: int increment_version (); + void distribute_iogr (ACE_ENV_ARG_DECL); + PortableGroup::ObjectGroup_ptr add_member_to_iogr(CORBA::Object_ptr member ACE_ENV_ARG_DECL); + + void create_members (size_t count ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( CORBA::SystemException, |