summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2001-06-20 17:29:25 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2001-06-20 17:29:25 +0000
commit6875b5f861b1c033bc1038f22347d26ff5ecbd7c (patch)
tree1489ce0c32da6e39543645906acc491e89e7ef94
parent00573bb117cd1c75ded336b8a686b23a6df6b6af (diff)
downloadATCD-6875b5f861b1c033bc1038f22347d26ff5ecbd7c.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_GenericFactory.cpp51
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.cpp40
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.h17
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.cpp58
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h79
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_PropertyManager.cpp108
-rw-r--r--TAO/orbsvcs/orbsvcs/LB_PropertyManager.h35
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_GenericFactory.cpp51
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.cpp40
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.h17
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.cpp58
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h79
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp108
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.h35
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp4
-rw-r--r--TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp4
16 files changed, 510 insertions, 274 deletions
diff --git a/TAO/orbsvcs/orbsvcs/LB_GenericFactory.cpp b/TAO/orbsvcs/orbsvcs/LB_GenericFactory.cpp
index 6d809749243..8c732a254c1 100644
--- a/TAO/orbsvcs/orbsvcs/LB_GenericFactory.cpp
+++ b/TAO/orbsvcs/orbsvcs/LB_GenericFactory.cpp
@@ -24,7 +24,7 @@ TAO_LB_GenericFactory::TAO_LB_GenericFactory (
CORBA::Object_ptr
TAO_LB_GenericFactory::create_object (
const char * type_id,
- const LoadBalancing::Criteria & /* the_criteria */,
+ const LoadBalancing::Criteria &the_criteria,
LoadBalancing::GenericFactory::FactoryCreationId_out
factory_creation_id,
CORBA::Environment &ACE_TRY_ENV)
@@ -35,14 +35,31 @@ TAO_LB_GenericFactory::create_object (
LoadBalancing::InvalidProperty,
LoadBalancing::CannotMeetCriteria))
{
- LoadBalancing::Properties_var properties =
- this->property_manager_.get_type_properties (type_id,
- ACE_TRY_ENV);
+// LoadBalancing::Properties_var properties =
+// this->property_manager_.get_type_properties (type_id,
+// ACE_TRY_ENV);
+// ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ // Make sure the criteria for the object group being created are
+ // valid.
+ this->property_manager_.validate_properties (the_criteria, ACE_TRY_ENV);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
- CORBA::ULong factory_infos_count = factory_infos.length ();
+ // Extract the initial number of replicas to create.
+ LoadBalancing::InitialNumberReplicas initial_number_replicas =
+ this->property_manager_.get_initial_number_replicas (type_id,
+ the_criteria,
+ ACE_TRY_ENV);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
- const CORBA::UShort initial_number_replicas = 3; // @@ REMOVE ME!
+ // Extract the factory information for each of the replicas.
+ LoadBalancing::FactoryInfos factory_infos =
+ this->property_manager_.get_factory_infos (type_id,
+ the_criteria,
+ ACE_TRY_ENV);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ CORBA::ULong factory_infos_count = factory_infos.length ();
// If the number of factories is less than the initial number of
// replicas, then the desired number of replicas cannot possibly be
@@ -82,11 +99,11 @@ TAO_LB_GenericFactory::create_object (
object_group_entry->object_group =
CORBA::Object::_duplicate (object_group.in ());
- if (this->property_manager_.infrastructure_controlled_membership ())
- {
- this->populate_object_group (object_group_entry, ACE_TRY_ENV);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
- }
+// if (this->property_manager_.infrastructure_controlled_membership ())
+// {
+// this->populate_object_group (object_group_entry, ACE_TRY_ENV);
+// ACE_CHECK_RETURN (CORBA::Object::_nil ());
+// }
// Allocate a new FactoryCreationId for use as an "out" parameter.
LoadBalancing::GenericFactory::FactoryCreationId *tmp = 0;
@@ -101,8 +118,6 @@ TAO_LB_GenericFactory::create_object (
factory_creation_id = tmp;
- // Only increment the next FactoryCreationId if the object group was
- // successfully created.
*tmp <<= fcid;
// Now associate the ObjectId with the ObjectGroup reference. In
@@ -141,9 +156,15 @@ TAO_LB_GenericFactory::delete_object (
{
// Successfully extracted the FactoryCreationId. Now find the
// object group map corresponding to it.
+
+ // The ObjectId for the newly created object group is comprised
+ // solely of the FactoryCreationId.
+ PortableServer::ObjectId_var oid;
+ this->get_ObjectId (fcid, oid.out ());
+
TAO_LB_ObjectGroup_Map_Entry *object_group = 0;
- if (this->object_group_map_.find (fcid, object_group) == -1)
+ if (this->object_group_map_.find (oid.in (), object_group) == -1)
ACE_THROW (LoadBalancing::ObjectNotFound ());
TAO_LB_ReplicaInfo_Set &replica_infos = object_group->replica_infos;
@@ -178,7 +199,7 @@ TAO_LB_GenericFactory::delete_object (
}
// Now delete the ObjectGroup from the set of ObjectGroups.
- this->object_group_map_.unbind (fcid);
+ this->object_group_map_.unbind (oid.in ());
delete object_group;
}
diff --git a/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.cpp
index 919eb0980ad..804a27552bd 100644
--- a/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.cpp
@@ -11,9 +11,9 @@ ACE_RCSID (LoadBalancing,
TAO_LB_ObjectGroupManager::TAO_LB_ObjectGroupManager (
TAO_LB_PropertyManager &property_manager,
TAO_LB_ObjectGroup_Map &map)
- : poa_ (),
- property_manager_ (property_manager),
- object_group_map_ (map)
+ : property_manager_ (property_manager),
+ object_group_map_ (map),
+ location_map_ ()
{
}
@@ -48,7 +48,7 @@ TAO_LB_ObjectGroupManager::add_member (
LoadBalancing::ObjectNotAdded))
{
TAO_LB_ObjectGroup_Map_Entry group_entry =
- this->get_group_entry (object_group, ACE_TRY_ENV);
+ this->object_group_map_.get_group_entry (object_group, ACE_TRY_ENV);
ACE_CHECK_RETURN (LoadBalancing::ObjectGroup::_nil ());
ACE_NEW_THROW_EX (replica_info,
@@ -101,6 +101,7 @@ TAO_LB_ObjectGroupManager::locations_of_members (
ACE_THROW_SPEC ((CORBA::SystemException,
LoadBalancing::ObjectGroupNotFound))
{
+#if 0
TAO_LB_ObjectGroup_Map_Entry group_entry =
this->get_group_entry (object_group, ACE_TRY_ENV);
ACE_CHECK_RETURN (LoadBalancing::ObjectGroup::_nil ());
@@ -135,6 +136,9 @@ TAO_LB_ObjectGroupManager::locations_of_members (
}
return locations._retn ();
+#else
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+#endif /* 0 */
}
LoadBalancing::ObjectGroupId
@@ -170,31 +174,3 @@ TAO_LB_ObjectGroupManager::get_member_ref (
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (),
CORBA::Object::_nil ());
}
-
-void
-TAO_LB_ObjectGroupManager::poa (PortableServer::POA_ptr poa)
-{
- this->poa_ = PortableServer::POA::_duplicate (poa);
-}
-
-TAO_LB_ObjectGroup_Map_Entry *
-TAO_LB_ObjectGroupManager::get_group_entry (
- LoadBalancing::ObjectGroup_ptr object_group,
- CORBA::Environment &ACE_TRY_ENV)
- ACE_THROW_SPEC ((CORBA::SystemException,
- LoadBalancing::ObjectGroupNotFound))
-{
- if (CORBA::is_nil (this->poa_.in ()))
- ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
-
- PortableServer::ObjectId_var oid =
- this->poa_->reference_to_id (object_group, ACE_TRY_ENV);
- ACE_CHECK_RETURN (0);
-
- TAO_LB_ObjectGroup_Map_Entry *group_entry = 0;
- if (this->object_group_map_.find (oid.in (), group_entry) != 0)
- ACE_THROW_RETURN (LoadBalancing::ObjectGroupNotFound (),
- 0);
-
- return group_entry;
-}
diff --git a/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.h b/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.h
index 8fc9dc11e32..f3871bd5b7e 100644
--- a/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.h
+++ b/TAO/orbsvcs/orbsvcs/LB_ObjectGroupManager.h
@@ -148,25 +148,8 @@ public:
//@}
- /// Set the reference to the POA that created the object group
- /// references passed to the ObjectGroupManager methods.
- void poa (PortableServer::POA_ptr poa);
-
private:
- /// Obtain the ObjectGroup hash map entry corresponding to the given
- /// ObjectGroup reference.
- TAO_LB_ObjectGroup_Map_Entry *get_group_entry (
- LoadBalancing::ObjectGroup_ptr object_group,
- CORBA::Environment &ACE_TRY_ENV)
- ACE_THROW_SPEC ((LoadBalancing::ObjectGroupNotFound));
-
-private:
-
- /// Reference to the POA that created the object group references
- /// passed to the ObjectGroupManager methods.
- PortableServer::POA_var poa_;
-
/// Reference to the PropertyManager.
TAO_LB_PropertyManager &property_manager_;
diff --git a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.cpp b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.cpp
index 621492d2b74..6a8c24c3f35 100644
--- a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.cpp
+++ b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.cpp
@@ -6,17 +6,61 @@ ACE_RCSID (LoadBalancing,
LB_ObjectGroup_Map,
"$Id$")
+TAO_LB_ObjectGroup_Map::TAO_LB_ObjectGroup_Map (void)
+ : poa_ (),
+ table_ ()
+{
+}
+
+int
+TAO_LB_ObjectGroup_Map::bind (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *entry)
+{
+ return this->table_.bind (oid, entry);
+}
+
+int
+TAO_LB_ObjectGroup_Map::find (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *&entry)
+{
+ return this->table_.find (oid, entry);
+}
+
+int
+TAO_LB_ObjectGroup_Map::unbind (const PortableServer::ObjectId &oid)
+{
+ return this->table_.unbind (oid);
+}
-TAO_LB_ObjectGroup_Map_Entry::TAO_LB_ObjectGroup_Map_Entry (void)
- : type_id (),
- object_group (),
- replica_infos (),
- creation_properties (),
- dynamic_properties (0),
- lock ()
+void
+TAO_LB_ObjectGroupManager::poa (PortableServer::POA_ptr poa)
{
+ this->poa_ = PortableServer::POA::_duplicate (poa);
}
+TAO_LB_ObjectGroup_Map_Entry *
+TAO_LB_ObjectGroup_Map::get_group_entry (
+ CORBA::Object_ptr object_group,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ LoadBalancing::ObjectGroupNotFound))
+{
+ if (CORBA::is_nil (this->poa_.in ()))
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+
+ PortableServer::ObjectId_var oid =
+ this->poa_->reference_to_id (object_group, ACE_TRY_ENV);
+ ACE_CHECK_RETURN (0);
+
+ TAO_LB_ObjectGroup_Map_Entry *group_entry = 0;
+ if (this->object_group_map_.find (oid.in (), group_entry) != 0)
+ ACE_THROW_RETURN (LoadBalancing::ObjectGroupNotFound (),
+ 0);
+
+ return group_entry;
+}
+
+
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Hash_Map_Entry<PortableServer::ObjectId, TAO_LB_ObjectGroup_Map_Entry *>;
diff --git a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h
index 347b816dbe9..fe74fadf50d 100644
--- a/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h
+++ b/TAO/orbsvcs/orbsvcs/LB_ObjectGroup_Map.h
@@ -34,15 +34,10 @@
*
* @brief Value field of the ObjectGroup map.
*/
-class TAO_LB_ObjectGroup_Map_Entry
+struct TAO_LB_ObjectGroup_Map_Entry
{
public:
- /// Constructor
- TAO_LB_ObjectGroup_Map_Entry (void);
-
-public:
-
/// The RepositoryId corresponding to all Replicas in the
/// ObjectGroup.
CORBA::String_var type_id;
@@ -54,25 +49,71 @@ public:
/// information for each replica.
TAO_LB_ReplicaInfo_Set replica_infos;
- /// Properties used when creating this object group.
- LoadBalancing::Properties creation_properties;
-
- /// Properties set for this object group after this object group was
- /// created.
- LoadBalancing::Properties *dynamic_properties;
+ /// Properties used when creating this object group, in addition
+ /// those set dynamically after the creation.
+ LoadBalancing::Properties properties;
/// Lock used to synchronize access to the ReplicaInfo set.
TAO_SYNCH_MUTEX lock;
};
-/// ObjectId hash map.
-typedef ACE_Hash_Map_Manager_Ex<
- PortableServer::ObjectId,
- TAO_LB_ObjectGroup_Map_Entry *,
- TAO_ObjectId_Hash,
- ACE_Equal_To<PortableServer::ObjectId>,
- TAO_SYNCH_MUTEX> TAO_LB_ObjectGroup_Map;
+class TAO_LB_ObjectGroup_Map
+{
+public:
+
+ /// ObjectId hash map typedef.
+ typedef ACE_Hash_Map_Manager_Ex<
+ PortableServer::ObjectId,
+ TAO_LB_ObjectGroup_Map_Entry *,
+ TAO_ObjectId_Hash,
+ ACE_Equal_To<PortableServer::ObjectId>,
+ TAO_SYNCH_MUTEX> Table;
+
+ /// Constructor
+ TAO_LB_ObjectGroup_Map (void);
+
+ /**
+ * @name The Canonical Map Methods
+ */
+ //@{
+ /// Bind the given ObjectId to the given object group map entry.
+ int bind (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *entry);
+
+ /// Return the object group entry corresponding to the given
+ /// ObjectId.
+ int find (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *&entry);
+
+ /// Unbind the given ObjectId from the map.
+ int unbind (const PortableServer::ObjectId &oid);
+
+ //@}
+
+ /// Set the reference to the POA that created the object group
+ /// references passed to the ObjectGroupManager methods.
+ void poa (PortableServer::POA_ptr poa);
+
+private:
+
+ /// Obtain the ObjectGroup hash map entry corresponding to the given
+ /// ObjectGroup reference.
+ TAO_LB_ObjectGroup_Map_Entry *get_group_entry (
+ LoadBalancing::ObjectGroup_ptr object_group,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((LoadBalancing::ObjectGroupNotFound));
+
+private:
+
+ /// Reference to the POA that created the object group reference.
+ PortableServer::POA_var poa_;
+
+ /// Underlying table that maps ObjectId to object group related
+ /// information.
+ Table table_;
+
+};
#include "ace/post.h"
#endif /* TAO_LB_OBJECTGROUP_MAP_H */
diff --git a/TAO/orbsvcs/orbsvcs/LB_PropertyManager.cpp b/TAO/orbsvcs/orbsvcs/LB_PropertyManager.cpp
index 835a4b5d450..2454edd0d63 100644
--- a/TAO/orbsvcs/orbsvcs/LB_PropertyManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/LB_PropertyManager.cpp
@@ -6,11 +6,12 @@ ACE_RCSID (LoadBalancing,
LB_PropertyManager,
"$Id$")
-TAO_LB_PropertyManager::TAO_LB_PropertyManager (void)
- : default_properties_ (),
+TAO_LB_PropertyManager::TAO_LB_PropertyManager (
+ TAO_LB_ObjectGroup_Map &object_group_map)
+ : object_group_map_ (object_group_map),
+ default_properties_ (),
type_properties_ (),
- creation_properties_ (),
- dynamic_properties_ ()
+ lock_ ()
{
}
@@ -25,7 +26,11 @@ TAO_LB_PropertyManager::set_default_properties (
this->validate_properties (props, ACE_TRY_ENV);
ACE_CHECK;
- this->default_properties_ = props;
+ {
+ ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_);
+
+ this->default_properties_ = props;
+ }
}
LoadBalancing::Properties *
@@ -33,6 +38,8 @@ TAO_LB_PropertyManager::get_default_properties (
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, 0);
+
LoadBalancing::Properties *props = 0;
ACE_NEW_THROW_EX (props,
LoadBalancing::Properties (this->default_properties_),
@@ -112,7 +119,7 @@ TAO_LB_PropertyManager::set_properties_dynamically (
this->validate_properties (overrides, ACE_TRY_ENV);
ACE_CHECK;
- ACE_THROW (CORBA::NO_IMPLEMENT ());
+
}
LoadBalancing::Properties *
@@ -122,7 +129,23 @@ TAO_LB_PropertyManager::get_properties (
ACE_THROW_SPEC ((CORBA::SystemException,
LoadBalancing::ObjectGroupNotFound))
{
- ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+ TAO_LB_ObjectGroup_Map *entry =
+ this->object_group_map_.get_group_entry (object_group, ACE_TRY_ENV);
+ ACE_CHECK_RETURN (0);
+
+ // ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, group_map_guard, entry->lock, 0);
+
+ // ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, property_map_guard, this->lock_, 0);
+
+ // Merge the type-properties into the list.
+ LoadBalancing::Properties &type_properties;
+ if (this->type_properties_.find (entry.in (), type_properties == 0))
+ {
+ }
+
+ // Merge the default properties into the property list.
+
+ return properties._retn ();
}
void
@@ -151,6 +174,43 @@ TAO_LB_PropertyManager::validate_properties (
}
}
+LoadBalancing::InitialNumberReplicas
+TAO_LB_PropertyManager::get_initial_number_replicas (
+ const char * /* type_id */,
+ const LoadBalancing::Criteria &the_criteria,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ // @@ Hack to get things going.
+
+ // First, check if the given criteria has a desired number of
+ // initial replicas.
+ CORBA::ULong len = the_criteria.length ();
+ for (CORBA::ULong i = 0; i < len; ++i)
+ {
+ if (ACE_OS::strcmp (the_criteria[i].nam.id[0],
+ "InitialNumberReplicas") == 0)
+ {
+ LoadBalancing::InitialNumberReplicas initial_number_replicas = 0;
+
+ if (the_criteria[i].val >>= initial_number_replicas)
+ return initial_number_replicas;
+ else
+ ACE_THROW_RETURN (LoadBalancing::Property (
+ the_criteria[i].nam,
+ the_criteria[i].val),
+ 0);
+ }
+ }
+
+ // Second, check if a type-specific number of initial replicas was
+ // set.
+
+ // Third, check if a default number of initial replicas was set.
+
+ return 0; // @@ FIXME
+}
+
+
// -----------------------------------------------------------
CORBA::Boolean
@@ -179,36 +239,18 @@ operator== (const LoadBalancing::Property &lhs,
// Type-specific property hash map template instantiations
template class ACE_Hash_Map_Entry<const char *, LoadBalancing::Properties>;
-template class ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-
-// ObjectGroup-specific property hash map template instantiations
-template class ACE_Hash_Map_Entry<PortableServer::ObjectId, LoadBalancing::Properties>;
-template class ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Base_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-
-template class ACE_Equal_To<PortableServer::ObjectId>;
+template class ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
// Type-specific property hash map template instantiations
#pragma instantiate ACE_Hash_Map_Entry<const char *, LoadBalancing::Properties>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-
-// ObjectGroup-specific property hash map template instantiations
-#pragma instantiate ACE_Hash_Map_Entry<PortableServer::ObjectId, LoadBalancing::Properties>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-
-#pragma instantiate ACE_Equal_To<PortableServer::ObjectId>
+#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/LB_PropertyManager.h b/TAO/orbsvcs/orbsvcs/LB_PropertyManager.h
index d98bf0061c4..4ef2d62d53f 100644
--- a/TAO/orbsvcs/orbsvcs/LB_PropertyManager.h
+++ b/TAO/orbsvcs/orbsvcs/LB_PropertyManager.h
@@ -24,11 +24,26 @@
#include "orbsvcs/LoadBalancingC.h"
+/**
+ * @class TAO_LB_PropertyManager
+ *
+ * @brief Class that implements the LoadBalancing::PropertyManager
+ * interface.
+ *
+ * Only the default and type-specific properties are housed in this
+ * class. The properties used at creation time of an object group and
+ * those set dynamically after object group creation are stored in the
+ * TAO_LB_ObjectGroup_Map_Entry structure. However, the
+ * PropertyManager is still used to manage those properties.
+ */
class TAO_LB_PropertyManager
: public virtual LoadBalancing::PropertyManager
{
public:
+ /// Constructor.
+ TAO_LB_PropertyManager (TAO_LB_ObjectGroup_Map &object_group_map);
+
/**
* @name TAO_LoadBalancer::PropertyManager methods
*/
@@ -103,7 +118,7 @@ public:
* 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
+ * were used when the replica was created, and default properties
* that weren't overridden.
*/
virtual LoadBalancing::Properties * get_properties (
@@ -168,26 +183,22 @@ public:
LoadBalancing::Properties,
ACE_Hash<const char *>,
ACE_Equal_To<const char *>,
- TAO_SYNCH_MUTEX> Type_Prop_Table;
-
- /// Properties used when a given object group was created.
- typedef ACE_Hash_Map_Manager_Ex<
- PortableServer::ObjectId,
- LoadBalancing::Properties,
- TAO_ObjectId_Hash,
- ACE_Equal_To<PortableServer::ObjectId>,
- TAO_SYNCH_MUTEX> Dynamic_Prop_Table;
+ ACE_Null_Mutex> Type_Prop_Table;
private:
+ /// Table that maps ObjectId to Object Group related information.
+ TAO_LB_ObjectGroup_Map &object_group_map_;
+
/// Default properties.
LoadBalancing::Properties default_properties_;
/// Table of type-specific object group properties.
Type_Prop_Table type_properties_;
- /// Table of object group properties used at run-time.
- Dynamic_Prop_Table dynamic_properties_;
+ /// Lock used to synchronize access to the default properties and
+ /// the type-specific properties.
+ TAO_SYNCH_MUTEX lock_;
};
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_GenericFactory.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_GenericFactory.cpp
index 6d809749243..8c732a254c1 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_GenericFactory.cpp
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_GenericFactory.cpp
@@ -24,7 +24,7 @@ TAO_LB_GenericFactory::TAO_LB_GenericFactory (
CORBA::Object_ptr
TAO_LB_GenericFactory::create_object (
const char * type_id,
- const LoadBalancing::Criteria & /* the_criteria */,
+ const LoadBalancing::Criteria &the_criteria,
LoadBalancing::GenericFactory::FactoryCreationId_out
factory_creation_id,
CORBA::Environment &ACE_TRY_ENV)
@@ -35,14 +35,31 @@ TAO_LB_GenericFactory::create_object (
LoadBalancing::InvalidProperty,
LoadBalancing::CannotMeetCriteria))
{
- LoadBalancing::Properties_var properties =
- this->property_manager_.get_type_properties (type_id,
- ACE_TRY_ENV);
+// LoadBalancing::Properties_var properties =
+// this->property_manager_.get_type_properties (type_id,
+// ACE_TRY_ENV);
+// ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ // Make sure the criteria for the object group being created are
+ // valid.
+ this->property_manager_.validate_properties (the_criteria, ACE_TRY_ENV);
ACE_CHECK_RETURN (CORBA::Object::_nil ());
- CORBA::ULong factory_infos_count = factory_infos.length ();
+ // Extract the initial number of replicas to create.
+ LoadBalancing::InitialNumberReplicas initial_number_replicas =
+ this->property_manager_.get_initial_number_replicas (type_id,
+ the_criteria,
+ ACE_TRY_ENV);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
- const CORBA::UShort initial_number_replicas = 3; // @@ REMOVE ME!
+ // Extract the factory information for each of the replicas.
+ LoadBalancing::FactoryInfos factory_infos =
+ this->property_manager_.get_factory_infos (type_id,
+ the_criteria,
+ ACE_TRY_ENV);
+ ACE_CHECK_RETURN (CORBA::Object::_nil ());
+
+ CORBA::ULong factory_infos_count = factory_infos.length ();
// If the number of factories is less than the initial number of
// replicas, then the desired number of replicas cannot possibly be
@@ -82,11 +99,11 @@ TAO_LB_GenericFactory::create_object (
object_group_entry->object_group =
CORBA::Object::_duplicate (object_group.in ());
- if (this->property_manager_.infrastructure_controlled_membership ())
- {
- this->populate_object_group (object_group_entry, ACE_TRY_ENV);
- ACE_CHECK_RETURN (CORBA::Object::_nil ());
- }
+// if (this->property_manager_.infrastructure_controlled_membership ())
+// {
+// this->populate_object_group (object_group_entry, ACE_TRY_ENV);
+// ACE_CHECK_RETURN (CORBA::Object::_nil ());
+// }
// Allocate a new FactoryCreationId for use as an "out" parameter.
LoadBalancing::GenericFactory::FactoryCreationId *tmp = 0;
@@ -101,8 +118,6 @@ TAO_LB_GenericFactory::create_object (
factory_creation_id = tmp;
- // Only increment the next FactoryCreationId if the object group was
- // successfully created.
*tmp <<= fcid;
// Now associate the ObjectId with the ObjectGroup reference. In
@@ -141,9 +156,15 @@ TAO_LB_GenericFactory::delete_object (
{
// Successfully extracted the FactoryCreationId. Now find the
// object group map corresponding to it.
+
+ // The ObjectId for the newly created object group is comprised
+ // solely of the FactoryCreationId.
+ PortableServer::ObjectId_var oid;
+ this->get_ObjectId (fcid, oid.out ());
+
TAO_LB_ObjectGroup_Map_Entry *object_group = 0;
- if (this->object_group_map_.find (fcid, object_group) == -1)
+ if (this->object_group_map_.find (oid.in (), object_group) == -1)
ACE_THROW (LoadBalancing::ObjectNotFound ());
TAO_LB_ReplicaInfo_Set &replica_infos = object_group->replica_infos;
@@ -178,7 +199,7 @@ TAO_LB_GenericFactory::delete_object (
}
// Now delete the ObjectGroup from the set of ObjectGroups.
- this->object_group_map_.unbind (fcid);
+ this->object_group_map_.unbind (oid.in ());
delete object_group;
}
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.cpp
index 919eb0980ad..804a27552bd 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.cpp
@@ -11,9 +11,9 @@ ACE_RCSID (LoadBalancing,
TAO_LB_ObjectGroupManager::TAO_LB_ObjectGroupManager (
TAO_LB_PropertyManager &property_manager,
TAO_LB_ObjectGroup_Map &map)
- : poa_ (),
- property_manager_ (property_manager),
- object_group_map_ (map)
+ : property_manager_ (property_manager),
+ object_group_map_ (map),
+ location_map_ ()
{
}
@@ -48,7 +48,7 @@ TAO_LB_ObjectGroupManager::add_member (
LoadBalancing::ObjectNotAdded))
{
TAO_LB_ObjectGroup_Map_Entry group_entry =
- this->get_group_entry (object_group, ACE_TRY_ENV);
+ this->object_group_map_.get_group_entry (object_group, ACE_TRY_ENV);
ACE_CHECK_RETURN (LoadBalancing::ObjectGroup::_nil ());
ACE_NEW_THROW_EX (replica_info,
@@ -101,6 +101,7 @@ TAO_LB_ObjectGroupManager::locations_of_members (
ACE_THROW_SPEC ((CORBA::SystemException,
LoadBalancing::ObjectGroupNotFound))
{
+#if 0
TAO_LB_ObjectGroup_Map_Entry group_entry =
this->get_group_entry (object_group, ACE_TRY_ENV);
ACE_CHECK_RETURN (LoadBalancing::ObjectGroup::_nil ());
@@ -135,6 +136,9 @@ TAO_LB_ObjectGroupManager::locations_of_members (
}
return locations._retn ();
+#else
+ ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+#endif /* 0 */
}
LoadBalancing::ObjectGroupId
@@ -170,31 +174,3 @@ TAO_LB_ObjectGroupManager::get_member_ref (
ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (),
CORBA::Object::_nil ());
}
-
-void
-TAO_LB_ObjectGroupManager::poa (PortableServer::POA_ptr poa)
-{
- this->poa_ = PortableServer::POA::_duplicate (poa);
-}
-
-TAO_LB_ObjectGroup_Map_Entry *
-TAO_LB_ObjectGroupManager::get_group_entry (
- LoadBalancing::ObjectGroup_ptr object_group,
- CORBA::Environment &ACE_TRY_ENV)
- ACE_THROW_SPEC ((CORBA::SystemException,
- LoadBalancing::ObjectGroupNotFound))
-{
- if (CORBA::is_nil (this->poa_.in ()))
- ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
-
- PortableServer::ObjectId_var oid =
- this->poa_->reference_to_id (object_group, ACE_TRY_ENV);
- ACE_CHECK_RETURN (0);
-
- TAO_LB_ObjectGroup_Map_Entry *group_entry = 0;
- if (this->object_group_map_.find (oid.in (), group_entry) != 0)
- ACE_THROW_RETURN (LoadBalancing::ObjectGroupNotFound (),
- 0);
-
- return group_entry;
-}
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.h
index 8fc9dc11e32..f3871bd5b7e 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.h
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroupManager.h
@@ -148,25 +148,8 @@ public:
//@}
- /// Set the reference to the POA that created the object group
- /// references passed to the ObjectGroupManager methods.
- void poa (PortableServer::POA_ptr poa);
-
private:
- /// Obtain the ObjectGroup hash map entry corresponding to the given
- /// ObjectGroup reference.
- TAO_LB_ObjectGroup_Map_Entry *get_group_entry (
- LoadBalancing::ObjectGroup_ptr object_group,
- CORBA::Environment &ACE_TRY_ENV)
- ACE_THROW_SPEC ((LoadBalancing::ObjectGroupNotFound));
-
-private:
-
- /// Reference to the POA that created the object group references
- /// passed to the ObjectGroupManager methods.
- PortableServer::POA_var poa_;
-
/// Reference to the PropertyManager.
TAO_LB_PropertyManager &property_manager_;
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.cpp
index 621492d2b74..6a8c24c3f35 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.cpp
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.cpp
@@ -6,17 +6,61 @@ ACE_RCSID (LoadBalancing,
LB_ObjectGroup_Map,
"$Id$")
+TAO_LB_ObjectGroup_Map::TAO_LB_ObjectGroup_Map (void)
+ : poa_ (),
+ table_ ()
+{
+}
+
+int
+TAO_LB_ObjectGroup_Map::bind (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *entry)
+{
+ return this->table_.bind (oid, entry);
+}
+
+int
+TAO_LB_ObjectGroup_Map::find (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *&entry)
+{
+ return this->table_.find (oid, entry);
+}
+
+int
+TAO_LB_ObjectGroup_Map::unbind (const PortableServer::ObjectId &oid)
+{
+ return this->table_.unbind (oid);
+}
-TAO_LB_ObjectGroup_Map_Entry::TAO_LB_ObjectGroup_Map_Entry (void)
- : type_id (),
- object_group (),
- replica_infos (),
- creation_properties (),
- dynamic_properties (0),
- lock ()
+void
+TAO_LB_ObjectGroupManager::poa (PortableServer::POA_ptr poa)
{
+ this->poa_ = PortableServer::POA::_duplicate (poa);
}
+TAO_LB_ObjectGroup_Map_Entry *
+TAO_LB_ObjectGroup_Map::get_group_entry (
+ CORBA::Object_ptr object_group,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ LoadBalancing::ObjectGroupNotFound))
+{
+ if (CORBA::is_nil (this->poa_.in ()))
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
+
+ PortableServer::ObjectId_var oid =
+ this->poa_->reference_to_id (object_group, ACE_TRY_ENV);
+ ACE_CHECK_RETURN (0);
+
+ TAO_LB_ObjectGroup_Map_Entry *group_entry = 0;
+ if (this->object_group_map_.find (oid.in (), group_entry) != 0)
+ ACE_THROW_RETURN (LoadBalancing::ObjectGroupNotFound (),
+ 0);
+
+ return group_entry;
+}
+
+
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Hash_Map_Entry<PortableServer::ObjectId, TAO_LB_ObjectGroup_Map_Entry *>;
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h
index 347b816dbe9..fe74fadf50d 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ObjectGroup_Map.h
@@ -34,15 +34,10 @@
*
* @brief Value field of the ObjectGroup map.
*/
-class TAO_LB_ObjectGroup_Map_Entry
+struct TAO_LB_ObjectGroup_Map_Entry
{
public:
- /// Constructor
- TAO_LB_ObjectGroup_Map_Entry (void);
-
-public:
-
/// The RepositoryId corresponding to all Replicas in the
/// ObjectGroup.
CORBA::String_var type_id;
@@ -54,25 +49,71 @@ public:
/// information for each replica.
TAO_LB_ReplicaInfo_Set replica_infos;
- /// Properties used when creating this object group.
- LoadBalancing::Properties creation_properties;
-
- /// Properties set for this object group after this object group was
- /// created.
- LoadBalancing::Properties *dynamic_properties;
+ /// Properties used when creating this object group, in addition
+ /// those set dynamically after the creation.
+ LoadBalancing::Properties properties;
/// Lock used to synchronize access to the ReplicaInfo set.
TAO_SYNCH_MUTEX lock;
};
-/// ObjectId hash map.
-typedef ACE_Hash_Map_Manager_Ex<
- PortableServer::ObjectId,
- TAO_LB_ObjectGroup_Map_Entry *,
- TAO_ObjectId_Hash,
- ACE_Equal_To<PortableServer::ObjectId>,
- TAO_SYNCH_MUTEX> TAO_LB_ObjectGroup_Map;
+class TAO_LB_ObjectGroup_Map
+{
+public:
+
+ /// ObjectId hash map typedef.
+ typedef ACE_Hash_Map_Manager_Ex<
+ PortableServer::ObjectId,
+ TAO_LB_ObjectGroup_Map_Entry *,
+ TAO_ObjectId_Hash,
+ ACE_Equal_To<PortableServer::ObjectId>,
+ TAO_SYNCH_MUTEX> Table;
+
+ /// Constructor
+ TAO_LB_ObjectGroup_Map (void);
+
+ /**
+ * @name The Canonical Map Methods
+ */
+ //@{
+ /// Bind the given ObjectId to the given object group map entry.
+ int bind (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *entry);
+
+ /// Return the object group entry corresponding to the given
+ /// ObjectId.
+ int find (const PortableServer::ObjectId &oid,
+ TAO_LB_ObjectGroup_Map_Entry *&entry);
+
+ /// Unbind the given ObjectId from the map.
+ int unbind (const PortableServer::ObjectId &oid);
+
+ //@}
+
+ /// Set the reference to the POA that created the object group
+ /// references passed to the ObjectGroupManager methods.
+ void poa (PortableServer::POA_ptr poa);
+
+private:
+
+ /// Obtain the ObjectGroup hash map entry corresponding to the given
+ /// ObjectGroup reference.
+ TAO_LB_ObjectGroup_Map_Entry *get_group_entry (
+ LoadBalancing::ObjectGroup_ptr object_group,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((LoadBalancing::ObjectGroupNotFound));
+
+private:
+
+ /// Reference to the POA that created the object group reference.
+ PortableServer::POA_var poa_;
+
+ /// Underlying table that maps ObjectId to object group related
+ /// information.
+ Table table_;
+
+};
#include "ace/post.h"
#endif /* TAO_LB_OBJECTGROUP_MAP_H */
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp
index 835a4b5d450..2454edd0d63 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp
@@ -6,11 +6,12 @@ ACE_RCSID (LoadBalancing,
LB_PropertyManager,
"$Id$")
-TAO_LB_PropertyManager::TAO_LB_PropertyManager (void)
- : default_properties_ (),
+TAO_LB_PropertyManager::TAO_LB_PropertyManager (
+ TAO_LB_ObjectGroup_Map &object_group_map)
+ : object_group_map_ (object_group_map),
+ default_properties_ (),
type_properties_ (),
- creation_properties_ (),
- dynamic_properties_ ()
+ lock_ ()
{
}
@@ -25,7 +26,11 @@ TAO_LB_PropertyManager::set_default_properties (
this->validate_properties (props, ACE_TRY_ENV);
ACE_CHECK;
- this->default_properties_ = props;
+ {
+ ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_);
+
+ this->default_properties_ = props;
+ }
}
LoadBalancing::Properties *
@@ -33,6 +38,8 @@ TAO_LB_PropertyManager::get_default_properties (
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, 0);
+
LoadBalancing::Properties *props = 0;
ACE_NEW_THROW_EX (props,
LoadBalancing::Properties (this->default_properties_),
@@ -112,7 +119,7 @@ TAO_LB_PropertyManager::set_properties_dynamically (
this->validate_properties (overrides, ACE_TRY_ENV);
ACE_CHECK;
- ACE_THROW (CORBA::NO_IMPLEMENT ());
+
}
LoadBalancing::Properties *
@@ -122,7 +129,23 @@ TAO_LB_PropertyManager::get_properties (
ACE_THROW_SPEC ((CORBA::SystemException,
LoadBalancing::ObjectGroupNotFound))
{
- ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);
+ TAO_LB_ObjectGroup_Map *entry =
+ this->object_group_map_.get_group_entry (object_group, ACE_TRY_ENV);
+ ACE_CHECK_RETURN (0);
+
+ // ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, group_map_guard, entry->lock, 0);
+
+ // ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, property_map_guard, this->lock_, 0);
+
+ // Merge the type-properties into the list.
+ LoadBalancing::Properties &type_properties;
+ if (this->type_properties_.find (entry.in (), type_properties == 0))
+ {
+ }
+
+ // Merge the default properties into the property list.
+
+ return properties._retn ();
}
void
@@ -151,6 +174,43 @@ TAO_LB_PropertyManager::validate_properties (
}
}
+LoadBalancing::InitialNumberReplicas
+TAO_LB_PropertyManager::get_initial_number_replicas (
+ const char * /* type_id */,
+ const LoadBalancing::Criteria &the_criteria,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ // @@ Hack to get things going.
+
+ // First, check if the given criteria has a desired number of
+ // initial replicas.
+ CORBA::ULong len = the_criteria.length ();
+ for (CORBA::ULong i = 0; i < len; ++i)
+ {
+ if (ACE_OS::strcmp (the_criteria[i].nam.id[0],
+ "InitialNumberReplicas") == 0)
+ {
+ LoadBalancing::InitialNumberReplicas initial_number_replicas = 0;
+
+ if (the_criteria[i].val >>= initial_number_replicas)
+ return initial_number_replicas;
+ else
+ ACE_THROW_RETURN (LoadBalancing::Property (
+ the_criteria[i].nam,
+ the_criteria[i].val),
+ 0);
+ }
+ }
+
+ // Second, check if a type-specific number of initial replicas was
+ // set.
+
+ // Third, check if a default number of initial replicas was set.
+
+ return 0; // @@ FIXME
+}
+
+
// -----------------------------------------------------------
CORBA::Boolean
@@ -179,36 +239,18 @@ operator== (const LoadBalancing::Property &lhs,
// Type-specific property hash map template instantiations
template class ACE_Hash_Map_Entry<const char *, LoadBalancing::Properties>;
-template class ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>;
-
-// ObjectGroup-specific property hash map template instantiations
-template class ACE_Hash_Map_Entry<PortableServer::ObjectId, LoadBalancing::Properties>;
-template class ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Base_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-template class ACE_Hash_Map_Reverse_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>;
-
-template class ACE_Equal_To<PortableServer::ObjectId>;
+template class ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
// Type-specific property hash map template instantiations
#pragma instantiate ACE_Hash_Map_Entry<const char *, LoadBalancing::Properties>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, TAO_SYNCH_MUTEX>
-
-// ObjectGroup-specific property hash map template instantiations
-#pragma instantiate ACE_Hash_Map_Entry<PortableServer::ObjectId, LoadBalancing::Properties>
-#pragma instantiate ACE_Hash_Map_Manager_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<PortableServer::ObjectId, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<PortableServer::ObjectId>, TAO_SYNCH_MUTEX>
-
-#pragma instantiate ACE_Equal_To<PortableServer::ObjectId>
+#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, TAO_ObjectId_Hash, ACE_Equal_To<const char *>, ACE_Null_Mutex>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.h
index d98bf0061c4..4ef2d62d53f 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.h
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.h
@@ -24,11 +24,26 @@
#include "orbsvcs/LoadBalancingC.h"
+/**
+ * @class TAO_LB_PropertyManager
+ *
+ * @brief Class that implements the LoadBalancing::PropertyManager
+ * interface.
+ *
+ * Only the default and type-specific properties are housed in this
+ * class. The properties used at creation time of an object group and
+ * those set dynamically after object group creation are stored in the
+ * TAO_LB_ObjectGroup_Map_Entry structure. However, the
+ * PropertyManager is still used to manage those properties.
+ */
class TAO_LB_PropertyManager
: public virtual LoadBalancing::PropertyManager
{
public:
+ /// Constructor.
+ TAO_LB_PropertyManager (TAO_LB_ObjectGroup_Map &object_group_map);
+
/**
* @name TAO_LoadBalancer::PropertyManager methods
*/
@@ -103,7 +118,7 @@ public:
* 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
+ * were used when the replica was created, and default properties
* that weren't overridden.
*/
virtual LoadBalancing::Properties * get_properties (
@@ -168,26 +183,22 @@ public:
LoadBalancing::Properties,
ACE_Hash<const char *>,
ACE_Equal_To<const char *>,
- TAO_SYNCH_MUTEX> Type_Prop_Table;
-
- /// Properties used when a given object group was created.
- typedef ACE_Hash_Map_Manager_Ex<
- PortableServer::ObjectId,
- LoadBalancing::Properties,
- TAO_ObjectId_Hash,
- ACE_Equal_To<PortableServer::ObjectId>,
- TAO_SYNCH_MUTEX> Dynamic_Prop_Table;
+ ACE_Null_Mutex> Type_Prop_Table;
private:
+ /// Table that maps ObjectId to Object Group related information.
+ TAO_LB_ObjectGroup_Map &object_group_map_;
+
/// Default properties.
LoadBalancing::Properties default_properties_;
/// Table of type-specific object group properties.
Type_Prop_Table type_properties_;
- /// Table of object group properties used at run-time.
- Dynamic_Prop_Table dynamic_properties_;
+ /// Lock used to synchronize access to the default properties and
+ /// the type-specific properties.
+ TAO_SYNCH_MUTEX lock_;
};
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp
index 2f30a287778..2212a9e44ee 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LoadBalancingI.cpp
@@ -20,7 +20,7 @@ TAO_LoadBalancing_ReplicationManager_i::TAO_LoadBalancing_ReplicationManager_i
: poa_ (),
lock_ (),
object_group_map_ (),
- property_manager_ (),
+ property_manager_ (this->object_group_map_),
generic_factory_ (this->property_manager_,
this->object_group_map_),
object_group_manager_ (this->property_manager_,
@@ -457,8 +457,8 @@ TAO_LoadBalancing_ReplicationManager_i::init (
ACE_TRY_ENV);
ACE_TRY_CHECK;
+ this->object_group_map_.poa (this->poa_.in ());
this->generic_factory_.poa (this->poa_.in ());
- this->object_group_manager_.poa (this->poa_.in ());
}
ACE_CATCHANY
{
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp
index 2f30a287778..2212a9e44ee 100644
--- a/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp
+++ b/TAO/orbsvcs/orbsvcs/LoadBalancingI.cpp
@@ -20,7 +20,7 @@ TAO_LoadBalancing_ReplicationManager_i::TAO_LoadBalancing_ReplicationManager_i
: poa_ (),
lock_ (),
object_group_map_ (),
- property_manager_ (),
+ property_manager_ (this->object_group_map_),
generic_factory_ (this->property_manager_,
this->object_group_map_),
object_group_manager_ (this->property_manager_,
@@ -457,8 +457,8 @@ TAO_LoadBalancing_ReplicationManager_i::init (
ACE_TRY_ENV);
ACE_TRY_CHECK;
+ this->object_group_map_.poa (this->poa_.in ());
this->generic_factory_.poa (this->poa_.in ());
- this->object_group_manager_.poa (this->poa_.in ());
}
ACE_CATCHANY
{