diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp | 125 |
1 files changed, 88 insertions, 37 deletions
diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp index 2454edd0d63..a33bf726d22 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_PropertyManager.cpp @@ -1,11 +1,13 @@ // -*- C++ -*- #include "LB_PropertyManager.h" +#include "LB_ObjectGroup_Map.h" ACE_RCSID (LoadBalancing, LB_PropertyManager, "$Id$") + TAO_LB_PropertyManager::TAO_LB_PropertyManager ( TAO_LB_ObjectGroup_Map &object_group_map) : object_group_map_ (object_group_map), @@ -108,7 +110,7 @@ TAO_LB_PropertyManager::remove_type_properties ( void TAO_LB_PropertyManager::set_properties_dynamically ( - LoadBalancing::ObjectGroup_ptr object_group, + LoadBalancing::ObjectGroup_ptr /*object_group */, const LoadBalancing::Properties & overrides, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, @@ -119,17 +121,18 @@ TAO_LB_PropertyManager::set_properties_dynamically ( this->validate_properties (overrides, ACE_TRY_ENV); ACE_CHECK; - + ACE_THROW (CORBA::NO_IMPLEMENT ()); } LoadBalancing::Properties * TAO_LB_PropertyManager::get_properties ( - LoadBalancing::ObjectGroup_ptr object_group, + LoadBalancing::ObjectGroup_ptr /* object_group */, CORBA::Environment &ACE_TRY_ENV) ACE_THROW_SPEC ((CORBA::SystemException, LoadBalancing::ObjectGroupNotFound)) { - TAO_LB_ObjectGroup_Map *entry = +#if 0 + TAO_LB_ObjectGroup_Map_Entry *entry = this->object_group_map_.get_group_entry (object_group, ACE_TRY_ENV); ACE_CHECK_RETURN (0); @@ -146,6 +149,9 @@ TAO_LB_PropertyManager::get_properties ( // Merge the default properties into the property list. return properties._retn (); +#else + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +#endif /* 0 */ } void @@ -160,13 +166,13 @@ TAO_LB_PropertyManager::validate_properties ( CORBA::ULong len = props.length (); for (CORBA::ULong i = 0; i < len; ++i) { - if (ACE_OS::strcmp (props[i].nam.id[0], + if (ACE_OS::strcmp (props[i].nam[0].id, "Factories") == 0) return; - else if (ACE_OS::strcmp (props[i].nam.id[0], + else if (ACE_OS::strcmp (props[i].nam[0].id, "InitialNumberReplicas") == 0) return; - else if (ACE_OS::strcmp (props[i].nam.id[0], + else if (ACE_OS::strcmp (props[i].nam[0].id, "MinimumNumberReplicas") == 0) return; else @@ -174,11 +180,29 @@ TAO_LB_PropertyManager::validate_properties ( } } +// void +// TAO_LB_PropertyManager::process_criteria ( +// const char *type_id, +// const LoadBalancing::Criteria &the_criteria, // IN +// LoadBalancing::Properties &props, // OUT +// CORBA::Environment &ACE_TRY_ENV) +// { +// this->validate_properties (the_criteria, ACE_TRY_ENV); +// ACE_CHECK; + +// CORBA::ULong len = the_criteria.length (); +// for (CORBA::ULong i = 0; i < len; ++i) +// { +// // @@ Hack to get things going. +// props[i] = the_criteria[i]; +// } +// } + LoadBalancing::InitialNumberReplicas -TAO_LB_PropertyManager::get_initial_number_replicas ( +TAO_LB_PropertyManager::initial_number_replicas ( const char * /* type_id */, const LoadBalancing::Criteria &the_criteria, - CORBA::Environment &ACE_TRY_ENV) + CORBA::Environment &ACE_TRY_ENV) const { // @@ Hack to get things going. @@ -187,7 +211,7 @@ TAO_LB_PropertyManager::get_initial_number_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], + if (ACE_OS::strcmp (the_criteria[i].nam[0].id, "InitialNumberReplicas") == 0) { LoadBalancing::InitialNumberReplicas initial_number_replicas = 0; @@ -195,7 +219,7 @@ TAO_LB_PropertyManager::get_initial_number_replicas ( if (the_criteria[i].val >>= initial_number_replicas) return initial_number_replicas; else - ACE_THROW_RETURN (LoadBalancing::Property ( + ACE_THROW_RETURN (LoadBalancing::InvalidProperty ( the_criteria[i].nam, the_criteria[i].val), 0); @@ -210,47 +234,74 @@ TAO_LB_PropertyManager::get_initial_number_replicas ( return 0; // @@ FIXME } - -// ----------------------------------------------------------- - -CORBA::Boolean -operator== (const LoadBalancing::Property &lhs, - const LoadBalancing::Property &rhs) +LoadBalancing::FactoryInfos * +TAO_LB_PropertyManager::factory_infos ( + const char * /* type_id */, + const LoadBalancing::Criteria &the_criteria, + CORBA::Environment &ACE_TRY_ENV) const { - // @todo Interim implementation until we figure out what to do when a - // property has multiple components. - CORBA::ULong lhs_len = lhs.length (); - CORBA::ULong rhs_len = rhs.length (); + // @@ 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[0].id, + "Factories") == 0) + { + LoadBalancing::FactoryInfos *tmp = 0; + + if (the_criteria[i].val >>= tmp) + { + // The Any retains ownership of the data, so we need to + // return a copy. + LoadBalancing::FactoryInfos *factory_infos = 0; + ACE_NEW_THROW_EX ( + factory_infos, + LoadBalancing::FactoryInfos (*tmp), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (0); + + return factory_infos; + } + else + ACE_THROW_RETURN (LoadBalancing::InvalidProperty ( + the_criteria[i].nam, + the_criteria[i].val), + 0); + } + } - if (lhs_len != rhs_len) - return 0; + // Second, check if a type-specific number of initial replicas was + // set. - for (CORBA::ULong i = 0; i < lhs_len; ++i) - if (ACE_OS::strcmp (lhs[i].id, rhs[i].id) != 0 - || ACE_OS::strcmp (lhs[i].kind, rhs[i].kind) != 0) - return 0; + // Third, check if a default number of initial replicas was set. - return 1; + return 0; // @@ FIXME } -// ----------------------------------------------------------- #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) // 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 *>, 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>; +template class ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, 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 *>, 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> +#pragma instantiate ACE_Hash_Map_Manager_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<const char *, LoadBalancing::Properties, ACE_Hash<const char *>, ACE_Equal_To<const char *>, ACE_Null_Mutex> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ |