From 1c89c484296eb4e5ddde09ca0588cc415719c1dd Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Fri, 4 May 2001 20:02:47 +0000 Subject: Minor updates. --- TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.cpp | 4 +- TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.inl | 2 + TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h | 82 +++--- TAO/orbsvcs/orbsvcs/LB_Replica_Hash.inl | 2 +- TAO/orbsvcs/orbsvcs/LoadBalancing.idl | 90 ++++--- .../orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.cpp | 4 +- .../orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.inl | 2 + .../orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h | 82 +++--- .../orbsvcs/LoadBalancing/LB_Replica_Hash.inl | 2 +- .../orbsvcs/LoadBalancing/LoadBalancingI.cpp | 81 ++++-- TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.h | 289 +++++++++++++-------- .../orbsvcs/LoadBalancing/ObjectGroupManager.cpp | 7 +- .../orbsvcs/LoadBalancing/ReplicaLocator.cpp | 4 +- TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp | 81 ++++-- TAO/orbsvcs/orbsvcs/LoadBalancingI.h | 289 +++++++++++++-------- TAO/orbsvcs/orbsvcs/ObjectGroupManager.cpp | 7 +- TAO/orbsvcs/orbsvcs/ReplicaLocator.cpp | 4 +- .../tests/LoadBalancing/HashReplicaFactory.cpp | 8 +- TAO/orbsvcs/tests/LoadBalancing/server.cpp | 4 +- 19 files changed, 627 insertions(+), 417 deletions(-) diff --git a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.cpp b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.cpp index 594e3bb1380..e62af63bce6 100644 --- a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.cpp +++ b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.cpp @@ -6,4 +6,6 @@ #include "LB_Hash.inl" #endif /* __ACE_INLINE__ */ -ACE_RCSID (TAO_LoadBalancing, LB_Hash, "$Id$") +ACE_RCSID (TAO_LoadBalancing, + LB_Hash, + "$Id$") diff --git a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.inl b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.inl index 8bf5490a545..fe12be1ad3f 100644 --- a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.inl +++ b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Hash.inl @@ -10,6 +10,8 @@ TAO_LB_ObjectGroup_Hash::operator() ( return object_group->_hash (max); } +// ------------------------------------------------------------------- + ACE_INLINE CORBA::ULong TAO_LB_FactoryCreationId_Hash::operator() ( const TAO_LoadBalancing::FactoryCreationId &factory_creation_id) const diff --git a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h index 52817547c36..bc276fb0567 100644 --- a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h +++ b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h @@ -1,19 +1,15 @@ // -*- C++ -*- -// -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// LB_ObjectGroup_Map.h -// -// = AUTHOR -// Ossama Othman -// -// ============================================================================ + +//======================================================================= +/** + * @file LB_ObjectGroup_Map.h + * + * $Id$ + * + * @author Ossama Othman + */ +//======================================================================= + #ifndef TAO_LB_OBJECTGROUP_MAP_H #define TAO_LB_OBJECTGROUP_MAP_H @@ -32,69 +28,71 @@ #include "LB_ObjectGroup_Equal_To.h" #include "orbsvcs/LoadBalancingC.h" +/** + * @class TAO_LB_ObjectGroup_Map + * + * @brief Map of RepositoryId to ObjectGroup reference, + * FactoryCreationId, replicas belonging to the ObjectGroup and + * corresponding replica-specific information. + * + * Implementation to be used by the Load Balancer ReplicationManager. + */ class TAO_LB_ObjectGroup_Map { - // = TITLE - // Map of RepositoryId to ObjectGroup reference, - // FactoryCreationId, replicas belonging to the ObjectGroup and - // corresponding replica-specific information. - // - // = DESCRIPTION - // Implementation to be used by the Load Balancer - // ReplicationManager. public: + /** + * @class Map_Entry + * + * @brief Value field of the replica map. + * + * Mapping from and to all of the following fields: + * @param object_group, @param factory_creation_id, @param factory, + * and @param factory_creation_id. Therefore, we keep all the + * fields together in the map. + */ struct Map_Entry { - // = TITLE - // Value field of the replica map. - // - // = DESCRIPTION - // Mapping from and to all of the following fields: - // , , , and - // . Therefore, we keep all the fields - // together in the map. - + /// The RepositoryId corresponding to all Replicas in the + /// ObjectGroup. CORBA::String_var type_id; - // The RepositoryId corresponding to all Replicas in the - // ObjectGroup. + /// Reference to the ObjectGroup. TAO_LoadBalancing::ObjectGroup_var object_group; - // Reference to the ObjectGroup. + /// The FactoryCreationId corresponding to the ObjectGroup created + /// by the Load Balancer GenericFactory. TAO_LoadBalancing::FactoryCreationId factory_creation_id; - // The FactoryCreationId corresponding to the ObjectGroup created by - // the Load Balancer GenericFactory. + /// Hash map containing replica references and all related + /// information for each replica. TAO_LB_Replica_Map replica_map; - // Hash map containing replica references and all related - // information for each replica. }; + /// type_id hash map. typedef ACE_Hash_Map_Manager_Ex< const char *, Map_Entry *, ACE_Hash, ACE_Equal_To, ACE_SYNCH_MUTEX> type_id_map; - // type_id hash map. + /// ObjectGroup hash map. typedef ACE_Hash_Map_Manager_Ex< TAO_LoadBalancing::ObjectGroup_ptr, Map_Entry *, TAO_LB_ObjectGroup_Hash, TAO_LB_ObjectGroup_Equal_To, ACE_SYNCH_MUTEX> ObjectGroup_map; - // ObjectGroup hash map. + /// FactoryCreationId hash map. typedef ACE_Hash_Map_Manager_Ex< TAO_LoadBalancing::FactoryCreationId, Map_Entry *, TAO_LB_FactoryCreationId_Hash, TAO_LB_FactoryCreationId_Equal_To, ACE_SYNCH_MUTEX> FactoryCreationId_map; - // FactoryCreationId hash map. int bind (const char *type_id, TAO_LoadBalancing::ObjectGroup_ptr object_group, diff --git a/TAO/orbsvcs/orbsvcs/LB_Replica_Hash.inl b/TAO/orbsvcs/orbsvcs/LB_Replica_Hash.inl index dedec714bf5..450a9797e48 100644 --- a/TAO/orbsvcs/orbsvcs/LB_Replica_Hash.inl +++ b/TAO/orbsvcs/orbsvcs/LB_Replica_Hash.inl @@ -19,7 +19,7 @@ TAO_LB_Location_Hash::operator() ( size_t location_length = location.length (); for (size_t i = 0; i < location_length; ++i) - hash += (ACE::hash_pjw (location[i].id) + hash += (ACE::hash_pjw (location[i].id) + ACE::hash_pjw (location[i].kind)); return hash; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing.idl b/TAO/orbsvcs/orbsvcs/LoadBalancing.idl index 327730d2a8d..2c74fb71e7f 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing.idl +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing.idl @@ -1,18 +1,15 @@ -// -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// LoadBalancing.idl -// -// = AUTHOR -// Ossama Othman -// -// ============================================================================ +// -*- IDL -*- + +//============================================================================= +/** + * @file LoadBalancing.idl + * + * $Id$ + * + * @author Ossama Othman + */ +//============================================================================= + #ifndef TAO_LOADBALANCING_IDL #define TAO_LOADBALANCING_IDL @@ -20,24 +17,35 @@ #include "CosNaming.idl" #include "orb.idl" -module TAO_LoadBalancing +#pragma prefix "tao.lb" + +/** + * @class LoadBalancing + * + * @brief This module defines the interfaces and data types used in + * TAO's Load Balancing service. + * @par + * TAO's Load Balancer manages distribution of requests to replicas of + * a given Object in an effort to ensure that the applications/hosts + * pointed to by the Object reference are as equally loaded as + * possible, i.e. load balanced. + * @par + * The definition of 'load' is application specific, for example, some + * applications may choose to load balance access to multiple + * dedicated lines, or separate network interfaces, as well as more + * traditional load balancing metrics, such as CPU or power load. + */ +module LoadBalancing { - // = TITLE - // This module defines the interfaces and data types used in TAO's - // Load Balancing service. - - // = DESCRIPTION - // TAO's Load Balancer manages distribution of requests to - // replicas of a given Object in an effort to ensure that the - // applications/hosts pointed to by the Object reference are as - // equally loaded as possible, i.e. load balanced. - // The definition of 'load' is application specific, for - // example, some applications may choose to load balance access - // to multiple dedicated lines, or separate network interfaces, - // as well as more traditional load balancing metrics, such as - // CPU or power load. - - // Specification of Common Types and Exceptions for ReplicationManager + /// Types used for obtaining and/or reporting loads + typedef unsigned long LoadId; + struct Load { + LoadId identifier; + float value; + }; + typedef sequence LoadList; + + /// Specification of Common Types and Exceptions for ReplicationManager interface GenericFactory; interface LoadNotifier; @@ -94,8 +102,8 @@ module TAO_LoadBalancing Criteria unmet_criteria; }; - // Specification of PropertyManager Interface - // which ReplicationManager Inherits + /// Specification of PropertyManager Interface which + /// ReplicationManager Inherits interface PropertyManager { void set_default_properties (in Properties props) raises (InvalidProperty, @@ -129,8 +137,8 @@ module TAO_LoadBalancing raises (ObjectGroupNotFound); }; - // Specification of ObjectGroupManager Interface - // which ReplicationManager Inherits + /// Specification of ObjectGroupManager Interface which + /// ReplicationManager Inherits interface ObjectGroupManager { ObjectGroup create_member (in ObjectGroup object_group, in Location the_location, @@ -178,8 +186,8 @@ module TAO_LoadBalancing MemberNotFound); }; - // Specification of GenericFactory Interface - // which ReplicationManager Inherits and Application Objects Implement + /// Specification of GenericFactory Interface which + /// ReplicationManager Inherits and Application Objects Implement interface GenericFactory { typedef any FactoryCreationId; @@ -196,7 +204,7 @@ module TAO_LoadBalancing raises (ObjectNotFound); }; - // Specification of ReplicationManager Interface + /// Specification of ReplicationManager Interface interface ReplicationManager : PropertyManager, ObjectGroupManager, GenericFactory { void register_load_notifier (in LoadNotifier load_notifier); @@ -206,4 +214,6 @@ module TAO_LoadBalancing }; }; -#endif /* TAO_LOADBALANCER_IDL */ +#pragma prefix "" + +#endif /* TAO_LOADBALANCING_IDL */ diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.cpp index 594e3bb1380..e62af63bce6 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.cpp @@ -6,4 +6,6 @@ #include "LB_Hash.inl" #endif /* __ACE_INLINE__ */ -ACE_RCSID (TAO_LoadBalancing, LB_Hash, "$Id$") +ACE_RCSID (TAO_LoadBalancing, + LB_Hash, + "$Id$") diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.inl b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.inl index 8bf5490a545..fe12be1ad3f 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.inl +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Hash.inl @@ -10,6 +10,8 @@ TAO_LB_ObjectGroup_Hash::operator() ( return object_group->_hash (max); } +// ------------------------------------------------------------------- + ACE_INLINE CORBA::ULong TAO_LB_FactoryCreationId_Hash::operator() ( const TAO_LoadBalancing::FactoryCreationId &factory_creation_id) const diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h index 52817547c36..bc276fb0567 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h @@ -1,19 +1,15 @@ // -*- C++ -*- -// -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO_LoadBalancing -// -// = FILENAME -// LB_ObjectGroup_Map.h -// -// = AUTHOR -// Ossama Othman -// -// ============================================================================ + +//======================================================================= +/** + * @file LB_ObjectGroup_Map.h + * + * $Id$ + * + * @author Ossama Othman + */ +//======================================================================= + #ifndef TAO_LB_OBJECTGROUP_MAP_H #define TAO_LB_OBJECTGROUP_MAP_H @@ -32,69 +28,71 @@ #include "LB_ObjectGroup_Equal_To.h" #include "orbsvcs/LoadBalancingC.h" +/** + * @class TAO_LB_ObjectGroup_Map + * + * @brief Map of RepositoryId to ObjectGroup reference, + * FactoryCreationId, replicas belonging to the ObjectGroup and + * corresponding replica-specific information. + * + * Implementation to be used by the Load Balancer ReplicationManager. + */ class TAO_LB_ObjectGroup_Map { - // = TITLE - // Map of RepositoryId to ObjectGroup reference, - // FactoryCreationId, replicas belonging to the ObjectGroup and - // corresponding replica-specific information. - // - // = DESCRIPTION - // Implementation to be used by the Load Balancer - // ReplicationManager. public: + /** + * @class Map_Entry + * + * @brief Value field of the replica map. + * + * Mapping from and to all of the following fields: + * @param object_group, @param factory_creation_id, @param factory, + * and @param factory_creation_id. Therefore, we keep all the + * fields together in the map. + */ struct Map_Entry { - // = TITLE - // Value field of the replica map. - // - // = DESCRIPTION - // Mapping from and to all of the following fields: - // , , , and - // . Therefore, we keep all the fields - // together in the map. - + /// The RepositoryId corresponding to all Replicas in the + /// ObjectGroup. CORBA::String_var type_id; - // The RepositoryId corresponding to all Replicas in the - // ObjectGroup. + /// Reference to the ObjectGroup. TAO_LoadBalancing::ObjectGroup_var object_group; - // Reference to the ObjectGroup. + /// The FactoryCreationId corresponding to the ObjectGroup created + /// by the Load Balancer GenericFactory. TAO_LoadBalancing::FactoryCreationId factory_creation_id; - // The FactoryCreationId corresponding to the ObjectGroup created by - // the Load Balancer GenericFactory. + /// Hash map containing replica references and all related + /// information for each replica. TAO_LB_Replica_Map replica_map; - // Hash map containing replica references and all related - // information for each replica. }; + /// type_id hash map. typedef ACE_Hash_Map_Manager_Ex< const char *, Map_Entry *, ACE_Hash, ACE_Equal_To, ACE_SYNCH_MUTEX> type_id_map; - // type_id hash map. + /// ObjectGroup hash map. typedef ACE_Hash_Map_Manager_Ex< TAO_LoadBalancing::ObjectGroup_ptr, Map_Entry *, TAO_LB_ObjectGroup_Hash, TAO_LB_ObjectGroup_Equal_To, ACE_SYNCH_MUTEX> ObjectGroup_map; - // ObjectGroup hash map. + /// FactoryCreationId hash map. typedef ACE_Hash_Map_Manager_Ex< TAO_LoadBalancing::FactoryCreationId, Map_Entry *, TAO_LB_FactoryCreationId_Hash, TAO_LB_FactoryCreationId_Equal_To, ACE_SYNCH_MUTEX> FactoryCreationId_map; - // FactoryCreationId hash map. int bind (const char *type_id, TAO_LoadBalancing::ObjectGroup_ptr object_group, diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Replica_Hash.inl b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Replica_Hash.inl index dedec714bf5..450a9797e48 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Replica_Hash.inl +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_Replica_Hash.inl @@ -19,7 +19,7 @@ TAO_LB_Location_Hash::operator() ( size_t location_length = location.length (); for (size_t i = 0; i < location_length; ++i) - hash += (ACE::hash_pjw (location[i].id) + hash += (ACE::hash_pjw (location[i].id) + ACE::hash_pjw (location[i].kind)); return hash; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp index 14ba8a32ae4..f8500c09cf2 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp @@ -4,6 +4,11 @@ #include "LoadBalancingI.h" +ACE_RCSID (LoadBalancing, + LoadBalancingI, + "$Id$") + + // Implementation skeleton constructor TAO_LoadBalancing_ReplicationManager_i::TAO_LoadBalancing_ReplicationManager_i (void) @@ -22,14 +27,16 @@ TAO_LoadBalancing_ReplicationManager_i::~TAO_LoadBalancing_ReplicationManager_i void TAO_LoadBalancing_ReplicationManager_i::register_load_notifier ( - TAO_LoadBalancing::LoadNotifier_ptr /* load_notifier */) + TAO_LoadBalancing::LoadNotifier_ptr /* load_notifier */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW (CORBA::NO_IMPLEMENT()); } TAO_LoadBalancing::LoadNotifier_ptr -TAO_LoadBalancing_ReplicationManager_i::get_load_notifier (void) +TAO_LoadBalancing_ReplicationManager_i::get_load_notifier ( + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InterfaceNotFound)) { @@ -38,7 +45,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_load_notifier (void) void TAO_LoadBalancing_ReplicationManager_i::set_default_properties ( - const TAO_LoadBalancing::Properties & /* props */) + const TAO_LoadBalancing::Properties & /* props */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -47,7 +55,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_default_properties ( } TAO_LoadBalancing::Properties * -TAO_LoadBalancing_ReplicationManager_i::get_default_properties (void) +TAO_LoadBalancing_ReplicationManager_i::get_default_properties ( + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW (CORBA::NO_IMPLEMENT ()); @@ -55,7 +64,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_default_properties (void) void TAO_LoadBalancing_ReplicationManager_i::remove_default_properties ( - const TAO_LoadBalancing::Properties & /* props */) + const TAO_LoadBalancing::Properties & /* props */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -66,7 +76,8 @@ TAO_LoadBalancing_ReplicationManager_i::remove_default_properties ( void TAO_LoadBalancing_ReplicationManager_i::set_type_properties ( const char * /* type_id */, - const TAO_LoadBalancing::Properties & /* overrides */) + const TAO_LoadBalancing::Properties & /* overrides */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -76,7 +87,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_type_properties ( TAO_LoadBalancing::Properties * TAO_LoadBalancing_ReplicationManager_i::get_type_properties ( - const char * /* type_id */) + const char * /* type_id */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW (CORBA::NO_IMPLEMENT ()); @@ -85,7 +97,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_type_properties ( void TAO_LoadBalancing_ReplicationManager_i::remove_type_properties ( const char * /* type_id */, - const TAO_LoadBalancing::Properties & /* props */) + const TAO_LoadBalancing::Properties & /* props */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -96,7 +109,8 @@ TAO_LoadBalancing_ReplicationManager_i::remove_type_properties ( void TAO_LoadBalancing_ReplicationManager_i::set_properties_dynamically ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Properties & /* overrides */) + const TAO_LoadBalancing::Properties & /* overrides */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::InvalidProperty, @@ -107,7 +121,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_properties_dynamically ( TAO_LoadBalancing::Properties * TAO_LoadBalancing_ReplicationManager_i::get_properties ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -119,7 +134,8 @@ TAO_LoadBalancing_ReplicationManager_i::create_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, const TAO_LoadBalancing::Location & /* the_location */, const char * /* type_id */, - const TAO_LoadBalancing::Criteria & /* the_criteria */) + const TAO_LoadBalancing::Criteria & /* the_criteria */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, @@ -135,7 +151,8 @@ TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::add_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, const TAO_LoadBalancing::Location & /* the_location */, - CORBA::Object_ptr /* member */) + CORBA::Object_ptr /* member */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, @@ -147,7 +164,8 @@ TAO_LoadBalancing_ReplicationManager_i::add_member ( TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::remove_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Location & /* the_location */) + const TAO_LoadBalancing::Location & /* the_location */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound)) @@ -158,7 +176,8 @@ TAO_LoadBalancing_ReplicationManager_i::remove_member ( TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::set_primary_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Location & /* the_location */) + const TAO_LoadBalancing::Location & /* the_location */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound, @@ -170,7 +189,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_primary_member ( TAO_LoadBalancing::Locations * TAO_LoadBalancing_ReplicationManager_i::locations_of_members ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -179,7 +199,8 @@ TAO_LoadBalancing_ReplicationManager_i::locations_of_members ( TAO_LoadBalancing::ObjectGroupId TAO_LoadBalancing_ReplicationManager_i::get_object_group_id ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -188,7 +209,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_object_group_id ( TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::get_object_group_ref ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -198,7 +220,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_object_group_ref ( CORBA::Object_ptr TAO_LoadBalancing_ReplicationManager_i::get_member_ref ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Location & loc) + const TAO_LoadBalancing::Location & loc, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound)) @@ -251,7 +274,7 @@ TAO_LoadBalancing_ReplicationManager_i::create_object ( } // Obtain the FactoryInfos from the_criteria. This method also - // ensure that GenericFactories at different locations are used. + // ensures that GenericFactories at different locations are used. else if (this->get_factory_infos (type_id, the_criteria[i], factory_infos) == 0) @@ -323,7 +346,7 @@ TAO_LoadBalancing_ReplicationManager_i::create_object_i ( // FactoryInfo with a "Location" member that matches // the location at which to create the desired // replica. - // @@ It is also used to ensure the only one replica of + // @@ It is also used to ensure that only one replica of // a given type is created at a given location. @@ -392,8 +415,16 @@ TAO_LoadBalancing_ReplicationManager_i::create_object_i ( replica_entry->factory_creation_id = replica_factory_creation_id; if (object_group_entry.replica_map.bind (replica_entry) != 0) - ACE_THROW_RETURN (TAO_LoadBalancer::ObjectNotCreated (), - CORBA::Object::_nil ()); + { + // An Object of incorrect type was created. Delete it, and + // throw a NoFactory exception. + factory->delete_object (replica_factory_creation_id, + ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + ACE_THROW_RETURN (TAO_LoadBalancer::ObjectNotCreated (), + CORBA::Object::_nil ()); + } // No longer need to protect the allocated Replica_Map. safe_replica_entry.release (); @@ -443,7 +474,9 @@ TAO_LoadBalancing_ReplicationManager_i::get_factory_infos () void TAO_LoadBalancing_ReplicationManager_i::delete_object ( - const TAO_LoadBalancing::GenericFactory::FactoryCreationId & factory_creation_id) + const TAO_LoadBalancing::GenericFactory::FactoryCreationId & + factory_creation_id, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectNotFound)) { @@ -578,7 +611,7 @@ TAO_LoadBalancing_ReplicationManager_i::operator= ( TAO_LoadBalancing::FactoryInfo &lhs, const TAO_LoadBalancing::FactoryInfo &rhs) { - lhs.facgtory = + lhs.factory = TAO_LoadBalancing::GenericFactory::_duplicate (rhs.factory); lhs.the_location = rhs.the_location; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.h index 8d3d4a8a47e..37f1ea7462a 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.h @@ -1,6 +1,15 @@ // -*- C++ -*- -// -// $Id$ + +//============================================================================= +/** + * @file ReplicaLocator.h + * + * $Id$ + * + * @author Ossama Othman + */ +//============================================================================= + #ifndef TAO_LOADBALANCINGI_H #define TAO_LOADBALANCINGI_H @@ -16,99 +25,128 @@ #include "orbsvcs/LoadBalancingS.h" #include "LB_ObjectGroup_Map.h" -class TAO_LoadBalancing_ReplicationManager_i : - public virtual POA_TAO_LoadBalancing::ReplicationManager +class TAO_LoadBalancing_ReplicationManager_i + : public virtual POA_TAO_LoadBalancing::ReplicationManager { public: + /// Constructor. TAO_LoadBalancing_ReplicationManager_i (void); - - virtual ~TAO_LoadBalancing_ReplicationManager_i (void); + /// Destructor. + ~TAO_LoadBalancing_ReplicationManager_i (void); + + /// Register a load notifier with the load balancer + /// ReplicationManager. virtual void register_load_notifier ( - TAO_LoadBalancing::LoadNotifier_ptr load_notifier) + TAO_LoadBalancing::LoadNotifier_ptr load_notifier, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); - // Register a load notifier with the load balancer - // ReplicationManager. - virtual TAO_LoadBalancing::LoadNotifier_ptr get_load_notifier (void) + /// Return a reference to the load notifier in use. + virtual TAO_LoadBalancing::LoadNotifier_ptr get_load_notifier ( + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InterfaceNotFound)); - // Return a reference to the load notifier in use. - // = TAO_LoadBalancer::PropertyManager methods + /** + * @name TAO_LoadBalancer::PropertyManager methods + */ + //@{ + /// Set the default properties to be used by all object groups. virtual void set_default_properties ( - const TAO_LoadBalancing::Properties & props) + const TAO_LoadBalancing::Properties & props, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Set the default properties to be used by all object groups. - virtual TAO_LoadBalancing::Properties * get_default_properties (void) + /// Get the default properties used by all object groups. + virtual TAO_LoadBalancing::Properties * get_default_properties ( + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); - // Get the default properties used by all object groups. + /// Remove default properties. virtual void remove_default_properties ( - const TAO_LoadBalancing::Properties & props) + const TAO_LoadBalancing::Properties & props, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Remove default properties. + /// Set properties associated with a given Replica type. These + /// properties override the default properties. virtual void set_type_properties ( - const char * type_id, - const TAO_LoadBalancing::Properties & overrides) + const char * type_id, + const TAO_LoadBalancing::Properties & overrides, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Set properties associated with a given Replica type. These - // properties override the default properties. + /** + * Return the properties associated with a give Replica type. These + * properties include the type-specific properties in use, in + * addition to the default properties that were not overridden. + */ virtual TAO_LoadBalancing::Properties * get_type_properties ( - const char * type_id) + const char * type_id, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); - // Return the properties associated with a give Replica type. These - // properties include the type-specific properties in use, in - // addition to the default properties that were not overridden. + /// Remove the given properties associated with the Replica type ID. virtual void remove_type_properties ( - const char * type_id, - const TAO_LoadBalancing::Properties & props) + const char * type_id, + const TAO_LoadBalancing::Properties & props, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Remove the given properties associated with the Replica type ID. + /** + * Dynamically set the properties associated with a given object + * group as the load balancer and replicas are being executed. + * These properties override the type-specific and default + * properties. + */ virtual void set_properties_dynamically ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Properties & overrides) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Properties & overrides, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Dynamically set the properties associated with a given object - // group as the load balancer and replicas are being executed. - // These properties override the type-specific and default - // properties. + /** + * Return the properties currently in use by the given object + * group. These properties include those that were set dynamically, + * type-specific properties that weren't overridden, properties that + * were used when the Replica was created, and default properties + * that weren't overridden. + */ virtual TAO_LoadBalancing::Properties * get_properties ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // Return the properties currently in use by the given object - // group. These properties include those that were set dynamically, - // type-specific properties that weren't overridden, properties that - // were used when the Replica was created, and default properties - // that weren't overridden. - // = TAO_LoadBalancer::ObjectGroupManager methods + //@} + + /** + * @name TAO_LoadBalancer::ObjectGroupManager methods + */ + //@{ + /// Create a member using the load balancer ObjectGroupManager, and + /// add the created object to the ObjectGroup. virtual TAO_LoadBalancing::ObjectGroup_ptr create_member ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & the_location, - const char * type_id, - const TAO_LoadBalancing::Criteria & the_criteria) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & the_location, + const char * type_id, + const TAO_LoadBalancing::Criteria & the_criteria, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, @@ -116,88 +154,108 @@ public: TAO_LoadBalancing::ObjectNotCreated, TAO_LoadBalancing::InvalidCriteria, TAO_LoadBalancing::CannotMeetCriteria)); - // Create a member using the load balancer ObjectGroupManager, and - // add the created object to the ObjectGroup. + /// Add an existing object to the ObjectGroup. virtual TAO_LoadBalancing::ObjectGroup_ptr add_member ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & the_location, - CORBA::Object_ptr member) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & the_location, + CORBA::Object_ptr member, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, TAO_LoadBalancing::ObjectNotAdded)); - // Add an existing object to the ObjectGroup. + /** + * Remove an object at a specific location from the given + * ObjectGroup. Deletion of application created objects must be + * deleted by the application. Objects created by the + * infrastructure (load balancer) will be deleted by the + * infrastructure. + */ virtual TAO_LoadBalancing::ObjectGroup_ptr remove_member ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & the_location) - ACE_THROW_SPEC ((CORBA::SystemException, - TAO_LoadBalancing::ObjectGroupNotFound, - TAO_LoadBalancing::MemberNotFound)); - // Remove an object at a specific location from the given - // ObjectGroup. Deletion of application created objects must be - // deleted by the application. Objects created by the - // infrastructure (load balancer) will be deleted by the - // infrastructure. + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & the_location, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + TAO_LoadBalancing::ObjectGroupNotFound, + TAO_LoadBalancing::MemberNotFound)); + /// Return the locations of the members in the given ObjectGroup. virtual TAO_LoadBalancing::Locations * locations_of_members ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // Return the locations of the members in the given ObjectGroup. + /// Return the ObjectGroupId for the given ObjectGroup. virtual TAO_LoadBalancing::ObjectGroupId get_object_group_id ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // Return the ObjectGroupId for the given ObjectGroup. + /// @note Does this method make sense for load balanced objects? virtual TAO_LoadBalancing::ObjectGroup_ptr get_object_group_ref ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // @@ Does this method make sense for load balanced objects? + /// Return the reference corresponding to the Replica of a given + /// ObjectGroup at the given location. virtual CORBA::Object_ptr get_member_ref ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & loc) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & loc, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound)); - // Return the reference corresponding to the Replica of a given - // ObjectGroup at the given location. - // = TAO_LoadBalancer::GenericFactory methods + //@} + /** + * @name TAO_LoadBalancer::GenericFactory methods + */ + //@{ + + /** + * Create an object of the specified type that adheres to the + * restrictions defined by the provided Criteria. The out + * FactoryCreationId parameter may be passed to the delete_object() + * method to delete the object. + */ virtual CORBA::Object_ptr create_object ( - const char * type_id, - const TAO_LoadBalancing::Criteria & the_criteria, - TAO_LoadBalancing::GenericFactory::FactoryCreationId_out - factory_creation_id) + const char * type_id, + const TAO_LoadBalancing::Criteria & the_criteria, + TAO_LoadBalancing::GenericFactory::FactoryCreationId_out + factory_creation_id, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::NoFactory, TAO_LoadBalancing::ObjectNotCreated, TAO_LoadBalancing::InvalidCriteria, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::CannotMeetCriteria)); - // Create an object of the specified type that adheres to the - // restrictions defined by the provided Criteria. The out - // FactoryCreationId parameter may be passed to the delete_object() - // method to delete the object. + /** + * Delete the object corresponding to the provided + * FactoryCreationId. If the object is actually an ObjectGroup, + * then all members within the ObjectGroup will be deleted. + * Afterward, the ObjectGroup itself will be deleted. + */ virtual void delete_object ( - const TAO_LoadBalancing::GenericFactory::FactoryCreationId & - factory_creation_id) + const TAO_LoadBalancing::GenericFactory::FactoryCreationId & + factory_creation_id, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectNotFound)); - // Delete the object corresponding to the provided - // FactoryCreationId. If the object is actually an ObjectGroup, - // then all members within the ObjectGroup will be deleted. - // Afterward, the ObjectGroup itself will be deleted. + + //@} private: + /// Helper method that creates replicas of the given type. void create_object_i ( const char * type_id, CORBA::UShort initial_number_replicas, @@ -209,62 +267,67 @@ private: TAO_LoadBalancing::InvalidCriteria, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::CannotMeetCriteria)); - // Helper method that creates replicas of the given type. + /// Extract the value of the InitialNumberReplicas property from + /// the_criteria. int get_initial_number_replicas ( const char *type_id, const TAO_LoadBalancing::Criteria &the_criteria, CORBA::UShort &initial_number_replicas) const; - // Extract the value of the InitialNumberReplicas property from - // the_criteria. + /** + * Extract the value of the Factories property from the_criteria. + * This method ensures that the locations in the returned + * FactoryInfos are unique. This is necessary to ensure that only + * one replica of a given type is created by the load balancer at a + * given location. + */ int get_factory_infos ( const char *type_id, const TAO_LoadBalancing::Criteria &the_criteria, TAO_LoadBalancing::FactoryInfos &factory_infos) const; - // Extract the value of the Factories property from the_criteria. - // This method ensures that the locations in the returned - // FactoryInfos are unique. This is necessary to ensure that only - // one replica of a given type is created by the load balancer at a - // given location. + /// Create a POA with the appropriate policies to support + /// ServantLocators (i.e. the ReplicaLocator). int init (PortableServer::POA_ptr root_poa); - // Create a POA with the appropriate policies to support - // ServantLocators (i.e. the ReplicaLocator). + /** + * Get a new ObjectId to be used when creating a new ObjectGroup. + * An ObjectId created by this method will never be reused within + * the scope of a given ReplicationManager. A value suitable for + * use in a map association is also returned. + */ void get_ObjectId (PortableServer::ObjectId &oid, TAO_LB_ObjectGroup_EXT_ID &ext_id); - // Get a new ObjectId to be used when creating a new ObjectGroup. - // An ObjectId created by this method will never be reused within - // the scope of a given ReplicationManager. A value suitable for - // use in a map association is also returned. + /// Assignment operator for TAO_LoadBalancer::FactoryInfo instances. void operator= (TAO_LoadBalancer::FactoryInfo &lhs, const TAO_LoadBalancer::FactoryInfo &rhs); - // Assignment operator for TAO_LoadBalancer::FactoryInfo instances. private: + /// The object that tells the invoking client to forward its requests + /// from the LoadBalancer to an actual replica. TAO_LB_ReplicaLocator locator_; - // The object that tells the invoking client to forward its requests - // from the LoadBalancer to an actual replica. + /// The POA that dispatches requests to the ReplicaLocator. PortableServer::POA_var poa_; - // The POA that dispatches requests to the ReplicaLocator. + /// ObjectId to be used for the next ObjectGroup that is created. CORBA::ULong next_oid_; - // ObjectId to be used for the next ObjectGroup that is created. + /// Map between RepositoryId, ObjectGroup reference, replica list and + /// factory creation ID. TAO_LB_ObjectGroup_Map object_group_map_; - // Map between RepositoryId, ObjectGroup reference, replica list and - // factory creation ID. + /** + * Value that is used when assigning a FactoryCreationId to the + * factory that was used to create a given ObjectGroup. The + * FactoryCreationId is typically comprised of this value in + * addition to another value that makes it unique to a given Load + * Balancer. + */ CORBA::ULong next_factory_num_; - // Value that is used when assigning a FactoryCreationId to the - // factory that was used to create a given ObjectGroup. The - // FactoryCreationId is typically comprised of this value in - // addition to another value that makes it unique to a given Load - // Balancer. }; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/ObjectGroupManager.cpp index 52daa7176ca..e2e9ce3f6c9 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ObjectGroupManager.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/ObjectGroupManager.cpp @@ -1,8 +1,11 @@ // -*- C++ -*- -// $Id$ +#include "ObjectGroupManager.h" -ACE_RCSID(orbsvcs, ObjectGroupManager, "$Id$") + +ACE_RCSID (LoadBalancing, + ObjectGroupManager, + "$Id$") #if !defined (__ACE_INLINE__) #include "LoadBalancer_i.i" diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.cpp index becce777cb3..533bedcd372 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/ReplicaLocator.cpp @@ -34,9 +34,7 @@ TAO_LB_ReplicaLocator::preinvoke ( // Throw a ForwardRequest exception to force the client to redirect its // requests to the Replica chosen by the LoadBalancer. - ACE_THROW_RETURN (PortableServer::ForwardRequest ( - CORBA::Object::_duplicate (replica)), - 0); + ACE_THROW_RETURN (PortableServer::ForwardRequest (replica), 0); } void diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp index 14ba8a32ae4..f8500c09cf2 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp @@ -4,6 +4,11 @@ #include "LoadBalancingI.h" +ACE_RCSID (LoadBalancing, + LoadBalancingI, + "$Id$") + + // Implementation skeleton constructor TAO_LoadBalancing_ReplicationManager_i::TAO_LoadBalancing_ReplicationManager_i (void) @@ -22,14 +27,16 @@ TAO_LoadBalancing_ReplicationManager_i::~TAO_LoadBalancing_ReplicationManager_i void TAO_LoadBalancing_ReplicationManager_i::register_load_notifier ( - TAO_LoadBalancing::LoadNotifier_ptr /* load_notifier */) + TAO_LoadBalancing::LoadNotifier_ptr /* load_notifier */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW (CORBA::NO_IMPLEMENT()); } TAO_LoadBalancing::LoadNotifier_ptr -TAO_LoadBalancing_ReplicationManager_i::get_load_notifier (void) +TAO_LoadBalancing_ReplicationManager_i::get_load_notifier ( + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InterfaceNotFound)) { @@ -38,7 +45,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_load_notifier (void) void TAO_LoadBalancing_ReplicationManager_i::set_default_properties ( - const TAO_LoadBalancing::Properties & /* props */) + const TAO_LoadBalancing::Properties & /* props */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -47,7 +55,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_default_properties ( } TAO_LoadBalancing::Properties * -TAO_LoadBalancing_ReplicationManager_i::get_default_properties (void) +TAO_LoadBalancing_ReplicationManager_i::get_default_properties ( + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW (CORBA::NO_IMPLEMENT ()); @@ -55,7 +64,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_default_properties (void) void TAO_LoadBalancing_ReplicationManager_i::remove_default_properties ( - const TAO_LoadBalancing::Properties & /* props */) + const TAO_LoadBalancing::Properties & /* props */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -66,7 +76,8 @@ TAO_LoadBalancing_ReplicationManager_i::remove_default_properties ( void TAO_LoadBalancing_ReplicationManager_i::set_type_properties ( const char * /* type_id */, - const TAO_LoadBalancing::Properties & /* overrides */) + const TAO_LoadBalancing::Properties & /* overrides */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -76,7 +87,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_type_properties ( TAO_LoadBalancing::Properties * TAO_LoadBalancing_ReplicationManager_i::get_type_properties ( - const char * /* type_id */) + const char * /* type_id */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW (CORBA::NO_IMPLEMENT ()); @@ -85,7 +97,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_type_properties ( void TAO_LoadBalancing_ReplicationManager_i::remove_type_properties ( const char * /* type_id */, - const TAO_LoadBalancing::Properties & /* props */) + const TAO_LoadBalancing::Properties & /* props */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)) @@ -96,7 +109,8 @@ TAO_LoadBalancing_ReplicationManager_i::remove_type_properties ( void TAO_LoadBalancing_ReplicationManager_i::set_properties_dynamically ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Properties & /* overrides */) + const TAO_LoadBalancing::Properties & /* overrides */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::InvalidProperty, @@ -107,7 +121,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_properties_dynamically ( TAO_LoadBalancing::Properties * TAO_LoadBalancing_ReplicationManager_i::get_properties ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -119,7 +134,8 @@ TAO_LoadBalancing_ReplicationManager_i::create_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, const TAO_LoadBalancing::Location & /* the_location */, const char * /* type_id */, - const TAO_LoadBalancing::Criteria & /* the_criteria */) + const TAO_LoadBalancing::Criteria & /* the_criteria */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, @@ -135,7 +151,8 @@ TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::add_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, const TAO_LoadBalancing::Location & /* the_location */, - CORBA::Object_ptr /* member */) + CORBA::Object_ptr /* member */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, @@ -147,7 +164,8 @@ TAO_LoadBalancing_ReplicationManager_i::add_member ( TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::remove_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Location & /* the_location */) + const TAO_LoadBalancing::Location & /* the_location */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound)) @@ -158,7 +176,8 @@ TAO_LoadBalancing_ReplicationManager_i::remove_member ( TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::set_primary_member ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Location & /* the_location */) + const TAO_LoadBalancing::Location & /* the_location */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound, @@ -170,7 +189,8 @@ TAO_LoadBalancing_ReplicationManager_i::set_primary_member ( TAO_LoadBalancing::Locations * TAO_LoadBalancing_ReplicationManager_i::locations_of_members ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -179,7 +199,8 @@ TAO_LoadBalancing_ReplicationManager_i::locations_of_members ( TAO_LoadBalancing::ObjectGroupId TAO_LoadBalancing_ReplicationManager_i::get_object_group_id ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -188,7 +209,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_object_group_id ( TAO_LoadBalancing::ObjectGroup_ptr TAO_LoadBalancing_ReplicationManager_i::get_object_group_ref ( - TAO_LoadBalancing::ObjectGroup_ptr /* object_group */) + TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)) { @@ -198,7 +220,8 @@ TAO_LoadBalancing_ReplicationManager_i::get_object_group_ref ( CORBA::Object_ptr TAO_LoadBalancing_ReplicationManager_i::get_member_ref ( TAO_LoadBalancing::ObjectGroup_ptr /* object_group */, - const TAO_LoadBalancing::Location & loc) + const TAO_LoadBalancing::Location & loc, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound)) @@ -251,7 +274,7 @@ TAO_LoadBalancing_ReplicationManager_i::create_object ( } // Obtain the FactoryInfos from the_criteria. This method also - // ensure that GenericFactories at different locations are used. + // ensures that GenericFactories at different locations are used. else if (this->get_factory_infos (type_id, the_criteria[i], factory_infos) == 0) @@ -323,7 +346,7 @@ TAO_LoadBalancing_ReplicationManager_i::create_object_i ( // FactoryInfo with a "Location" member that matches // the location at which to create the desired // replica. - // @@ It is also used to ensure the only one replica of + // @@ It is also used to ensure that only one replica of // a given type is created at a given location. @@ -392,8 +415,16 @@ TAO_LoadBalancing_ReplicationManager_i::create_object_i ( replica_entry->factory_creation_id = replica_factory_creation_id; if (object_group_entry.replica_map.bind (replica_entry) != 0) - ACE_THROW_RETURN (TAO_LoadBalancer::ObjectNotCreated (), - CORBA::Object::_nil ()); + { + // An Object of incorrect type was created. Delete it, and + // throw a NoFactory exception. + factory->delete_object (replica_factory_creation_id, + ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + ACE_THROW_RETURN (TAO_LoadBalancer::ObjectNotCreated (), + CORBA::Object::_nil ()); + } // No longer need to protect the allocated Replica_Map. safe_replica_entry.release (); @@ -443,7 +474,9 @@ TAO_LoadBalancing_ReplicationManager_i::get_factory_infos () void TAO_LoadBalancing_ReplicationManager_i::delete_object ( - const TAO_LoadBalancing::GenericFactory::FactoryCreationId & factory_creation_id) + const TAO_LoadBalancing::GenericFactory::FactoryCreationId & + factory_creation_id, + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectNotFound)) { @@ -578,7 +611,7 @@ TAO_LoadBalancing_ReplicationManager_i::operator= ( TAO_LoadBalancing::FactoryInfo &lhs, const TAO_LoadBalancing::FactoryInfo &rhs) { - lhs.facgtory = + lhs.factory = TAO_LoadBalancing::GenericFactory::_duplicate (rhs.factory); lhs.the_location = rhs.the_location; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancingI.h b/TAO/orbsvcs/orbsvcs/LoadBalancingI.h index 8d3d4a8a47e..37f1ea7462a 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancingI.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancingI.h @@ -1,6 +1,15 @@ // -*- C++ -*- -// -// $Id$ + +//============================================================================= +/** + * @file ReplicaLocator.h + * + * $Id$ + * + * @author Ossama Othman + */ +//============================================================================= + #ifndef TAO_LOADBALANCINGI_H #define TAO_LOADBALANCINGI_H @@ -16,99 +25,128 @@ #include "orbsvcs/LoadBalancingS.h" #include "LB_ObjectGroup_Map.h" -class TAO_LoadBalancing_ReplicationManager_i : - public virtual POA_TAO_LoadBalancing::ReplicationManager +class TAO_LoadBalancing_ReplicationManager_i + : public virtual POA_TAO_LoadBalancing::ReplicationManager { public: + /// Constructor. TAO_LoadBalancing_ReplicationManager_i (void); - - virtual ~TAO_LoadBalancing_ReplicationManager_i (void); + /// Destructor. + ~TAO_LoadBalancing_ReplicationManager_i (void); + + /// Register a load notifier with the load balancer + /// ReplicationManager. virtual void register_load_notifier ( - TAO_LoadBalancing::LoadNotifier_ptr load_notifier) + TAO_LoadBalancing::LoadNotifier_ptr load_notifier, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); - // Register a load notifier with the load balancer - // ReplicationManager. - virtual TAO_LoadBalancing::LoadNotifier_ptr get_load_notifier (void) + /// Return a reference to the load notifier in use. + virtual TAO_LoadBalancing::LoadNotifier_ptr get_load_notifier ( + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InterfaceNotFound)); - // Return a reference to the load notifier in use. - // = TAO_LoadBalancer::PropertyManager methods + /** + * @name TAO_LoadBalancer::PropertyManager methods + */ + //@{ + /// Set the default properties to be used by all object groups. virtual void set_default_properties ( - const TAO_LoadBalancing::Properties & props) + const TAO_LoadBalancing::Properties & props, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Set the default properties to be used by all object groups. - virtual TAO_LoadBalancing::Properties * get_default_properties (void) + /// Get the default properties used by all object groups. + virtual TAO_LoadBalancing::Properties * get_default_properties ( + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); - // Get the default properties used by all object groups. + /// Remove default properties. virtual void remove_default_properties ( - const TAO_LoadBalancing::Properties & props) + const TAO_LoadBalancing::Properties & props, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Remove default properties. + /// Set properties associated with a given Replica type. These + /// properties override the default properties. virtual void set_type_properties ( - const char * type_id, - const TAO_LoadBalancing::Properties & overrides) + const char * type_id, + const TAO_LoadBalancing::Properties & overrides, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Set properties associated with a given Replica type. These - // properties override the default properties. + /** + * Return the properties associated with a give Replica type. These + * properties include the type-specific properties in use, in + * addition to the default properties that were not overridden. + */ virtual TAO_LoadBalancing::Properties * get_type_properties ( - const char * type_id) + const char * type_id, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException)); - // Return the properties associated with a give Replica type. These - // properties include the type-specific properties in use, in - // addition to the default properties that were not overridden. + /// Remove the given properties associated with the Replica type ID. virtual void remove_type_properties ( - const char * type_id, - const TAO_LoadBalancing::Properties & props) + const char * type_id, + const TAO_LoadBalancing::Properties & props, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Remove the given properties associated with the Replica type ID. + /** + * Dynamically set the properties associated with a given object + * group as the load balancer and replicas are being executed. + * These properties override the type-specific and default + * properties. + */ virtual void set_properties_dynamically ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Properties & overrides) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Properties & overrides, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::UnsupportedProperty)); - // Dynamically set the properties associated with a given object - // group as the load balancer and replicas are being executed. - // These properties override the type-specific and default - // properties. + /** + * Return the properties currently in use by the given object + * group. These properties include those that were set dynamically, + * type-specific properties that weren't overridden, properties that + * were used when the Replica was created, and default properties + * that weren't overridden. + */ virtual TAO_LoadBalancing::Properties * get_properties ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // Return the properties currently in use by the given object - // group. These properties include those that were set dynamically, - // type-specific properties that weren't overridden, properties that - // were used when the Replica was created, and default properties - // that weren't overridden. - // = TAO_LoadBalancer::ObjectGroupManager methods + //@} + + /** + * @name TAO_LoadBalancer::ObjectGroupManager methods + */ + //@{ + /// Create a member using the load balancer ObjectGroupManager, and + /// add the created object to the ObjectGroup. virtual TAO_LoadBalancing::ObjectGroup_ptr create_member ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & the_location, - const char * type_id, - const TAO_LoadBalancing::Criteria & the_criteria) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & the_location, + const char * type_id, + const TAO_LoadBalancing::Criteria & the_criteria, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, @@ -116,88 +154,108 @@ public: TAO_LoadBalancing::ObjectNotCreated, TAO_LoadBalancing::InvalidCriteria, TAO_LoadBalancing::CannotMeetCriteria)); - // Create a member using the load balancer ObjectGroupManager, and - // add the created object to the ObjectGroup. + /// Add an existing object to the ObjectGroup. virtual TAO_LoadBalancing::ObjectGroup_ptr add_member ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & the_location, - CORBA::Object_ptr member) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & the_location, + CORBA::Object_ptr member, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberAlreadyPresent, TAO_LoadBalancing::ObjectNotAdded)); - // Add an existing object to the ObjectGroup. + /** + * Remove an object at a specific location from the given + * ObjectGroup. Deletion of application created objects must be + * deleted by the application. Objects created by the + * infrastructure (load balancer) will be deleted by the + * infrastructure. + */ virtual TAO_LoadBalancing::ObjectGroup_ptr remove_member ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & the_location) - ACE_THROW_SPEC ((CORBA::SystemException, - TAO_LoadBalancing::ObjectGroupNotFound, - TAO_LoadBalancing::MemberNotFound)); - // Remove an object at a specific location from the given - // ObjectGroup. Deletion of application created objects must be - // deleted by the application. Objects created by the - // infrastructure (load balancer) will be deleted by the - // infrastructure. + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & the_location, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) + ACE_THROW_SPEC ((CORBA::SystemException, + TAO_LoadBalancing::ObjectGroupNotFound, + TAO_LoadBalancing::MemberNotFound)); + /// Return the locations of the members in the given ObjectGroup. virtual TAO_LoadBalancing::Locations * locations_of_members ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // Return the locations of the members in the given ObjectGroup. + /// Return the ObjectGroupId for the given ObjectGroup. virtual TAO_LoadBalancing::ObjectGroupId get_object_group_id ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // Return the ObjectGroupId for the given ObjectGroup. + /// @note Does this method make sense for load balanced objects? virtual TAO_LoadBalancing::ObjectGroup_ptr get_object_group_ref ( - TAO_LoadBalancing::ObjectGroup_ptr object_group) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound)); - // @@ Does this method make sense for load balanced objects? + /// Return the reference corresponding to the Replica of a given + /// ObjectGroup at the given location. virtual CORBA::Object_ptr get_member_ref ( - TAO_LoadBalancing::ObjectGroup_ptr object_group, - const TAO_LoadBalancing::Location & loc) + TAO_LoadBalancing::ObjectGroup_ptr object_group, + const TAO_LoadBalancing::Location & loc, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectGroupNotFound, TAO_LoadBalancing::MemberNotFound)); - // Return the reference corresponding to the Replica of a given - // ObjectGroup at the given location. - // = TAO_LoadBalancer::GenericFactory methods + //@} + /** + * @name TAO_LoadBalancer::GenericFactory methods + */ + //@{ + + /** + * Create an object of the specified type that adheres to the + * restrictions defined by the provided Criteria. The out + * FactoryCreationId parameter may be passed to the delete_object() + * method to delete the object. + */ virtual CORBA::Object_ptr create_object ( - const char * type_id, - const TAO_LoadBalancing::Criteria & the_criteria, - TAO_LoadBalancing::GenericFactory::FactoryCreationId_out - factory_creation_id) + const char * type_id, + const TAO_LoadBalancing::Criteria & the_criteria, + TAO_LoadBalancing::GenericFactory::FactoryCreationId_out + factory_creation_id, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::NoFactory, TAO_LoadBalancing::ObjectNotCreated, TAO_LoadBalancing::InvalidCriteria, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::CannotMeetCriteria)); - // Create an object of the specified type that adheres to the - // restrictions defined by the provided Criteria. The out - // FactoryCreationId parameter may be passed to the delete_object() - // method to delete the object. + /** + * Delete the object corresponding to the provided + * FactoryCreationId. If the object is actually an ObjectGroup, + * then all members within the ObjectGroup will be deleted. + * Afterward, the ObjectGroup itself will be deleted. + */ virtual void delete_object ( - const TAO_LoadBalancing::GenericFactory::FactoryCreationId & - factory_creation_id) + const TAO_LoadBalancing::GenericFactory::FactoryCreationId & + factory_creation_id, + CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ()) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::ObjectNotFound)); - // Delete the object corresponding to the provided - // FactoryCreationId. If the object is actually an ObjectGroup, - // then all members within the ObjectGroup will be deleted. - // Afterward, the ObjectGroup itself will be deleted. + + //@} private: + /// Helper method that creates replicas of the given type. void create_object_i ( const char * type_id, CORBA::UShort initial_number_replicas, @@ -209,62 +267,67 @@ private: TAO_LoadBalancing::InvalidCriteria, TAO_LoadBalancing::InvalidProperty, TAO_LoadBalancing::CannotMeetCriteria)); - // Helper method that creates replicas of the given type. + /// Extract the value of the InitialNumberReplicas property from + /// the_criteria. int get_initial_number_replicas ( const char *type_id, const TAO_LoadBalancing::Criteria &the_criteria, CORBA::UShort &initial_number_replicas) const; - // Extract the value of the InitialNumberReplicas property from - // the_criteria. + /** + * Extract the value of the Factories property from the_criteria. + * This method ensures that the locations in the returned + * FactoryInfos are unique. This is necessary to ensure that only + * one replica of a given type is created by the load balancer at a + * given location. + */ int get_factory_infos ( const char *type_id, const TAO_LoadBalancing::Criteria &the_criteria, TAO_LoadBalancing::FactoryInfos &factory_infos) const; - // Extract the value of the Factories property from the_criteria. - // This method ensures that the locations in the returned - // FactoryInfos are unique. This is necessary to ensure that only - // one replica of a given type is created by the load balancer at a - // given location. + /// Create a POA with the appropriate policies to support + /// ServantLocators (i.e. the ReplicaLocator). int init (PortableServer::POA_ptr root_poa); - // Create a POA with the appropriate policies to support - // ServantLocators (i.e. the ReplicaLocator). + /** + * Get a new ObjectId to be used when creating a new ObjectGroup. + * An ObjectId created by this method will never be reused within + * the scope of a given ReplicationManager. A value suitable for + * use in a map association is also returned. + */ void get_ObjectId (PortableServer::ObjectId &oid, TAO_LB_ObjectGroup_EXT_ID &ext_id); - // Get a new ObjectId to be used when creating a new ObjectGroup. - // An ObjectId created by this method will never be reused within - // the scope of a given ReplicationManager. A value suitable for - // use in a map association is also returned. + /// Assignment operator for TAO_LoadBalancer::FactoryInfo instances. void operator= (TAO_LoadBalancer::FactoryInfo &lhs, const TAO_LoadBalancer::FactoryInfo &rhs); - // Assignment operator for TAO_LoadBalancer::FactoryInfo instances. private: + /// The object that tells the invoking client to forward its requests + /// from the LoadBalancer to an actual replica. TAO_LB_ReplicaLocator locator_; - // The object that tells the invoking client to forward its requests - // from the LoadBalancer to an actual replica. + /// The POA that dispatches requests to the ReplicaLocator. PortableServer::POA_var poa_; - // The POA that dispatches requests to the ReplicaLocator. + /// ObjectId to be used for the next ObjectGroup that is created. CORBA::ULong next_oid_; - // ObjectId to be used for the next ObjectGroup that is created. + /// Map between RepositoryId, ObjectGroup reference, replica list and + /// factory creation ID. TAO_LB_ObjectGroup_Map object_group_map_; - // Map between RepositoryId, ObjectGroup reference, replica list and - // factory creation ID. + /** + * Value that is used when assigning a FactoryCreationId to the + * factory that was used to create a given ObjectGroup. The + * FactoryCreationId is typically comprised of this value in + * addition to another value that makes it unique to a given Load + * Balancer. + */ CORBA::ULong next_factory_num_; - // Value that is used when assigning a FactoryCreationId to the - // factory that was used to create a given ObjectGroup. The - // FactoryCreationId is typically comprised of this value in - // addition to another value that makes it unique to a given Load - // Balancer. }; diff --git a/TAO/orbsvcs/orbsvcs/ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/ObjectGroupManager.cpp index 52daa7176ca..e2e9ce3f6c9 100644 --- a/TAO/orbsvcs/orbsvcs/ObjectGroupManager.cpp +++ b/TAO/orbsvcs/orbsvcs/ObjectGroupManager.cpp @@ -1,8 +1,11 @@ // -*- C++ -*- -// $Id$ +#include "ObjectGroupManager.h" -ACE_RCSID(orbsvcs, ObjectGroupManager, "$Id$") + +ACE_RCSID (LoadBalancing, + ObjectGroupManager, + "$Id$") #if !defined (__ACE_INLINE__) #include "LoadBalancer_i.i" diff --git a/TAO/orbsvcs/orbsvcs/ReplicaLocator.cpp b/TAO/orbsvcs/orbsvcs/ReplicaLocator.cpp index becce777cb3..533bedcd372 100644 --- a/TAO/orbsvcs/orbsvcs/ReplicaLocator.cpp +++ b/TAO/orbsvcs/orbsvcs/ReplicaLocator.cpp @@ -34,9 +34,7 @@ TAO_LB_ReplicaLocator::preinvoke ( // Throw a ForwardRequest exception to force the client to redirect its // requests to the Replica chosen by the LoadBalancer. - ACE_THROW_RETURN (PortableServer::ForwardRequest ( - CORBA::Object::_duplicate (replica)), - 0); + ACE_THROW_RETURN (PortableServer::ForwardRequest (replica), 0); } void diff --git a/TAO/orbsvcs/tests/LoadBalancing/HashReplicaFactory.cpp b/TAO/orbsvcs/tests/LoadBalancing/HashReplicaFactory.cpp index 15063062c9b..262b1850a6b 100644 --- a/TAO/orbsvcs/tests/LoadBalancing/HashReplicaFactory.cpp +++ b/TAO/orbsvcs/tests/LoadBalancing/HashReplicaFactory.cpp @@ -1,10 +1,10 @@ // -*- C++ -*- -// -// $Id$ #include "HashReplicaFactory.h" -ACE_RCSID (LB_test, HashReplicaFactory, "$Id$") +ACE_RCSID (LB_test, + HashReplicaFactory, + "$Id$") CORBA::Object_ptr HashReplicaFactory::create_object ( @@ -12,7 +12,7 @@ HashReplicaFactory::create_object ( const TAO_LoadBalancing::Criteria &the_criteria, TAO_LoadBalancing::GenericFactory::FactoryCreationId_out factory_creation_id, - ACE_TRY_ENV) + CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, TAO_LoadBalancing::NoFactory, TAO_LoadBalancing::ObjectNotCreated, diff --git a/TAO/orbsvcs/tests/LoadBalancing/server.cpp b/TAO/orbsvcs/tests/LoadBalancing/server.cpp index f47efd57aa6..1526a5e1343 100644 --- a/TAO/orbsvcs/tests/LoadBalancing/server.cpp +++ b/TAO/orbsvcs/tests/LoadBalancing/server.cpp @@ -43,7 +43,9 @@ main (int argc, char *argv[]) } CORBA::Object_var poa_object = - orb->resolve_initial_references ("RootPOA"); + orb->resolve_initial_references ("RootPOA", ACE_TRY_ENV); + ACE_TRY_CHECK; + if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), -- cgit v1.2.1