diff options
author | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-25 17:50:01 +0000 |
---|---|---|
committer | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-25 17:50:01 +0000 |
commit | d0cf1bb2c2258543b14bb9bb48d920b64cd6330e (patch) | |
tree | f371c5e70e5f05cdc6e18e76a863e2b04eba345d | |
parent | 1fa3e171e7cf245d0615b74921b5e111787b47d5 (diff) | |
download | ATCD-d0cf1bb2c2258543b14bb9bb48d920b64cd6330e.tar.gz |
ChangeLogTag: Tue Nov 25 11:22:22 2003 Dale Wilson <wilson_d@ociweb.com>
28 files changed, 1191 insertions, 1102 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index d2ae9af1194..345e508976f 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,54 @@ +Tue Nov 25 11:22:22 2003 Dale Wilson <wilson_d@ociweb.com> + + * orbsvcs/orbsvcs/FT_CORBA.idl: + * orbsvcs/orbsvcs/FT_FaultDetectorFactory.idl: + * orbsvcs/orbsvcs/FT_ReplicationManager.idl: + Increase use of PortableGroup definitions to + avoid confusion between synonyms (i.e. what's + the difference between PortableGroup::Name and + FT::Name?) + + * orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h: + * orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp: + * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp: + * orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h: + * orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h: + * orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp: + * orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h: + * orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp: + * orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h: + * orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp: + * orbsvcs/Fault_Detector/Fault_Detector_i.h: + * orbsvcs/Fault_Detector/Fault_Detector_i.cpp: + + Code review issues and use PortableGroup names. + + + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h: + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp: + Code review issues. + Remove IOR Manipulator (moved into ObjectGroup) + Add comments about parallel data structures. + Move object group management code (create_object, add_member, remove_member) + to TAO::PG_Object_Group class. + + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp: + Object group management code moved into Object_Group + and protected with a MUTEX + + * orbsvcs/tests/FT_App/FT_Creator.h: + * orbsvcs/tests/FT_App/FT_Creator.cpp: + * orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp: + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h: + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp: + Fix build issues encountered on solaris & linux. + + * orbsvcs/tests/FT_App/replica.cmd: + * orbsvcs/tests/FT_App/run_test_registry.pl: + Keep scripts up to date with recent code changes. + Wed Nov 19 14:30:07 2003 Dale Wilson <wilson_d@ociweb.com> * orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp Remove dead code. diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp index beb9b8b0f45..81f65f0c316 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp @@ -14,6 +14,7 @@ #include "FT_DefaultFaultAnalyzer.h" #include "orbsvcs/CosNotifyCommC.h" #include "orbsvcs/FT_NotifierC.h" +#include "orbsvcs/FT_FaultDetectorFactoryC.h" #include "orbsvcs/FT_ReplicationManagerC.h" #include "orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h" #include <tao/debug.h> @@ -58,21 +59,23 @@ int TAO::FT_DefaultFaultAnalyzer::validate_event_type ( if (result == 0) { - //TODO: Get rid of magic strings (though they come from the spec). - if (ACE_OS::strcmp (domain_name.in(), "FT_CORBA") != 0 || - ACE_OS::strcmp (type_name.in(), "ObjectCrashFault") != 0) + if (ACE_OS::strcmp (domain_name.in(), FT::FT_EVENT_TYPE_DOMAIN) != 0 || + ACE_OS::strcmp (type_name.in(), FT::FT_EVENT_TYPE_NAME) != 0) { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ( - "TAO::FT_DefaultFaultAnalyzer::validate_event_type: " - "Received invalid event type.\n" - "EventType domain: <%s>\n" - "EventType type: <%s>\n" - "EventName: <%s>\n"), - domain_name.in(), - type_name.in(), - event_name.in() - )); + if (TAO_debug_level > 6) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ( + "TAO::FT_DefaultFaultAnalyzer::validate_event_type: " + "Received invalid event type.\n" + "EventType domain: <%s>\n" + "EventType type: <%s>\n" + "EventName: <%s>\n"), + domain_name.in(), + type_name.in(), + event_name.in() + )); + } result = -1; } } @@ -97,39 +100,48 @@ int TAO::FT_DefaultFaultAnalyzer::validate_event_type ( { // Check for FTDomainId. if (ACE_OS::strcmp ( - event.filterable_data[0].name.in(), "FTDomainId") != 0) + event.filterable_data[0].name.in(), FT::FT_DOMAIN_ID) != 0) { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ( - "TAO::FT_DefaultFaultAnalyzer::validate_event_type: " - "Received invalid structured event.\n" - "filterable_data[0] must be \"FTDomainId\", not \"%s\"\n"), - event.filterable_data[0].name.in() - )); + if (TAO_debug_level > 6) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ( + "TAO::FT_DefaultFaultAnalyzer::validate_event_type: " + "Received invalid structured event.\n" + "filterable_data[0] must be \"FTDomainId\", not \"%s\"\n"), + event.filterable_data[0].name.in() + )); + } result = -1; } else if (ACE_OS::strcmp ( - event.filterable_data[1].name.in(), "Location") != 0) + event.filterable_data[1].name.in(), FT::FT_LOCATION) != 0) + { + if (TAO_debug_level > 6) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ( + "TAO::FT_DefaultFaultAnalyzer::validate_event_type: " + "Received invalid structured event.\n" + "filterable_data[1] must be \"Location\", not \"%s\"\n"), + event.filterable_data[1].name.in() + )); + } + result = -1; + } + } + else + { + if (TAO_debug_level > 6) { ACE_ERROR ((LM_ERROR, ACE_TEXT ( "TAO::FT_DefaultFaultAnalyzer::validate_event_type: " "Received invalid structured event.\n" - "filterable_data[1] must be \"Location\", not \"%s\"\n"), - event.filterable_data[1].name.in() + "There must be at least two name/value pairs in " + "the filterable_data field, for \"FTDomainId\" and \"Location\".\n") )); - result = -1; } - } - else - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ( - "TAO::FT_DefaultFaultAnalyzer::validate_event_type: " - "Received invalid structured event.\n" - "There must be at least two name/value pairs in " - "the filterable_data field, for \"FTDomainId\" and \"Location\".\n") - )); result = -1; } } @@ -141,9 +153,7 @@ int TAO::FT_DefaultFaultAnalyzer::validate_event_type ( int TAO::FT_DefaultFaultAnalyzer::analyze_fault_event ( const CosNotification::StructuredEvent & event) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h index 9b3d1a665df..e5b1b0b8292 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h @@ -36,7 +36,7 @@ namespace TAO * */ class TAO_ReplicationManagerLib_Export FT_DefaultFaultAnalyzer - : public TAO::FT_FaultAnalyzer + : public ::TAO::FT_FaultAnalyzer { public: diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp index 2033bb4ae77..0467dfde29e 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp @@ -59,9 +59,7 @@ int TAO::FT_FaultConsumer::init ( ACE_ENV_ARG_DECL) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -107,9 +105,7 @@ int TAO::FT_FaultConsumer::init ( this->consumer_ref_.in(), filter ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -129,9 +125,7 @@ int TAO::FT_FaultConsumer::init ( int TAO::FT_FaultConsumer::fini (ACE_ENV_SINGLE_ARG_DECL) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Enter TAO::FT_FaultConsumer::fini.\n") @@ -145,9 +139,7 @@ int TAO::FT_FaultConsumer::fini (ACE_ENV_SINGLE_ARG_DECL) if (!CORBA::is_nil (this->fault_notifier_.in())) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -160,9 +152,7 @@ int TAO::FT_FaultConsumer::fini (ACE_ENV_SINGLE_ARG_DECL) this->consumer_id_ ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -188,9 +178,7 @@ int TAO::FT_FaultConsumer::fini (ACE_ENV_SINGLE_ARG_DECL) ACE_ENDTRY; ACE_CHECK_RETURN(1); -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -201,9 +189,7 @@ int TAO::FT_FaultConsumer::fini (ACE_ENV_SINGLE_ARG_DECL) this->consumer_ref_ = CosNotifyComm::StructuredPushConsumer::_nil (); -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Leave TAO::FT_FaultConsumer::fini.\n") @@ -242,9 +228,7 @@ void TAO::FT_FaultConsumer::push_structured_event ( { // Debugging support. this->notifications_ += 1; -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h index a1e613f5ded..d0b64b49e4f 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h @@ -49,22 +49,22 @@ namespace TAO int object_is_primary; /// The location of the fault. - FT::Location_var location; + PortableGroup::Location_var location; /// The TypeId of the object that faulted. - FT::TypeId_var type_id; + PortableGroup::TypeId_var type_id; /// The ObjectGroupId of the faulted object. PortableGroup::ObjectGroupId object_group_id; /// Other properties of the object group to which the fault relates. - FT::MembershipStyleValue membership_style; + PortableGroup::MembershipStyleValue membership_style; FT::ReplicationStyleValue replication_style; - FT::MinimumNumberMembersValue minimum_number_members; - FT::InitialNumberMembersValue initial_number_members; + PortableGroup::MinimumNumberMembersValue minimum_number_members; + PortableGroup::InitialNumberMembersValue initial_number_members; /// The object group's factories. - FT::FactoryInfos_var factories; + PortableGroup::FactoryInfos_var factories; }; diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp index b3267c46ae7..375ed19a342 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp @@ -24,14 +24,6 @@ #include <orbsvcs/PortableGroup/PG_Properties_Encoder.h> #include <orbsvcs/PortableGroup/PG_Property_Utils.h> #include <orbsvcs/PortableGroup/PG_conf.h> -#include <orbsvcs/PortableGroup/PG_Utils.h> - - -/////////////////////////////////////////////////////////////// -// parallel Object Group Map that is FT/IOGR aware -// @@ todo reconcile this with the LB centric implementation -#include <orbsvcs/PortableGroup/PG_Object_Group_Map.h> - #include <orbsvcs/FaultTolerance/FT_IOGR_Property.h> #include <orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h> @@ -41,29 +33,27 @@ ACE_RCSID (FT_ReplicationManager, "$Id$") TAO::FT_ReplicationManager::FT_ReplicationManager () - : internals_() - , orb_(CORBA::ORB::_nil()) - , poa_(PortableServer::POA::_nil()) - , iorm_(TAO_IOP::TAO_IOR_Manipulation::_nil()) - , ior_output_file_(0) - , ns_name_(0) - , naming_context_(CosNaming::NamingContext::_nil()) - , replication_manager_ref_(FT::ReplicationManager::_nil()) - , object_group_manager_() - , property_manager_ (this->object_group_manager_) + : orb_ (CORBA::ORB::_nil ()) + , poa_ (PortableServer::POA::_nil ()) + , ior_output_file_ (0) + , ns_name_ (0) + , naming_context_ (CosNaming::NamingContext::_nil ()) + , replication_manager_ref_ (FT::ReplicationManager::_nil ()) + , object_group_manager_ () + , property_manager_ (object_group_manager_) , generic_factory_ (this->object_group_manager_, this->property_manager_) - , fault_notifier_(FT::FaultNotifier::_nil()) - , fault_notifier_ior_(0) - , fault_consumer_() - , factory_registry_("ReplicationManager::FactoryRegistry") - , quit_(0) + , fault_notifier_ (FT::FaultNotifier::_nil ()) + , fault_notifier_ior_string_ (0) + , fault_consumer_ () + , factory_registry_ ("ReplicationManager::FactoryRegistry") + , quit_ (0) { - // @@ init must be called before using this object. + // init must be called before using this object. } TAO::FT_ReplicationManager::~FT_ReplicationManager (void) { - // @@ cleanup happens in fini + // cleanup happens in fini } @@ -75,7 +65,7 @@ int TAO::FT_ReplicationManager::parse_args (int argc, char * argv[]) ACE_Get_Opt get_opts (argc, argv, "n:o:f:"); int c; - while ((c = get_opts ()) != -1) + while ( (c = get_opts ()) != -1) { switch (c) { @@ -88,16 +78,17 @@ int TAO::FT_ReplicationManager::parse_args (int argc, char * argv[]) break; case 'f': - this->fault_notifier_ior_ = get_opts.opt_arg (); + this->fault_notifier_ior_string_ = get_opts.opt_arg (); break; case '?': // fall thru default: - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ( (LM_ERROR, ACE_TEXT ("%T %n (%P|%t) - usage: %s") - ACE_TEXT (" -o <iorfile>") - ACE_TEXT (" -n <name-to-bind-in-NameService>") + ACE_TEXT (" -o <iorfile (for testing)>") + ACE_TEXT (" -f <fault notifier IOR (for testing)>") + ACE_TEXT (" -n <name-to-bind-in-NameService (for testing)>") ACE_TEXT ("\n"), argv [0]), -1); @@ -110,16 +101,14 @@ int TAO::FT_ReplicationManager::parse_args (int argc, char * argv[]) const char * TAO::FT_ReplicationManager::identity () const { - return this->identity_.c_str(); + return this->identity_.c_str (); } int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { - ACE_DEBUG ((LM_DEBUG, + ACE_DEBUG ( (LM_DEBUG, ACE_TEXT ( "%T %n (%P|%t) - Enter TAO::FT_ReplicationManager::init.\n") )); @@ -137,7 +126,7 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) } else { - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ( (LM_ERROR, ACE_TEXT ( "%T %n (%P|%t) - " "Could not create Property Validator.\n")), @@ -146,61 +135,67 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) // initialize the FactoryRegistry - this->factory_registry_.init(this->orb_.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN(-1); + this->factory_registry_.init (this->orb_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); // Get the RootPOA. CORBA::Object_var poa_obj = this->orb_->resolve_initial_references ( TAO_OBJID_ROOTPOA ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); this->poa_ = PortableServer::POA::_narrow ( - poa_obj.in() ACE_ENV_ARG_PARAMETER); + poa_obj.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); // Initialize the Object Group Manager. result = this->object_group_manager_.init ( - this->orb_.in(), this->poa_.in()); + this->orb_.in (), this->poa_.in ()); if (result != 0) { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ( - "%T %n (%P|%t) - " - "Could not initialize the Object Group Manager.\n")), - -1); + if (TAO_debug_level > 3) + { + ACE_ERROR ( (LM_ERROR, + ACE_TEXT ( + "%T %n (%P|%t) - " + "Could not initialize the Object Group Manager.\n"))); + } + return -1; } - // Get an object reference for the ORB's IORManipulation object. - CORBA::Object_var iorm_obj = this->orb_->resolve_initial_references ( - TAO_OBJID_IORMANIPULATION ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - this->iorm_ = TAO_IOP::TAO_IOR_Manipulation::_narrow ( - iorm_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - // Activate ourself in the POA. PortableServer::ObjectId_var oid = this->poa_->activate_object ( this ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); CORBA::Object_var this_obj = this->poa_->id_to_reference ( - oid.in() ACE_ENV_ARG_PARAMETER); + oid.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); this->replication_manager_ref_ = FT::ReplicationManager::_narrow ( - this_obj.in() ACE_ENV_ARG_PARAMETER); + this_obj.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); // If we were given an initial IOR string for a Fault Notifier on the // command line, convert it to an IOR, then register the fault // notifier. - if (this->fault_notifier_ior_ != 0) + if (this->fault_notifier_ior_string_ != 0) { CORBA::Object_var notifier_obj = this->orb_->string_to_object ( - this->fault_notifier_ior_ ACE_ENV_ARG_PARAMETER); + this->fault_notifier_ior_string_ ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); FT::FaultNotifier_var notifier = FT::FaultNotifier::_narrow ( - notifier_obj.in() ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - this->register_fault_notifier_i (notifier.in() ACE_ENV_ARG_PARAMETER); + notifier_obj.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + if (! CORBA::is_nil (notifier.in ())) + { + this->register_fault_notifier_i (notifier.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + } + else + { + ACE_ERROR_RETURN ( (LM_ERROR, + ACE_TEXT ( + "%T %n (%P|%t) - " + "Could not resolve notifier IOR.\n")), + -1); + } } // Activate the RootPOA. @@ -222,7 +217,7 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) ACE_CHECK_RETURN (-1); if (CORBA::is_nil (ior_table.in ())) { - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ( (LM_ERROR, ACE_TEXT ("%T %n (%P|%t) - Unable to resolve the IORTable.\n")), -1); } @@ -241,14 +236,10 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { this->identity_ = "file:"; this->identity_ += this->ior_output_file_; - result = this->write_ior(); - } - else - { - this->ns_name_ = "ReplicationManager"; + result = this->write_ior (); } - if (this->ns_name_ != 0) + if (result == 0 && this->ns_name_ != 0) { this->identity_ = "name:"; this->identity_ += this->ns_name_; @@ -257,36 +248,44 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) TAO_OBJID_NAMESERVICE ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - if (CORBA::is_nil(naming_obj.in ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%T %n (%P|%t) - Unable to find the Naming Service.\n")), - -1); - } - this->naming_context_ = CosNaming::NamingContext::_narrow ( naming_obj.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); + if (CORBA::is_nil (this->naming_context_.in ())) + { + ACE_ERROR_RETURN ( (LM_ERROR, + ACE_TEXT ("%T %n (%P|%t) - Unable to find the Naming Service.\n")), + -1); + } + this->this_name_.length (1); this->this_name_[0].id = CORBA::string_dup (this->ns_name_); this->naming_context_->rebind ( this->this_name_, - replication_manager_ref_.in() + this->replication_manager_ref_.in () ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); } -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ( - "%T %n (%P|%t) - Leave TAO::FT_ReplicationManager::init.\n") - )); + if (result == 0) + { + ACE_DEBUG ( (LM_DEBUG, + ACE_TEXT ( + "%T %n (%P|%t) - Leave TAO::FT_ReplicationManager::init.\n") + )); + } + else + { + ACE_DEBUG ( (LM_DEBUG, + ACE_TEXT ( + "%T %n (%P|%t) - FT_ReplicationManager::init failed.\n") + )); + } } return result; @@ -303,8 +302,8 @@ int TAO::FT_ReplicationManager::fini (ACE_ENV_SINGLE_ARG_DECL) { int result = 0; - //@@ Should we ever return -1 from this function, or should we - // catch and swallow all exceptions? + result = this->fault_consumer_.fini (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); if (this->ior_output_file_ != 0) { @@ -318,31 +317,28 @@ int TAO::FT_ReplicationManager::fini (ACE_ENV_SINGLE_ARG_DECL) this->ns_name_ = 0; } - result = this->fault_consumer_.fini (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - return result; } //////////////////////////////////////////// // FT_ReplicationManager private methods -int TAO::FT_ReplicationManager::write_ior() +int TAO::FT_ReplicationManager::write_ior () { int result = -1; FILE* out = ACE_OS::fopen (this->ior_output_file_, "w"); if (out) { CORBA::String_var ior_str = this->orb_->object_to_string ( - this->replication_manager_ref_.in()); - ACE_OS::fprintf (out, "%s", ior_str.in()); + this->replication_manager_ref_.in ()); + ACE_OS::fprintf (out, "%s", ior_str.in ()); ACE_OS::fclose (out); result = 0; } else { - ACE_ERROR ((LM_ERROR, - ACE_TEXT("%T %n (%P|%t) - Open failed for %s\n"), this->ior_output_file_ + ACE_ERROR ( (LM_ERROR, + ACE_TEXT ("%T %n (%P|%t) - Open failed for %s\n"), this->ior_output_file_ )); } return result; @@ -357,20 +353,20 @@ void TAO::FT_ReplicationManager::register_fault_notifier ( FT::FaultNotifier_ptr fault_notifier ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) + ACE_THROW_SPEC ( (CORBA::SystemException)) { - this->register_fault_notifier_i (fault_notifier ACE_ENV_ARG_DECL); + this->register_fault_notifier_i (fault_notifier ACE_ENV_ARG_PARAMETER); } void TAO::FT_ReplicationManager::register_fault_notifier_i ( FT::FaultNotifier_ptr fault_notifier ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) + ACE_THROW_SPEC ( (CORBA::SystemException)) { if (CORBA::is_nil (fault_notifier)) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ( (LM_ERROR, ACE_TEXT ( "%T %n (%P|%t) - " "Bad Fault Notifier object reference provided.\n") @@ -390,9 +386,13 @@ TAO::FT_ReplicationManager::register_fault_notifier_i ( int result = 0; ACE_TRY_NEW_ENV { + //@@ should we check to see if a notifier is already registered, rather than + // simply "unregistering"? result = this->fault_consumer_.fini (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; + // Note if the fini failed, we ignore it. It may not have been registered in the first place. + // Create a fault analyzer. TAO::FT_FaultAnalyzer * analyzer = 0; ACE_NEW_NORETURN ( @@ -400,7 +400,7 @@ TAO::FT_ReplicationManager::register_fault_notifier_i ( TAO::FT_ReplicationManagerFaultAnalyzer (this)); if (analyzer == 0) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ( (LM_ERROR, ACE_TEXT ( "%T %n (%P|%t) - " "Error creating FaultAnalyzer.\n" @@ -411,8 +411,8 @@ TAO::FT_ReplicationManager::register_fault_notifier_i ( if (result == 0) { result = this->fault_consumer_.init ( - this->poa_.in(), - this->fault_notifier_.in(), + this->poa_.in (), + this->fault_notifier_.in (), analyzer ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; @@ -425,12 +425,13 @@ TAO::FT_ReplicationManager::register_fault_notifier_i ( "TAO::FT_ReplicationManager::register_fault_notifier_i: " "Error reinitializing FT_FaultConsumer.\n") ); + result = -1; } ACE_ENDTRY; if (result != 0) { - ACE_ERROR ((LM_ERROR, + ACE_ERROR ( (LM_ERROR, ACE_TEXT ( "%T %n (%P|%t) - " "Could not re-initialize FT_FaultConsumer.\n") @@ -449,9 +450,13 @@ TAO::FT_ReplicationManager::register_fault_notifier_i ( FT::FaultNotifier_ptr TAO::FT_ReplicationManager::get_fault_notifier ( ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, FT::InterfaceNotFound)) + ACE_THROW_SPEC ( (CORBA::SystemException, FT::InterfaceNotFound)) { - return FT::FaultNotifier::_duplicate (this->fault_notifier_.in()); + if (CORBA::is_nil (this->fault_notifier_.in ())) + { + ACE_THROW_RETURN ( FT::InterfaceNotFound () , FT::FaultNotifier::_nil ()); + } + return FT::FaultNotifier::_duplicate (this->fault_notifier_.in ()); } @@ -460,18 +465,18 @@ TAO::FT_ReplicationManager::get_fault_notifier ( TAO::FT_ReplicationManager::get_factory_registry ( const PortableGroup::Criteria & selection_criteria ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) + ACE_THROW_SPEC ( (CORBA::SystemException)) { ACE_UNUSED_ARG (selection_criteria); - return this->factory_registry_.reference(); + return this->factory_registry_.reference (); } /// TAO-specific shutdown operation. void TAO::FT_ReplicationManager::shutdown ( ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) + ACE_THROW_SPEC ( (CORBA::SystemException)) { - quit_ = 1; + this->quit_ = 1; } // Get the type_id associated with an object group. @@ -491,19 +496,18 @@ void TAO::FT_ReplicationManager::set_default_properties ( const PortableGroup::Properties & props ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { this->property_manager_.set_default_properties (props ACE_ENV_ARG_PARAMETER); - ACE_CHECK; } PortableGroup::Properties * TAO::FT_ReplicationManager::get_default_properties ( ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) + ACE_THROW_SPEC ( (CORBA::SystemException)) { return this->property_manager_.get_default_properties ( @@ -514,13 +518,12 @@ void TAO::FT_ReplicationManager::remove_default_properties ( const PortableGroup::Properties & props ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { this->property_manager_.remove_default_properties (props ACE_ENV_ARG_PARAMETER); - ACE_CHECK; } void @@ -528,21 +531,20 @@ TAO::FT_ReplicationManager::set_type_properties ( const char *type_id, const PortableGroup::Properties & overrides ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { this->property_manager_.set_type_properties (type_id, overrides ACE_ENV_ARG_PARAMETER); - ACE_CHECK; } PortableGroup::Properties * TAO::FT_ReplicationManager::get_type_properties ( const char *type_id ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) + ACE_THROW_SPEC ( (CORBA::SystemException)) { return this->property_manager_.get_type_properties (type_id @@ -554,14 +556,13 @@ TAO::FT_ReplicationManager::remove_type_properties ( const char *type_id, const PortableGroup::Properties & props ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { this->property_manager_.remove_type_properties (type_id, props ACE_ENV_ARG_PARAMETER); - ACE_CHECK; } void @@ -569,7 +570,7 @@ TAO::FT_ReplicationManager::set_properties_dynamically ( PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Properties & overrides ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound, PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) @@ -577,14 +578,13 @@ TAO::FT_ReplicationManager::set_properties_dynamically ( this->property_manager_.set_properties_dynamically (object_group, overrides ACE_ENV_ARG_PARAMETER); - ACE_CHECK; } PortableGroup::Properties * TAO::FT_ReplicationManager::get_properties ( PortableGroup::ObjectGroup_ptr object_group ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { return @@ -599,10 +599,10 @@ TAO::FT_ReplicationManager::get_properties ( /// Sets the primary member of a group. PortableGroup::ObjectGroup_ptr TAO::FT_ReplicationManager::set_primary_member ( - FT::ObjectGroup_ptr object_group, - const FT::Location & the_location + PortableGroup::ObjectGroup_ptr object_group, + const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( + ACE_THROW_SPEC ( ( CORBA::SystemException , PortableGroup::ObjectGroupNotFound , PortableGroup::MemberNotFound @@ -610,68 +610,30 @@ TAO::FT_ReplicationManager::set_primary_member ( , FT::BadReplicationStyle )) { - PortableGroup::ObjectGroup_var member = this->object_group_manager_.get_member_ref ( - object_group, - the_location - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil()); - - if (CORBA::is_nil (member.in ()) ) - { - ACE_THROW (PortableGroup::MemberNotFound ()); - ACE_CHECK_RETURN (CORBA::Object::_nil()); - } - - FT::TagFTGroupTaggedComponent tag_component; - TAO_FT_IOGR_Property prop (tag_component); - - //remove primary - if (iorm_->is_primary_set (&prop, object_group ACE_ENV_ARG_PARAMETER)) - { - ACE_CHECK_RETURN (CORBA::Object::_nil()); - (void)iorm_->remove_primary_tag (&prop, object_group ACE_ENV_ARG_PARAMETER); - } - - if (! iorm_->set_primary (&prop, member.in(), object_group ACE_ENV_ARG_PARAMETER)) + PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil(); + TAO::PG_Object_Group * group = 0; + if (this->object_group_map_.find_group (object_group, group)) { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%T %n (%P|%t) - Can't set primary in IOGR .\n") - )); - ACE_THROW( FT::PrimaryNotSet()); - } - ACE_CHECK_RETURN (CORBA::Object::_nil()); + PortableGroup::TagGroupTaggedComponent tag_component; + TAO_FT_IOGR_Property prop (tag_component); - if (! TAO::PG_Utils::get_tagged_component (object_group, tag_component)) - { - ACE_THROW (PortableGroup::ObjectGroupNotFound()); + int sts = group->set_primary_member (&prop, the_location ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (FT_ObjectGroup::_nil ()); + if (sts) + { + result = group->reference (); + } + else + { + ACE_THROW_RETURN (FT::PrimaryNotSet (), PortableGroup::ObjectGroup::_nil ()); + } } - - tag_component.object_group_ref_version += 1; - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%T %n (%P|%t) - set_primary_member: Setting IOGR version to %u\n"), - ACE_static_cast(unsigned, tag_component.object_group_ref_version) - )); - - // Set the property - TAO::PG_Utils::set_tagged_component (object_group, tag_component ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - /////////////////////// - // Now we do it again using - // our own object group collection - TAO::PG_Object_Group * group; - if (this->object_group_map_.find_group (object_group, group)) + else { - group->set_primary_location (the_location ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - // Set the new group reference - // and distribute it to all members - group->set_reference (object_group, tag_component.object_group_ref_version, 1); + ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), PortableGroup::ObjectGroup::_nil ()); } - - - return object_group->_duplicate (object_group); + return result._retn (); } PortableGroup::ObjectGroup_ptr @@ -681,7 +643,7 @@ TAO::FT_ReplicationManager::create_member ( const char * type_id, const PortableGroup::Criteria & the_criteria ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound, PortableGroup::MemberAlreadyPresent, PortableGroup::NoFactory, @@ -695,49 +657,9 @@ TAO::FT_ReplicationManager::create_member ( type_id, the_criteria ACE_ENV_ARG_PARAMETER); -} - -#if 0 // debug code -void TAO::FT_ReplicationManager::dump_membership (TAO_IOP::TAO_IOR_Manipulation_ptr iorm, const char * label, PortableGroup::ObjectGroup_ptr member) const -{ - FT::TagFTGroupTaggedComponent ft_tag_component; - TAO_FT_IOGR_Property prop (ft_tag_component); - if (iorm->is_primary_set(&prop, member)) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%T %n (%P|%t) - %s: PRIMARY member.\n"), - label - )); - } - else - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%T %n (%P|%t) - %s: backup member.\n"), - label - )); - } - PortableGroup::TagGroupTaggedComponent tag_component; - if (TAO::PG_Utils::get_tagged_component (member, tag_component)) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%T %n (%P|%t) - %s: Group: .") - ACE_TEXT (" version: %u\n"), - - label, - tag_component.object_group_ref_version - )); - } - else - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%T %n (%P|%t) - %s: No group information found.\n"), - label - )); - } + int todo; } -#endif // debug code - PortableGroup::ObjectGroup_ptr @@ -746,86 +668,49 @@ TAO::FT_ReplicationManager::add_member ( const PortableGroup::Location & the_location, CORBA::Object_ptr member ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound, PortableGroup::MemberAlreadyPresent, PortableGroup::ObjectNotAdded)) { + PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil (); - FT::TagFTGroupTaggedComponent ft_tag_component; - TAO_FT_IOGR_Property prop (ft_tag_component); - CORBA::Boolean first_member = ! iorm_->is_primary_set(&prop, object_group); - - PortableGroup::TagGroupTaggedComponent tag_component; - - if (! TAO::PG_Utils::get_tagged_component (object_group, tag_component)) + // Find the object group corresponding to this IOGR + TAO::PG_Object_Group * group = 0; + if (this->object_group_map_.find_group (object_group, group)) { - ACE_THROW (PortableGroup::ObjectGroupNotFound()); - } - - ///////////////////////////////////////////// - // create a list containing the existing ObjectGroup - // and the newly added member - TAO_IOP::TAO_IOR_Manipulation::IORList iors (2); - iors.length (2); - iors [0] = this->object_group_manager_.add_member ( - object_group, - the_location, - member + // add the member to the OGM's group information + // assign the (meaningless) result to a var. so we'll release it. + PortableGroup::ObjectGroup_var new_ogm_group = this->object_group_manager_.add_member ( + object_group, + the_location, + member + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (result); + + /////////////////////// + // Now we do it again using + // our own object group collection + // @@ TODO: if this fails, we're out of synch with the OGM + // @@ unified object group management will fix this someday. + group->add_member ( + the_location, + member ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); - - iors [1] = member; - - // Now merge the list into one new IOGR - PortableGroup::ObjectGroup_var merged = - iorm_->merge_iors (iors ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); - - if (first_member) + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + result = group->reference (); + } + else { - // remove the original profile. It's a dummy entry supplied by create_object. - PortableGroup::ObjectGroup_var cleaned = - iorm_->remove_profiles (merged.in (), object_group); - ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); - if (! iorm_->set_primary (&prop, member, cleaned.in () ACE_ENV_ARG_PARAMETER)) + if (TAO_debug_level > 0) { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%T %n (%P|%t) - Can't set primary in IOGR after adding first replica.\n") + ACE_ERROR ( (LM_ERROR, + ACE_TEXT ("%T %n (%P|%t) - FT_ReplicationManager::add_member to unknown group\n") )); } - ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); - - merged = cleaned; + ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result); } - ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); - - tag_component.object_group_ref_version += 1; - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%T %n (%P|%t) - add_member: Setting IOGR version to %u\n"), - ACE_static_cast(unsigned, tag_component.object_group_ref_version) - )); - - // Set the property - TAO::PG_Utils::set_tagged_component (merged, - tag_component); - ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); - - /////////////////////// - // Now we do it again using - // our own object group collection - TAO::PG_Object_Group * group; - if (this->object_group_map_.find_group (merged.in (), group)) - { - group->add_member (the_location, member ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - // Set the new group reference - // and distribute it to all members - group->set_reference (merged.in (), tag_component.object_group_ref_version, 1); - - } - return merged._retn(); + return result._retn (); } @@ -834,21 +719,42 @@ TAO::FT_ReplicationManager::remove_member ( PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound, PortableGroup::MemberNotFound)) { - return - this->object_group_manager_.remove_member (object_group, - the_location - ACE_ENV_ARG_PARAMETER); + PortableGroup::ObjectGroup_var result = PortableGroup::ObjectGroup::_nil (); + + // Find the object group corresponding to this IOGR + TAO::PG_Object_Group * group = 0; + if (this->object_group_map_.find_group (object_group, group)) + { + group->remove_member(the_location ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (result); + result = group->reference (); + + // @@ warning: if the remove_member call below is unsuccessful + // the parallel object group information will be out of synch + // Unifying the Object group management will fix this. + (void) this->object_group_manager_.remove_member ( + object_group, + the_location + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil ()); + + } + else + { + ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound (), result); + } + return result; } PortableGroup::Locations * TAO::FT_ReplicationManager::locations_of_members ( PortableGroup::ObjectGroup_ptr object_group ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { return @@ -860,7 +766,7 @@ PortableGroup::ObjectGroups * TAO::FT_ReplicationManager::groups_at_location ( const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) + ACE_THROW_SPEC ( (CORBA::SystemException)) { return this->object_group_manager_.groups_at_location (the_location @@ -871,7 +777,7 @@ PortableGroup::ObjectGroupId TAO::FT_ReplicationManager::get_object_group_id ( PortableGroup::ObjectGroup_ptr object_group ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { return @@ -883,7 +789,7 @@ PortableGroup::ObjectGroup_ptr TAO::FT_ReplicationManager::get_object_group_ref ( PortableGroup::ObjectGroup_ptr object_group ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound)) { return @@ -895,7 +801,7 @@ PortableGroup::ObjectGroup_ptr TAO::FT_ReplicationManager::get_object_group_ref_from_id ( PortableGroup::ObjectGroupId group_id ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( + ACE_THROW_SPEC ( ( CORBA::SystemException , PortableGroup::ObjectGroupNotFound )) @@ -910,7 +816,7 @@ TAO::FT_ReplicationManager::get_member_ref ( PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectGroupNotFound, PortableGroup::MemberNotFound)) { @@ -930,14 +836,15 @@ TAO::FT_ReplicationManager::create_object ( const PortableGroup::Criteria & the_criteria, PortableGroup::GenericFactory::FactoryCreationId_out factory_creation_id ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::NoFactory, PortableGroup::ObjectNotCreated, PortableGroup::InvalidCriteria, PortableGroup::InvalidProperty, PortableGroup::CannotMeetCriteria)) { - /// Start with the LB-oriented create_object + // Start with the LB-oriented create_object + // which actually creates an object group CORBA::Object_var obj = this->generic_factory_.create_object ( type_id, the_criteria, @@ -949,36 +856,59 @@ TAO::FT_ReplicationManager::create_object ( // then create the corresponding // entry in our object group map - PortableGroup::ObjectGroupId oid; - if (! ((*factory_creation_id) >>= oid )) + TAO::PG_Object_Group * objectGroup + = TAO::PG_Object_Group::create ( + this->orb_.in (), + obj.in (), + type_id, + the_criteria + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + this->object_group_map_.insert_group (objectGroup->get_object_group_id (), objectGroup); + + if (TAO_debug_level > 1) { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%T %n (%P|%t) - Unexpected type of factory creation id.\n") - )); - ACE_THROW (PortableGroup::ObjectNotCreated()); - ACE_CHECK_RETURN (CORBA::Object::_nil()); - } + PortableGroup::ObjectGroupId factory_id; + if ((*factory_creation_id) >>= factory_id) + { + PortableGroup::ObjectGroupId ogid = objectGroup->get_object_group_id (); + if (factory_id != ogid) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sanity check failed: Factory creation id[%u] != object group id[%u]\n"), + ACE_static_cast (unsigned, factory_id), + ACE_static_cast (unsigned, ogid) + )); + } + } + else + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Sanity check failed: Factory creation id is not an object group id\n") + )); + } - TAO::PG_Object_Group * objectGroup; - ACE_NEW_THROW_EX ( - objectGroup, - TAO::PG_Object_Group (this->orb_.in (), oid, type_id, the_criteria), - CORBA::NO_MEMORY()); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); + } - this->object_group_map_.insert_group(oid, objectGroup); - return obj._retn(); + return obj._retn (); } void TAO::FT_ReplicationManager::delete_object ( const PortableGroup::GenericFactory::FactoryCreationId & factory_creation_id ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, + ACE_THROW_SPEC ( (CORBA::SystemException, PortableGroup::ObjectNotFound)) { + this->generic_factory_.delete_object (factory_creation_id ACE_ENV_ARG_PARAMETER); + + int todo; ACE_CHECK; } + + + diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h index 01e1db674d8..5bacbeb504b 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h @@ -22,20 +22,13 @@ #pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -//@@ Review all these header files and make sure they are all needed -// or if some can be replaced with forward declarations. #include <orbsvcs/FT_ReplicationManagerS.h> -#include <orbsvcs/FT_NotifierC.h> -#include <tao/IORManipulation/IORC.h> -#include <orbsvcs/PortableGroupC.h> #include <orbsvcs/PortableGroup/PG_PropertyManager.h> #include <orbsvcs/PortableGroup/PG_GenericFactory.h> #include <orbsvcs/PortableGroup/PG_ObjectGroupManager.h> #include <orbsvcs/PortableGroup/PG_FactoryRegistry.h> #include <orbsvcs/PortableGroup/PG_Object_Group_Map.h> -#include <orbsvcs/FaultTolerance/FT_Service_Activate.h> #include <orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h> -#include <orbsvcs/CosNamingC.h> namespace TAO { @@ -64,75 +57,53 @@ namespace TAO public: - /** - * Parse command line arguments. - * @param argc traditional C argc - * @param argv traditional C argv - * @return zero for success; nonzero is process return code for failure. - */ - int parse_args (int argc, char * argv[]); - - /** - * Initialize this object. - * @param orb Our CORBA::ORB -- we keep var to it. - * @return zero for success; nonzero is process return code for failure. - */ - int init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + /** + * Parse command line arguments. + * @param argc traditional C argc + * @param argv traditional C argv + * @return zero for success; nonzero is process return code for failure. + */ + int parse_args (int argc, char * argv[]); - /** - * Prepare to exit. - * @return zero for success; nonzero is process return code for failure. - */ - int fini (ACE_ENV_SINGLE_ARG_DECL); + /** + * Initialize this object. + * @param orb Our CORBA::ORB -- we keep var to it. + * @return zero for success; nonzero is process return code for failure. + */ + int init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); - /** - * Idle-time activity. - * - * @param result is set to process return code if return value is non-zero. - * @return zero to continue; nonzero to exit - */ - int idle(int & result); + /** + * Prepare to exit. + * @return zero for success; nonzero is process return code for failure. + */ + int fini (ACE_ENV_SINGLE_ARG_DECL); + /** + * Idle-time activity. + * + * @param result is set to process return code if return value is non-zero. + * @return zero to continue; nonzero to exit + */ + int idle(int & result); - /** - * Identify this fault detector factory. - * @return a string to identify this object for logging/console message purposes. - */ - const char * identity () const; - /** - * Get the type_id associated with an object group. - * @param object_group The ObjectGroup. - * @return String identifying the type id associated with the ObjectGroup. - */ - char * type_id (PortableGroup::ObjectGroup_ptr object_group - ACE_ENV_ARG_DECL); - - ///////////////////////// - // Implementation methods - private: /** - * Write this factory's IOR to a file - */ - int write_ior (void); + * Identify this fault detector factory. + * @return a string to identify this object for logging/console message purposes. + */ + const char * identity () const; /** - * Extract the value of the InitialNumberReplicas property from - * the_criteria. - */ - int get_initial_number_replicas ( - const char * type_id, - const PortableGroup::Criteria & the_criteria, - CORBA::UShort & initial_number_replicas) const; + * Get the type_id associated with an object group. + * @param object_group The ObjectGroup. + * @return String identifying the type id associated with the ObjectGroup. + */ + char * type_id (PortableGroup::ObjectGroup_ptr object_group + ACE_ENV_ARG_DECL); - /// Registers the Fault Notifier with the Replication Manager. - void register_fault_notifier_i ( - FT::FaultNotifier_ptr fault_notifier - ACE_ENV_ARG_DECL - ) - ACE_THROW_SPEC (( - CORBA::SystemException - )); + + ////////////////////// + // CORBA interface(s) public: @@ -208,8 +179,10 @@ namespace TAO PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)); - /// Set properties associated with a given Replica type. These - /// properties override the 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 PortableGroup::Properties & overrides @@ -219,10 +192,10 @@ namespace TAO PortableGroup::UnsupportedProperty)); /** - * 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. - */ + * Return the properties associated with a given Replica type. These + * properties include the type-specific properties in use, in + * addition to the default properties that were not overridden. + */ virtual PortableGroup::Properties * get_type_properties ( const char * type_id ACE_ENV_ARG_DECL) @@ -238,11 +211,11 @@ namespace TAO PortableGroup::UnsupportedProperty)); /** - * Dynamically set the properties associated with a given object - * group as the replication manager and replicas are being executed. - * These properties override the type-specific and default - * properties. - */ + * Dynamically set the properties associated with a given object + * group as the replication manager and replicas are being executed. + * These properties override the type-specific and default + * properties. + */ virtual void set_properties_dynamically ( PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Properties & overrides @@ -253,12 +226,12 @@ namespace TAO PortableGroup::UnsupportedProperty)); /** - * 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. - */ + * 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 PortableGroup::Properties * get_properties ( PortableGroup::ObjectGroup_ptr object_group ACE_ENV_ARG_DECL) @@ -268,11 +241,11 @@ namespace TAO //@} /** - * @name FT::FTObjectGroupManager methods - * - * Methods required by the FTup::FTObjectGroupManager - * interface. - */ + * @name FT::FTObjectGroupManager methods + * + * Methods required by the FT::FTObjectGroupManager + * interface. + */ //@{ /// Create a member using the ObjectGroupManager, and @@ -303,12 +276,12 @@ namespace TAO PortableGroup::ObjectNotAdded)); /** - * 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 (replication manager) will be deleted by the - * infrastructure. - */ + * 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 (replication manager) will be deleted by the + * infrastructure. + */ virtual PortableGroup::ObjectGroup_ptr remove_member ( PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location & the_location @@ -357,8 +330,10 @@ namespace TAO , PortableGroup::ObjectGroupNotFound )); - /// Return the reference corresponding to the Replica of a given - /// ObjectGroup at the given location. + /** + * Return the reference corresponding to the Replica of a given + * ObjectGroup at the given location. + */ virtual CORBA::Object_ptr get_member_ref ( PortableGroup::ObjectGroup_ptr object_group, const PortableGroup::Location & loc @@ -368,9 +343,9 @@ namespace TAO PortableGroup::MemberNotFound)); /// Sets the primary member of a group. - virtual FT::ObjectGroup_ptr set_primary_member ( - FT::ObjectGroup_ptr object_group, - const FT::Location & the_location + virtual PortableGroup::ObjectGroup_ptr set_primary_member ( + PortableGroup::ObjectGroup_ptr object_group, + const PortableGroup::Location & the_location ACE_ENV_ARG_DECL ) ACE_THROW_SPEC (( @@ -384,18 +359,18 @@ namespace TAO //@} /** - * @name PortableGroup::GenericFactory methods - * - * Methods required by the PortableGroup::GenericFactory interface. - */ + * @name PortableGroup::GenericFactory methods + * + * Methods required by the PortableGroup::GenericFactory interface. + */ //@{ /** - * 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. - */ + * 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 PortableGroup::Criteria & the_criteria, @@ -410,11 +385,11 @@ namespace TAO PortableGroup::CannotMeetCriteria)); /** - * 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. - */ + * 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 PortableGroup::GenericFactory::FactoryCreationId & factory_creation_id @@ -424,6 +399,23 @@ namespace TAO //@} + ///////////////////////// + // Implementation methods + private: + /** + * Write this factory's IOR to a file + */ + int write_ior (void); + + /// Registers the Fault Notifier with the Replication Manager. + void register_fault_notifier_i ( + FT::FaultNotifier_ptr fault_notifier + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + //////////////// // Forbidden methods FT_ReplicationManager (const FT_ReplicationManager & rhs); @@ -433,31 +425,16 @@ namespace TAO // Data Members private: - /** - * Protect internal state. - * Mutex should be locked by corba methods, or by - * external (public) methods before calling implementation - * methods. - * Implementation methods should assume the mutex is - * locked if necessary. - */ - ACE_SYNCH_MUTEX internals_; - typedef ACE_Guard<ACE_SYNCH_MUTEX> InternalGuard; - /// The orb CORBA::ORB_var orb_; /// The POA. PortableServer::POA_var poa_; - // The ORB's IORManipulation object - TAO_IOP::TAO_IOR_Manipulation_var iorm_; - /// A file to which the factory's IOR should be written. const char * ior_output_file_; /// A name to be used to register the factory with the name service. - //@@ Are *all* of these needed? const char * ns_name_; CosNaming::NamingContext_var naming_context_; CosNaming::Name this_name_; @@ -470,7 +447,6 @@ namespace TAO /// The ObjectGroupManager that implements the functionality /// necessary for application-controlled object group membership. -// TAO::PG_ObjectGroupManager object_group_manager_; TAO_PG_ObjectGroupManager object_group_manager_; /// The PropertyManager that is reponsible for parsing all criteria, @@ -481,13 +457,22 @@ namespace TAO TAO_PG_GenericFactory generic_factory_; + // @@ The PortableGroup::ObjectGroupManager contains information about object groups + // in a TAO_PG_ObjectGroup_Map object. Unfortunatly this doesn't contain + // then information necessary to manage IOGRs. Originally I planned to extend that + // structure to support fault tolerance, but I ran into a large number of side effects + // as I changed that structure, so as an interim step I defined a new collection: + // TAO::PG_Object_Group_Map. The similarity in names is intentional. I still hope + // to replace the TAO_PG_ObjectGroup_Map int the ObjectGroupManager a with TAO::PG_Object_Group_Map + // but not right now. Dale Wilson wilson_d@ociweb.com /// A container for our object group information TAO::PG_Object_Group_Map object_group_map_; /// The fault notifier. FT::FaultNotifier_var fault_notifier_; - const char * fault_notifier_ior_; + /// set by command line -f option + const char * fault_notifier_ior_string_; /// The fault consumer. TAO::FT_FaultConsumer fault_consumer_; diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp index 3dfa661484a..8e691ebb294 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp @@ -22,8 +22,6 @@ #include <tao/debug.h> #include <iostream> -#define INTEGRATED_WITH_REPLICATION_MANAGER 1 - ACE_RCSID (FT_ReplicationManagerFaultAnalyzer, FT_ReplicationManagerFaultAnalyzer, "$Id$") @@ -63,9 +61,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event ( const CosNotification::FilterableEventBody & filterable = event.filterable_data; CORBA::ULong item_count = filterable.length (); -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { for (CORBA::ULong n_prop = 0; n_prop < item_count; ++n_prop) { @@ -126,7 +122,6 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event ( } } -#if (INTEGRATED_WITH_REPLICATION_MANAGER == 1) // A specific object at a location failed. if ((result == 0) && (fault_event_desc.object_at_location_failed == 1)) { @@ -144,12 +139,9 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event ( { result = this->type_failure (fault_event_desc); } -#endif /* (INTEGRATED_WITH_REPLICATION_MANAGER == 1) */ // Debugging support. -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { fault_event_desc.dump (); } @@ -160,7 +152,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event ( // Extract a string type_id from CORBA::Any. // Caller owns the string returned via <type_id>. int TAO::FT_ReplicationManagerFaultAnalyzer::get_type_id ( - const CORBA::Any& val, FT::TypeId_out type_id) + const CORBA::Any& val, PortableGroup::TypeId_out type_id) { const char* type_id_value; if ((val >>= type_id_value) == 0) @@ -172,10 +164,6 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_type_id ( -1); } - std::cout << std::endl << std::endl << std::endl - << type_id_value - << std::endl << std::endl << std::endl; - // Make a deep copy of the TypeId string. type_id = CORBA::string_dup (type_id_value); return 0; @@ -183,9 +171,9 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_type_id ( // Extract the ObjectGroupId from CORBA::Any. int TAO::FT_ReplicationManagerFaultAnalyzer::get_object_group_id ( - const CORBA::Any& val, FT::ObjectGroupId& id) + const CORBA::Any& val, PortableGroup::ObjectGroupId& id) { - FT::ObjectGroupId temp_id = (FT::ObjectGroupId)0; + PortableGroup::ObjectGroupId temp_id = (PortableGroup::ObjectGroupId)0; if ((val >>= temp_id) == 0) { ACE_ERROR_RETURN ((LM_ERROR, @@ -199,9 +187,9 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_object_group_id ( } int TAO::FT_ReplicationManagerFaultAnalyzer::get_location ( - const CORBA::Any& val, FT::Location_out location) + const CORBA::Any& val, PortableGroup::Location_out location) { - const FT::Location* temp_loc; + const PortableGroup::Location* temp_loc; if ((val >>= temp_loc) == 0) { ACE_ERROR_RETURN ((LM_ERROR, @@ -211,7 +199,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_location ( -1); } // Make a deep copy of the Location. - ACE_NEW_RETURN (location, FT::Location (*temp_loc), -1); + ACE_NEW_RETURN (location, PortableGroup::Location (*temp_loc), -1); return 0; } @@ -222,25 +210,23 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_location ( // Get the MembershipStyle property. int TAO::FT_ReplicationManagerFaultAnalyzer::get_membership_style ( - const FT::Properties & properties, - FT::MembershipStyleValue & membership_style) + const PortableGroup::Properties & properties, + PortableGroup::MembershipStyleValue & membership_style) { - FT::Name prop_name (1); + PortableGroup::Name prop_name (1); prop_name.length (1); prop_name[0].id = CORBA::string_dup (FT::FT_MEMBERSHIP_STYLE); int result = 0; - FT::Value value; + PortableGroup::Value value; if (TAO_PG::get_property_value (prop_name, properties, value) && ((value >>= membership_style) == 1)) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( - "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: " + "TAO::FT_ReplicationManagerFaultAnalyzer::get_membership_style: " "MembershipStyle is <%d>:\n"), membership_style )); @@ -255,25 +241,23 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_membership_style ( } int TAO::FT_ReplicationManagerFaultAnalyzer::get_replication_style ( - const FT::Properties & properties, + const PortableGroup::Properties & properties, FT::ReplicationStyleValue & replication_style) { - FT::Name prop_name (1); + PortableGroup::Name prop_name (1); prop_name.length (1); prop_name[0].id = CORBA::string_dup (FT::FT_REPLICATION_STYLE); int result = 0; - FT::Value value; + PortableGroup::Value value; if (TAO_PG::get_property_value (prop_name, properties, value) && ((value >>= replication_style) == 1)) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( - "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: " + "TAO::FT_ReplicationManagerFaultAnalyzer::get_replication_style: " "ReplicationStyle is <%d>:\n"), replication_style )); @@ -288,25 +272,23 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_replication_style ( } int TAO::FT_ReplicationManagerFaultAnalyzer::get_minimum_number_members ( - const FT::Properties & properties, - FT::MinimumNumberMembersValue & minimum_number_members) + const PortableGroup::Properties & properties, + PortableGroup::MinimumNumberMembersValue & minimum_number_members) { - FT::Name prop_name (1); + PortableGroup::Name prop_name (1); prop_name.length (1); prop_name[0].id = CORBA::string_dup (FT::FT_MINIMUM_NUMBER_MEMBERS); int result = 0; - FT::Value value; + PortableGroup::Value value; if (TAO_PG::get_property_value (prop_name, properties, value) && ((value >>= minimum_number_members) == 1)) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( - "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: " + "TAO::FT_ReplicationManagerFaultAnalyzer::get_minimum_number_members: " "MinimumNumberMembers is <%d>:\n"), minimum_number_members )); @@ -321,25 +303,23 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_minimum_number_members ( } int TAO::FT_ReplicationManagerFaultAnalyzer::get_initial_number_members ( - const FT::Properties & properties, - FT::InitialNumberMembersValue & initial_number_members) + const PortableGroup::Properties & properties, + PortableGroup::InitialNumberMembersValue & initial_number_members) { - FT::Name prop_name (1); + PortableGroup::Name prop_name (1); prop_name.length (1); prop_name[0].id = CORBA::string_dup (FT::FT_INITIAL_NUMBER_MEMBERS); int result = 0; - FT::Value value; + PortableGroup::Value value; if (TAO_PG::get_property_value (prop_name, properties, value) && ((value >>= initial_number_members) == 1)) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( - "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: " + "TAO::FT_ReplicationManagerFaultAnalyzer::get_initial_number_members: " "InitialNumberMembers is <%d>:\n"), initial_number_members )); @@ -354,16 +334,16 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_initial_number_members ( } int TAO::FT_ReplicationManagerFaultAnalyzer::get_factories ( - const FT::Properties & properties, - FT::FactoryInfos_out factories) + const PortableGroup::Properties & properties, + PortableGroup::FactoryInfos_out factories) { - FT::Name prop_name (1); + PortableGroup::Name prop_name (1); prop_name.length (1); prop_name[0].id = CORBA::string_dup (FT::FT_FACTORIES); int result = 0; - FT::FactoryInfos_var temp_factories; - FT::Value value; + PortableGroup::FactoryInfos_var temp_factories; + PortableGroup::Value value; if (TAO_PG::get_property_value (prop_name, properties, value) == 1) { if ((value >>= temp_factories) == 0) @@ -378,7 +358,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_factories ( else { // Make a deep copy of the Factories. - ACE_NEW_RETURN (factories, FT::FactoryInfos (temp_factories.in()), -1); + ACE_NEW_RETURN (factories, PortableGroup::FactoryInfos (temp_factories.in()), -1); result = 0; } } @@ -395,13 +375,13 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_factories ( } int TAO::FT_ReplicationManagerFaultAnalyzer::is_primary_member ( - FT::ObjectGroup_ptr iogr, - const FT::Location & location, + PortableGroup::ObjectGroup_ptr iogr, + const PortableGroup::Location & location, int & object_is_primary) { - //@@ Q: How do we determine if this was a primary that faulted? - //@@ A: Get the TagFTGroupTaggedComponent from the IOGR and search + // To determine if this was a primary that faulted: + // Get the TagFTGroupTaggedComponent from the IOGR and search // for the primary, using the TAO_FT_IOGR_Property helper class. // Then, compare the TypeId and Location of the failed object with // those of the primary. If they match, it was a primary fault. @@ -507,8 +487,8 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( TAO::FT_FaultEventDescriptor & fault_event_desc) { int result = 0; - FT::ObjectGroup_var the_object_group = FT::ObjectGroup::_nil(); - FT::Properties_var properties; + PortableGroup::ObjectGroup_var the_object_group = PortableGroup::ObjectGroup::_nil(); + PortableGroup::Properties_var properties; ACE_TRY_NEW_ENV { @@ -528,7 +508,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( "Could not get ObjectGroup reference from ObjectGroupId: <%Q>.\n"), fault_event_desc.object_group_id )); - ACE_THROW (PortableGroup::ObjectGroupNotFound ()); + ACE_TRY_THROW (PortableGroup::ObjectGroupNotFound ()); } // Get the properties associated with this ObjectGroup. @@ -552,7 +532,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( if (result == 0) { // Get the MembershipStyle property. - FT::MembershipStyleValue membership_style; + PortableGroup::MembershipStyleValue membership_style; result = this->get_membership_style (properties.in(), membership_style); if (result != 0) { @@ -567,9 +547,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( else { fault_event_desc.membership_style = membership_style; -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -596,9 +574,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( else { fault_event_desc.replication_style = replication_style; -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -610,7 +586,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( } // Get the MinimumNumberMembers property. - FT::MinimumNumberMembersValue minimum_number_members; + PortableGroup::MinimumNumberMembersValue minimum_number_members; result = this->get_minimum_number_members ( properties.in(), minimum_number_members); if (result != 0) @@ -626,9 +602,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( else { fault_event_desc.minimum_number_members = minimum_number_members; -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -640,7 +614,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( } // Get the InitialNumberMembers property. - FT::InitialNumberMembersValue initial_number_members; + PortableGroup::InitialNumberMembersValue initial_number_members; result = this->get_initial_number_members ( properties.in(), initial_number_members); if (result != 0) @@ -656,9 +630,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( else { fault_event_desc.initial_number_members = initial_number_members; -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -685,9 +657,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( } else { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -709,9 +679,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( fault_event_desc.replication_style == FT::WARM_PASSIVE || fault_event_desc.replication_style == FT::SEMI_ACTIVE)) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -730,14 +698,12 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( // If the MembershipStyle is FT::MEMB_INF_CTRL (infrastructure // controlled) and the primary has faulted, establish a new primary. // We get back a new object group. - FT::ObjectGroup_var new_object_group; + PortableGroup::ObjectGroup_var new_object_group; if ((result == 0) && (fault_event_desc.membership_style == FT::MEMB_INF_CTRL) && (fault_event_desc.object_is_primary == 1)) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -751,7 +717,10 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( the_object_group.in(), fault_event_desc, new_object_group.out()); - the_object_group = new_object_group; + if (result == 0) + { + the_object_group = new_object_group; + } } // If the MembershipStyle is FT::MEMB_INF_CTRL (infrastructure @@ -761,9 +730,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( if ((result == 0) && (fault_event_desc.membership_style == FT::MEMB_INF_CTRL)) { -#if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 6) -#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */ { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ( @@ -787,17 +754,17 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::single_replica_failure ( // Sets <new_iogr> and returns 0 on success. // Returns -1 on failure. int TAO::FT_ReplicationManagerFaultAnalyzer::set_new_primary ( - FT::ObjectGroup_ptr iogr, + PortableGroup::ObjectGroup_ptr iogr, TAO::FT_FaultEventDescriptor & fault_event_desc, - FT::ObjectGroup_out new_iogr) + PortableGroup::ObjectGroup_out new_iogr) { int result = 0; - new_iogr = FT::ObjectGroup::_nil (); + new_iogr = PortableGroup::ObjectGroup::_nil (); ACE_TRY_NEW_ENV { // Remove the old primary member from the object group. - FT::ObjectGroup_var temp_iogr = + PortableGroup::ObjectGroup_var temp_iogr = this->replication_manager_->remove_member ( iogr, fault_event_desc.location.in() @@ -805,7 +772,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::set_new_primary ( ACE_TRY_CHECK; // Get the locations of the remaining members of the object group. - FT::Locations_var locations = + PortableGroup::Locations_var locations = this->replication_manager_->locations_of_members ( temp_iogr.in() ACE_ENV_ARG_PARAMETER); @@ -847,18 +814,18 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::set_new_primary ( // Sets <new_iogr> and returns 0 on success. // Returns -1 on failure. int TAO::FT_ReplicationManagerFaultAnalyzer::add_members ( - FT::ObjectGroup_ptr iogr, + PortableGroup::ObjectGroup_ptr iogr, TAO::FT_FaultEventDescriptor & fault_event_desc, - FT::ObjectGroup_out new_iogr) + PortableGroup::ObjectGroup_out new_iogr) { int result = 0; - new_iogr = FT::ObjectGroup::_nil (); + new_iogr = PortableGroup::ObjectGroup::_nil (); ACE_TRY_NEW_ENV { // Get current number of members in object group // (same as number of locations). - FT::Locations_var locations = + PortableGroup::Locations_var locations = this->replication_manager_->locations_of_members ( iogr ACE_ENV_ARG_PARAMETER); @@ -914,7 +881,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::add_members ( // locations we can use to add members to this object group. // So, now we add new members until we reach // the value of the MinimumNumberMembers property. - FT::Location_var good_location; + PortableGroup::Location_var good_location; for (FT_Location_Set::iterator iter (valid_locations); iter.next (good_location.out()) && fault_event_desc.minimum_number_members > num_members; @@ -1070,7 +1037,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::type_failure ( ACE_TRY_CHECK; // Get type id of this object group. - FT::TypeId_var type_id = + PortableGroup::TypeId_var type_id = this->replication_manager_->type_id ( object_groups_at_location[i] ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; @@ -1079,7 +1046,6 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::type_failure ( if (ACE_OS::strcmp (type_id.in(), fault_event_desc.type_id.in()) == 0) { // Handle it as a single replica failure. - fault_event_desc.type_id = CORBA::string_dup (type_id.in()); result = this->single_replica_failure (fault_event_desc); } } @@ -1099,13 +1065,13 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::type_failure ( // Template instantiations. #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Unbounded_Set<FT::Location>; -template class ACE_Unbounded_Set_Iterator<FT::Location>; +template class ACE_Unbounded_Set<PortableGroup::Location>; +template class ACE_Unbounded_Set_Iterator<PortableGroup::Location>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Unbounded_Set<FT::Location> -#pragma instantiate ACE_Unbounded_Set_Iterator<FT::Location> +#pragma instantiate ACE_Unbounded_Set<PortableGroup::Location> +#pragma instantiate ACE_Unbounded_Set_Iterator<PortableGroup::Location> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h index 243740900b9..90e5e5434a2 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h @@ -38,14 +38,14 @@ namespace TAO class FT_ReplicationManager; struct FT_FaultEventDescriptor; - typedef ACE_Unbounded_Set<FT::Location> FT_Location_Set; + typedef ACE_Unbounded_Set<PortableGroup::Location> FT_Location_Set; /** * Replication Manager's fault analyzer. * */ class FT_ReplicationManagerFaultAnalyzer - : public TAO::FT_DefaultFaultAnalyzer + : public ::TAO::FT_DefaultFaultAnalyzer { public: @@ -100,38 +100,38 @@ namespace TAO /// Helper functions for fault analysis. // Extract the type id from a CORBA any. - int get_type_id (const CORBA::Any& val, FT::TypeId_out type_id); + int get_type_id (const CORBA::Any& val, PortableGroup::TypeId_out type_id); // Extract the ObjectGroupId from a CORBA any. - int get_object_group_id (const CORBA::Any& val, FT::ObjectGroupId& id); + int get_object_group_id (const CORBA::Any& val, PortableGroup::ObjectGroupId& id); - // Extract the FT::Location from a CORBA any. - int get_location (const CORBA::Any& val, FT::Location_out location); + // Extract the PortableGroup::Location from a CORBA any. + int get_location (const CORBA::Any& val, PortableGroup::Location_out location); // Get the MembershipStyle property. int get_membership_style ( - const FT::Properties & properties, - FT::MembershipStyleValue & membership_style); + const PortableGroup::Properties & properties, + PortableGroup::MembershipStyleValue & membership_style); // Get the ReplicationStyle property. int get_replication_style ( - const FT::Properties & properties, + const PortableGroup::Properties & properties, FT::ReplicationStyleValue & replication_style); // Get the MinimumNumberMembers property. int get_minimum_number_members ( - const FT::Properties & properties, - FT::MinimumNumberMembersValue & minimum_number_members); + const PortableGroup::Properties & properties, + PortableGroup::MinimumNumberMembersValue & minimum_number_members); // Get the InitialNumberMembers property. int get_initial_number_members ( - const FT::Properties & properties, - FT::InitialNumberMembersValue & initial_number_members); + const PortableGroup::Properties & properties, + PortableGroup::InitialNumberMembersValue & initial_number_members); // Get the Factories property. int get_factories ( - const FT::Properties & properties, - FT::FactoryInfos_out factories); + const PortableGroup::Properties & properties, + PortableGroup::FactoryInfos_out factories); // Handle a single replica failure. int single_replica_failure ( @@ -146,29 +146,29 @@ namespace TAO TAO::FT_FaultEventDescriptor & fault_event_desc); // Is the replica at location the primary member of its ObjectGroup? - // Sets <is_primary> and returns 0 on success. + // Sets <object_is_primary> and returns 0 on success. // Returns -1 on failure. int is_primary_member ( - const FT::ObjectGroup_ptr iogr, - const FT::Location & location, + const PortableGroup::ObjectGroup_ptr iogr, + const PortableGroup::Location & location, int & object_is_primary); // Choose a new primary member for the ObjectGroup. // Sets <new_iogr> and returns 0 on success. // Returns -1 on failure. int set_new_primary ( - FT::ObjectGroup_ptr iogr, + PortableGroup::ObjectGroup_ptr iogr, TAO::FT_FaultEventDescriptor & fault_event_desc, - FT::ObjectGroup_out new_iogr); + PortableGroup::ObjectGroup_out new_iogr); // While the number of members in the object group is less than // the MinimumNumberMembers property, add new members. // Sets <new_iogr> and returns 0 on success. // Returns -1 on failure. int add_members ( - FT::ObjectGroup_ptr iogr, + PortableGroup::ObjectGroup_ptr iogr, TAO::FT_FaultEventDescriptor & fault_event_desc, - FT::ObjectGroup_out new_iogr); + PortableGroup::ObjectGroup_out new_iogr); /////////////// diff --git a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp index f61f5e3c22e..0d145325908 100644 --- a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp +++ b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp @@ -446,7 +446,7 @@ void TAO::FT_FaultDetectorFactory_i::remove_detector(CORBA::ULong id, TAO::Fault // FT_FaultDetectorFactory_i CORBA methods void TAO::FT_FaultDetectorFactory_i::change_properties ( - const FT::Properties & property_set + const PortableGroup::Properties & property_set ACE_ENV_ARG_DECL ) ACE_THROW_SPEC (( @@ -500,8 +500,8 @@ void TAO::FT_FaultDetectorFactory_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) CORBA::Object_ptr TAO::FT_FaultDetectorFactory_i::create_object ( const char * type_id, - const FT::Criteria & the_criteria, - FT::GenericFactory::FactoryCreationId_out factory_creation_id + const PortableGroup::Criteria & the_criteria, + PortableGroup::GenericFactory::FactoryCreationId_out factory_creation_id ACE_ENV_ARG_DECL ) ACE_THROW_SPEC (( @@ -573,7 +573,7 @@ CORBA::Object_ptr TAO::FT_FaultDetectorFactory_i::create_object ( // missingParameterName = ::FT::FT_DOMAIN_ID; } - FT::Location * object_location = 0; + PortableGroup::Location * object_location = 0; if (! ::TAO_PG::find (decoder, ::FT::FT_LOCATION, object_location) ) { object_location = & this->location_; @@ -586,7 +586,7 @@ CORBA::Object_ptr TAO::FT_FaultDetectorFactory_i::create_object ( // missingParameterName = ::FT::FT_LOCATION; } - FT::TypeId object_type = 0; + PortableGroup::TypeId object_type = 0; const char * object_type_string; if (::TAO_PG::find (decoder, ::FT::FT_TYPE_ID, object_type_string)) { @@ -662,7 +662,7 @@ CORBA::Object_ptr TAO::FT_FaultDetectorFactory_i::create_object ( } void TAO::FT_FaultDetectorFactory_i::delete_object ( - const FT::GenericFactory::FactoryCreationId & factory_creation_id + const PortableGroup::GenericFactory::FactoryCreationId & factory_creation_id ACE_ENV_ARG_DECL ) ACE_THROW_SPEC (( diff --git a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h index 40b0304a8bb..a6bd20f11f6 100644 --- a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h +++ b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h @@ -158,7 +158,7 @@ namespace TAO /////////////////////////////////////////////// // CORBA interface FaultDetectorFactory methods virtual void change_properties ( - const FT::Properties & property_set + const PortableGroup::Properties & property_set ACE_ENV_ARG_DECL ) ACE_THROW_SPEC (( @@ -175,8 +175,8 @@ namespace TAO // CORBA interface GenericFactory methods virtual CORBA::Object_ptr create_object ( const char * type_id, - const FT::Criteria & the_criteria, - FT::GenericFactory::FactoryCreationId_out factory_creation_id + const PortableGroup::Criteria & the_criteria, + PortableGroup::GenericFactory::FactoryCreationId_out factory_creation_id ACE_ENV_ARG_DECL ) ACE_THROW_SPEC (( @@ -189,7 +189,7 @@ namespace TAO )); virtual void delete_object ( - const FT::GenericFactory::FactoryCreationId & factory_creation_id + const PortableGroup::GenericFactory::FactoryCreationId & factory_creation_id ACE_ENV_ARG_DECL ) ACE_THROW_SPEC (( diff --git a/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp b/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp index 6acf648597d..7795ecf6cb2 100644 --- a/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp +++ b/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp @@ -37,9 +37,9 @@ TAO::Fault_Detector_i::Fault_Detector_i ( FT::FaultNotifier_ptr & notifier, FT::PullMonitorable_ptr & monitorable, FT::FTDomainId domain_id, - const FT::Location & object_location, - FT::TypeId object_type, - FT::ObjectGroupId group_id + const PortableGroup::Location & object_location, + PortableGroup::TypeId object_type, + PortableGroup::ObjectGroupId group_id ) : factory_(factory) , id_(id) diff --git a/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.h b/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.h index bed17f8cabf..caac2690042 100644 --- a/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.h +++ b/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.h @@ -71,9 +71,9 @@ namespace TAO FT::FaultNotifier_ptr & notifier, FT::PullMonitorable_ptr & monitorable, FT::FTDomainId domain_id, - const FT::Location & object_location, - FT::TypeId object_type, - FT::ObjectGroupId group_id + const PortableGroup::Location & object_location, + PortableGroup::TypeId object_type, + PortableGroup::ObjectGroupId group_id ); /** * destructor. @@ -162,9 +162,9 @@ namespace TAO * Data for the notification message. */ FT::FTDomainId domain_id_; - FT::Location object_location_; - FT::TypeId object_type_; - FT::ObjectGroupId group_id_; + PortableGroup::Location object_location_; + PortableGroup::TypeId object_type_; + PortableGroup::ObjectGroupId group_id_; /** * An Event (in the Win32 sense) to implement interruptable sleep. diff --git a/TAO/orbsvcs/orbsvcs/FT_CORBA.idl b/TAO/orbsvcs/orbsvcs/FT_CORBA.idl index 34b8c050eb0..e8f0b60d804 100644 --- a/TAO/orbsvcs/orbsvcs/FT_CORBA.idl +++ b/TAO/orbsvcs/orbsvcs/FT_CORBA.idl @@ -62,44 +62,14 @@ module FT exception PrimaryNotSet {}; #ifdef FT_USES_PORTABLE_GROUP - ///////////////////////////////////////// - // The following typedefs "import" - // definitions from the PortableGroup module - // definitions into the FT module. - // This is an interim step during the process - // of having FT depend on the commmon - // of PortableGroup module rather than defining - // everything itself. - - // this typedef trick doesn't work for exceptions, so they must - // use the PortableGroup:: prefix - typedef PortableGroup::_TypeId _TypeId; - typedef PortableGroup::ObjectGroup ObjectGroup; - typedef PortableGroup::Name Name; - typedef PortableGroup::Value Value; - typedef PortableGroup::Property Property; - typedef PortableGroup::Properties Properties; - typedef PortableGroup::Location Location; - typedef PortableGroup::Locations Locations; - typedef PortableGroup::Criteria Criteria; - - typedef PortableGroup::FactoryInfo FactoryInfo; - typedef PortableGroup::FactoryInfos FactoryInfos; - typedef PortableGroup::MembershipStyleValue MembershipStyleValue; - - typedef PortableGroup::FactoriesValue FactoriesValue; - typedef PortableGroup::InitialNumberMembersValue InitialNumberMembersValue; - typedef PortableGroup::MinimumNumberMembersValue MinimumNumberMembersValue; - typedef PortableGroup::PropertyManager PropertyManager; - typedef PortableGroup::ObjectGroupManager ObjectGroupManager; - typedef PortableGroup::GenericFactory GenericFactory; - - // Specification of FTObjectGroupManager Interface - // which ReplicationManager Inherits + + /** + * FTObjectGroupManager Interface adds primary support to PortableGroup::ObjectGroupManager + */ interface FTObjectGroupManager : PortableGroup::ObjectGroupManager { - ObjectGroup set_primary_member(in ObjectGroup object_group, - in Location the_location) + ::PortableGroup::ObjectGroup set_primary_member(in ::PortableGroup::ObjectGroup object_group, + in ::PortableGroup::Location the_location) raises(PortableGroup::ObjectGroupNotFound, PortableGroup::MemberNotFound, PrimaryNotSet, @@ -118,8 +88,8 @@ module FT /// FT::MembershipStyle const string FT_MEMBERSHIP_STYLE = PortableGroup::PG_MEMBERSHIP_STYLE; - const MembershipStyleValue MEMB_APP_CTRL = PortableGroup::MEMB_APP_CTRL; - const MembershipStyleValue MEMB_INF_CTRL = PortableGroup::MEMB_INF_CTRL; + const PortableGroup::MembershipStyleValue MEMB_APP_CTRL = PortableGroup::MEMB_APP_CTRL; + const PortableGroup::MembershipStyleValue MEMB_INF_CTRL = PortableGroup::MEMB_INF_CTRL; /// FT::FaultMonitoringStyle const string FT_FAULT_MONITORING_STYLE = "org.omg.ft.FaultMonitoringStyle"; diff --git a/TAO/orbsvcs/orbsvcs/FT_FaultDetectorFactory.idl b/TAO/orbsvcs/orbsvcs/FT_FaultDetectorFactory.idl index 2e626c57449..b783eb46ace 100644 --- a/TAO/orbsvcs/orbsvcs/FT_FaultDetectorFactory.idl +++ b/TAO/orbsvcs/orbsvcs/FT_FaultDetectorFactory.idl @@ -94,20 +94,20 @@ module FT * The create_object requires the following criteria: * FT::Notifier Notifier * FT::PullMonitorable Monitorable - * FT::DomainId domain_id, - * FT::ObjectGroupId group_id, - * FT::Location object_location, - * FT::_TypeId object_type + * PortableGroup::DomainId domain_id, + * PortableGroup::ObjectGroupId group_id, + * PortableGroup::Location object_location, + * PortableGroup::_TypeId object_type */ - interface FaultDetectorFactory : GenericFactory, PullMonitorable + interface FaultDetectorFactory : ::PortableGroup::GenericFactory, PullMonitorable { /** * Adjust properties on-the-fly. * Applies to all FaultDetectors created by this factory. * @param property_set is a set of properties that (may) have new values. */ - void change_properties(in Properties property_set) - raises (PortableGroup::InvalidProperty); + void change_properties(in ::PortableGroup::Properties property_set) + raises (::PortableGroup::InvalidProperty); /** * Ask the Fault Detector Factory to come to an orderly end. diff --git a/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl b/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl index b6cb3572d39..8f36d6b135a 100644 --- a/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl +++ b/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl @@ -27,9 +27,9 @@ module FT exception InterfaceNotFound {}; // Specification of ReplicationManager Interface - interface ReplicationManager : PropertyManager, + interface ReplicationManager : ::PortableGroup::PropertyManager, FTObjectGroupManager, - GenericFactory + ::PortableGroup::GenericFactory { /** diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp index ef6c14fc78b..03140458ff7 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp @@ -18,11 +18,10 @@ TAO_PG_GenericFactory::TAO_PG_GenericFactory ( TAO_PG_ObjectGroupManager & object_group_manager, TAO_PG_PropertyManager & property_manager) : poa_ (), -// next_group_id_(0), object_group_manager_ (object_group_manager), property_manager_ (property_manager), factory_map_ (TAO_PG_MAX_OBJECT_GROUPS), - next_fcid_ (0), +// next_fcid_ (0), lock_ () { this->object_group_manager_.generic_factory (this); diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h index d7ae4be28fd..8b6b853fa64 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h @@ -196,10 +196,6 @@ private: /// Reference to the POA used to create object group references. PortableServer::POA_var poa_; - /// The GroupCreationId that will be assigned to the next object - /// group that is created. -// PortableGroup::ObjectGroupId next_group_id_; - /// Reference to the ObjectGroup map. TAO_PG_ObjectGroupManager & object_group_manager_; @@ -228,7 +224,7 @@ private: * addition to another value that makes it unique to a given Load * Balancer. */ - CORBA::ULong next_fcid_; +// CORBA::ULong next_fcid_; const char * domain_id_; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp index 7fabf33b073..979b399044f 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp @@ -8,6 +8,7 @@ #include <ace/Vector_T.h> #include <tao/PortableServer/ORB_Manager.h> #include <orbsvcs/PortableGroup/PG_Operators.h> // Borrow operator == on CosNaming::Name +#include <orbsvcs/PortableGroup/PG_Utils.h> /** * The single POA used to manage object groups @@ -41,11 +42,11 @@ TAO::PG_Object_Group::MemberInfo::MemberInfo ( TAO::PG_Object_Group::MemberInfo::~MemberInfo () { - if( ! CORBA::is_nil (factory_.in())) + if( ! CORBA::is_nil (this->factory_.in())) { ACE_TRY_NEW_ENV { - factory_->delete_object (factory_id_); + this->factory_->delete_object (this->factory_id_); } ACE_CATCHANY; { @@ -56,22 +57,85 @@ TAO::PG_Object_Group::MemberInfo::~MemberInfo () } } - TAO::PG_Object_Group::PG_Object_Group ( - CORBA::ORB_ptr orb, - PortableGroup::ObjectGroupId oid, + CORBA::ORB_ptr orb, + TAO_IOP::TAO_IOR_Manipulation_ptr iorm, + CORBA::Object_ptr empty_group, + const PortableGroup::TagGroupTaggedComponent & tagged_component, const char * type_id, PortableGroup::Criteria the_criteria) - : orb_ (CORBA::ORB::_duplicate (orb)) + : internals_() + , orb_ (CORBA::ORB::_duplicate (orb)) + , iorm_ (TAO_IOP::TAO_IOR_Manipulation::_duplicate(iorm)) + , empty_ (1) , role_ (type_id) - , type_id_ (CORBA::string_dup(type_id)) - , group_id_(oid) - , reference_ (0) + , tagged_component_ (tagged_component) + , reference_ (CORBA::Object::_duplicate(empty_group)) +// MemberMap members_ self initialized , primary_location_(0) , properties_ (the_criteria) + , membership_style_ (0) + , initial_number_members_ (0) + , minimum_number_members_ (0) +// group_specific_factories_ self initialized { } +//static +TAO::PG_Object_Group * TAO::PG_Object_Group::create ( + CORBA::ORB_ptr orb, + CORBA::Object_ptr empty_group, // empty group as created by ObjectManager + const char * type_id, + PortableGroup::Criteria the_criteria + ACE_ENV_ARG_DECL) +{ + //@@ Might be worthwhile making iorm_ static + // rather than resolving it for each new group. + TAO_IOP::TAO_IOR_Manipulation_var iorm; + // Get an object reference for the ORB's IORManipulation object. + CORBA::Object_var iorm_obj = orb->resolve_initial_references ( + TAO_OBJID_IORMANIPULATION ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + iorm = TAO_IOP::TAO_IOR_Manipulation::_narrow ( + iorm_obj.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + if (CORBA::is_nil (iorm.in ())) + { + if (TAO_debug_level > 3) + { + ACE_ERROR ( (LM_ERROR, + ACE_TEXT ( + "%T %n (%P|%t) - " + "Could not find an IOR Manipulator.\n"))); + } + return 0; + } + + // pick up the object group information as assigned by + // ObjectGroupManager + + PortableGroup::TagGroupTaggedComponent tagged_component; + + if (! TAO::PG_Utils::get_tagged_component (empty_group, tagged_component)) + { + ACE_THROW_RETURN (PortableGroup::ObjectGroupNotFound(), 0); + } + + TAO::PG_Object_Group * objectGroup = 0; + ACE_NEW_THROW_EX ( + objectGroup, + TAO::PG_Object_Group ( + orb, + iorm, + empty_group, + tagged_component, + type_id, + the_criteria), + CORBA::NO_MEMORY()); + return objectGroup; +} + + TAO::PG_Object_Group::~PG_Object_Group () { for (MemberMap_Iterator it = this->members_.begin(); @@ -80,7 +144,7 @@ TAO::PG_Object_Group::~PG_Object_Group () { MemberInfo * member = (*it).int_id_; delete member; - members_.unbind((*it).ext_id_); + this->members_.unbind((*it).ext_id_); } } @@ -88,7 +152,7 @@ TAO::PG_Object_Group::~PG_Object_Group () void dump_ior (const char * base, const char * ext, unsigned long version, const char * iogr) { char filename[1000]; - sprintf(filename, "%s_%lu.%s", base, version, ext ); + sprintf(filename, "%this->s_%lu.%s", base, version, ext ); FILE * iorfile = fopen(filename, "w"); fwrite (iogr, 1, strlen(iogr), iorfile); @@ -96,67 +160,6 @@ void dump_ior (const char * base, const char * ext, unsigned long version, const } -void TAO::PG_Object_Group::set_reference ( - PortableGroup::ObjectGroup_ptr reference, - PortableGroup::ObjectGroupRefVersion version, - int distribute - ACE_ENV_ARG_DECL) -{ - this->reference_ = PortableGroup::ObjectGroup::_duplicate (reference); - this->version_ = version; - this->IOGR_ = this->orb_->object_to_string (reference ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - if (distribute) - { - size_t n_rep = 0; // for dump_ior below - for ( MemberMap_Iterator it = members_.begin(); - it != members_.end(); - ++it) - { - MemberInfo const * info = (*it).int_id_; - // - // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface - // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_); - // but it doesn work: error message at replica is: - // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0] - // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed - // back to using _narrow - PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_); - if (! CORBA::is_nil (uog.in ()) ) - { - ACE_TRY_NEW_ENV - { - ACE_DEBUG ((LM_DEBUG, - "PG (%P|%t) - Object_Group pushing IOGR to %s member: %s@%s.\n", - (info->is_primary_ ? "Primary" : "Backup"), - this->role_.c_str(), - ACE_static_cast(const char *, info->location_[0].id) - )); - dump_ior ("group", "iogr", this->version_, this->IOGR_); - CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in() ACE_ENV_ARG_PARAMETER); - dump_ior (info->location_[0].id, "ior", (this->version_ * 100) + n_rep++, replica_ior); - - uog->tao_update_object_group (this->IOGR_, this->version_, info->is_primary_); - } - ACE_CATCHANY - { - // we expect an exception - // tao_update_object_group is not a real method - } - ACE_ENDTRY; - } - else - { - ACE_ERROR ((LM_ERROR, - "TAO::PG_Object_Group::set_reference can't narrow member reference to PortableGroup::TAO_UpdateObjectGroup.\n" - )); - } - } - } -} - - PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::reference()const { return PortableGroup::ObjectGroup::_duplicate (this->reference_); @@ -164,26 +167,33 @@ PortableGroup::ObjectGroup_ptr TAO::PG_Object_Group::reference()const void TAO::PG_Object_Group::set_membership_style (PortableGroup::MembershipStyleValue style) { + InternalGuard guard(this->internals_); this->membership_style_ = style; } PortableGroup::MembershipStyleValue TAO::PG_Object_Group::membership_style () const { + // const cast to simulate mutable + InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); return this->membership_style_; } void TAO::PG_Object_Group::initial_number_members (PortableGroup::InitialNumberMembersValue count) { + InternalGuard guard(this->internals_); this->initial_number_members_ = count; } PortableGroup::InitialNumberMembersValue TAO::PG_Object_Group::initial_number_members () const { + // const cast to simulate mutable + InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); return this->initial_number_members_; } void TAO::PG_Object_Group::set_minimum_number_members (PortableGroup::MinimumNumberMembersValue count) { + InternalGuard guard(this->internals_); this->minimum_number_members_ = count; } @@ -194,28 +204,117 @@ PortableGroup::MinimumNumberMembersValue TAO::PG_Object_Group::minimum_number_me void TAO::PG_Object_Group::set_group_specific_factories (const PortableGroup::FactoryInfos & infos) { + InternalGuard guard(this->internals_); this->group_specific_factories_ = infos; } void TAO::PG_Object_Group::group_specific_factories (PortableGroup::FactoryInfos & result) const { + // const cast to simulate mutable + InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); // copy is needed to have some semblance of thread safeness. // if performance is an issue avoid this method. result = this->group_specific_factories_; } -void TAO::PG_Object_Group::set_primary_location ( - const PortableGroup::Location & location - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((PortableGroup::MemberNotFound)) +const PortableGroup::Location & TAO::PG_Object_Group::primary_location() const +{ + // const cast to simulate mutable + InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); + return this->primary_location_; +} + +void TAO::PG_Object_Group::add_member ( + const PortableGroup::Location & the_location, + CORBA::Object_ptr member + ACE_ENV_ARG_PARAMETER) + ACE_THROW_SPEC ( (CORBA::SystemException, + PortableGroup::ObjectNotAdded)) + +{ + InternalGuard guard(this->internals_); + ///////////////////////////////////////// + // Convert the new member to a string IOR + // This keeps a clean IOR (not and IOGR!) + // while we add it to a group. We need a + // IORs, not IOGRs to send new IOGRs out + // to replicas. + + CORBA::String_var member_ior_string = orb_->object_to_string (member ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + //////////////////////////// + // @@ HACK ALERT + // The PortableGroup::ObjectGroupManager creates an object reference containing + // a dummy entry so it will have a place to store the tagged group component. + // If this is the first entry, we need to remove that entry once we have a *real* member. + // This can be avoided when we get support for TAG_MULTIPLE_COMPONENTS + // For now, we already have a copy of the tagGroupTagged component and we're going to use + // it below wen we increment the group version so we can clean out the dummy entry. + PortableGroup::ObjectGroup_var cleaned = this->reference_; + if (this->empty_) + { + // remove the original profile. It's a dummy entry supplied by create_object. + cleaned = + this->iorm_->remove_profiles (cleaned.in (), this->reference_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->empty_ = 0; + } + + // create a list of references to be merged + TAO_IOP::TAO_IOR_Manipulation::IORList iors (2); + iors.length (2); + iors [0] = cleaned.in(); + iors [1] = member; + + // Now merge the list into one new IOGR + PortableGroup::ObjectGroup_var new_reference = + this->iorm_->merge_iors (iors ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Object_var member_ior = this->orb_->string_to_object (member_ior_string ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + MemberInfo * info = 0; + ACE_NEW_THROW_EX (info, MemberInfo(member_ior, the_location), + CORBA::NO_MEMORY()); + + if (this->members_.bind (the_location, info) != 0) + { + ACE_THROW(CORBA::NO_MEMORY()); + } + + this->reference_ = new_reference; // note var-to-var assignment does a duplicate + + if (increment_version ()) + { + distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + else + { + ACE_THROW (PortableGroup::ObjectNotAdded()); + } +} + +int TAO::PG_Object_Group::set_primary_member ( + TAO_IOP::TAO_IOR_Property * prop, + const PortableGroup::Location & the_location + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , PortableGroup::MemberNotFound + )) { + InternalGuard guard(this->internals_); + int result = 1; MemberInfo * info; - if (this->members_.find (location, info) == 0) + if (this->members_.find (the_location, info) == 0) { int cleared = 0; - this->primary_location_ = location; + this->primary_location_ = the_location; for (MemberMap_Iterator it = this->members_.begin(); !cleared && it != this->members_.end(); ++it) @@ -224,104 +323,106 @@ void TAO::PG_Object_Group::set_primary_location ( (*it).int_id_->is_primary_ = 0; } info->is_primary_ = 1; + + //remove primary + int sts = this->iorm_->is_primary_set (prop, this->reference_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + if (sts) + { + (void)this->iorm_->remove_primary_tag (prop, this->reference_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + + sts = this->iorm_->set_primary (prop, info->member_.in (), this->reference_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + if (! sts) + { + if (TAO_debug_level > 3) + { + ACE_ERROR ( (LM_ERROR, + ACE_TEXT ("%T %n (%P|%t) - Can't set primary in IOGR .\n") + )); + } + } + if (result ) + { + if (increment_version()) + { + distribute_iogr (); + ACE_CHECK_RETURN (0); + } + } } else { - ACE_DEBUG ((LM_DEBUG, - "TAO-PG (%P|%t) - set_primary_location throwing MemberNotFound.\n" - )); - ACE_THROW (PortableGroup::MemberNotFound()) - ACE_CHECK; + if (TAO_debug_level > 3) + { + + ACE_DEBUG ((LM_DEBUG, + "TAO-PG (%P|%t) - set_primary_location throwing MemberNotFound.\n" + )); + } + ACE_THROW_RETURN (PortableGroup::MemberNotFound(), 0); } + return result; } -const PortableGroup::Location & TAO::PG_Object_Group::primary_location() const -{ - return this->primary_location_; -} -#ifdef NOT_IMPLEMENTED -void TAO::PG_Object_Group::create_member ( - const PortableGroup::Location & the_location, - const char * type_id, - const PortableGroup::Criteria & the_criteria +void TAO::PG_Object_Group::remove_member ( + const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberAlreadyPresent, - PortableGroup::ObjectNotCreated, - PortableGroup::InvalidCriteria, - PortableGroup::CannotMeetCriteria)) + ACE_THROW_SPEC ( (CORBA::SystemException, + PortableGroup::MemberNotFound)) { - ACE_ASSERT(0); - int todo; -} -#endif + InternalGuard guard(this->internals_); + MemberInfo * info; + if (this->members_.unbind (the_location, info) == 0) + { + if (this->members_.current_size() > 0) + { + this->reference_ = + this->iorm_->remove_profiles (this->reference_.in (), info->member_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + empty_ = 1; + } -void TAO::PG_Object_Group::add_member ( - const PortableGroup::Location & the_location, - CORBA::Object_ptr member - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberAlreadyPresent, - PortableGroup::ObjectNotAdded)) -{ - MemberInfo * info = 0; - ACE_NEW_THROW_EX (info, MemberInfo(member, the_location), - CORBA::NO_MEMORY()); + delete info; - if (members_.bind (the_location, info) != 0) - { - ACE_THROW(CORBA::NO_MEMORY()); - ACE_CHECK; - } -} + if (the_location == this->primary_location_) + { + this->primary_location_.length(0); + } -#ifdef NOT_IMPLEMENTED -void TAO::PG_Object_Group::remove_member ( - const PortableGroup::Location & the_location - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberNotFound)) -{ - ACE_ASSERT(0); - int todo; -} -#endif + if (increment_version ()) + { + distribute_iogr (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } -#ifdef NOT_IMPLEMENTED -void TAO::PG_Object_Group::locations_of_members ( - PortableGroup::Locations & locations - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - ACE_ASSERT(0); - int todo; -} -#endif + } + else + { + if (TAO_debug_level > 6) + { -PortableGroup::ObjectGroupId TAO::PG_Object_Group::get_object_group_id () const -{ - return this->group_id_; + ACE_DEBUG ((LM_DEBUG, + "TAO-PG (%P|%t) - remove_member throwing MemberNotFound.\n" + )); + } + ACE_THROW (PortableGroup::MemberNotFound() ); + } } -#ifdef NOT_IMPLEMENTED -CORBA::Object_ptr TAO::PG_Object_Group::get_member_ref ( - const PortableGroup::Location & loc - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberNotFound)) +PortableGroup::ObjectGroupId TAO::PG_Object_Group::get_object_group_id () const { - CORBA::Object_ptr result = CORBA::Object::_nil(); - ACE_ASSERT(0); - int todo; - return result; + // const cast to simulate mutable + InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); + return this->tagged_component_.object_group_id; } -#endif void TAO::PG_Object_Group::set_properties_dynamically ( const PortableGroup::Properties & overrides @@ -330,6 +431,7 @@ void TAO::PG_Object_Group::set_properties_dynamically ( PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { + InternalGuard guard(this->internals_); this->properties_ = overrides; //@@ int todo_parse_properties_for_special_value; //@@ int todo_override_rather_than_replace_question; @@ -337,16 +439,142 @@ void TAO::PG_Object_Group::set_properties_dynamically ( void TAO::PG_Object_Group::get_properties (PortableGroup::Properties_var & result) const { + // const cast to simulate mutable + InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); (*result) = this->properties_; } PortableGroup::TypeId TAO::PG_Object_Group::get_type_id () const { + // const cast to simulate mutable + InternalGuard guard(ACE_const_cast (TAO::PG_Object_Group *, this)->internals_); return CORBA::string_dup(this->type_id_); } +/////////////////// +// Internal method + +int TAO::PG_Object_Group::increment_version () +{ + // assume internals is locked + int result = 0; + this->tagged_component_.object_group_ref_version += 1; + if (TAO_debug_level > 3) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("%T %n (%P|%t) - Setting IOGR version to %u\n"), + ACE_static_cast(unsigned, this->tagged_component_.object_group_ref_version) + )); + } + + // Set the version + if ( TAO::PG_Utils::set_tagged_component (this->reference_, this->tagged_component_) ) + { + result = 1; + } + return result; +} + + +////////////////// +// Internal method +void TAO::PG_Object_Group::distribute_iogr (ACE_ENV_ARG_DECL) +{ + // assume internals is locked + CORBA::String_var iogr = this->orb_->object_to_string (this->reference_.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + size_t n_rep = 0; // for dump_ior below + for ( MemberMap_Iterator it = this->members_.begin(); + it != this->members_.end(); + ++it) + { + MemberInfo const * info = (*it).int_id_; + // + // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface + // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_); + // but it doesn work: error message at replica is: + // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0] + // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed + // back to using _narrow + PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_); + if (! CORBA::is_nil (uog.in ()) ) + { + ACE_TRY_NEW_ENV + { + ACE_DEBUG ((LM_DEBUG, + "PG (%P|%t) - Object_Group pushing IOGR to %s member: %s@%s.\n", + (info->is_primary_ ? "Primary" : "Backup"), + this->role_.c_str(), + ACE_static_cast(const char *, info->location_[0].id) + )); + dump_ior ("group", "iogr", this->tagged_component_.object_group_ref_version, iogr); + CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in() ACE_ENV_ARG_PARAMETER); + dump_ior (info->location_[0].id, "ior", (this->tagged_component_.object_group_ref_version * 100) + n_rep++, replica_ior); + + uog->tao_update_object_group (iogr, this->tagged_component_.object_group_ref_version, info->is_primary_); + } + ACE_CATCHANY + { + // we expect an exception + // tao_update_object_group is not a real method + } + ACE_ENDTRY; + } + else + { + ACE_ERROR ((LM_ERROR, + "TAO::PG_Object_Group::set_reference can't narrow member reference to PortableGroup::TAO_UpdateObjectGroup.\n" + )); + } + } +} + +#if 0 // debug code +void TAO::PG_Object_Group::dump_membership (TAO_IOP::TAO_IOR_Manipulation_ptr iorm, const char * label, PortableGroup::ObjectGroup_ptr member) const +{ + FT::TagFTGroupTaggedComponent ft_tag_component; + TAO_FT_IOGR_Property prop (ft_tag_component); + if (iorm->is_primary_set (&prop, member)) + { + ACE_DEBUG ( (LM_DEBUG, + ACE_TEXT ("%T %n (%P|%t) - %s: PRIMARY member.\n"), + label + )); + } + else + { + ACE_DEBUG ( (LM_DEBUG, + ACE_TEXT ("%T %n (%P|%t) - %s: backup member.\n"), + label + )); + } + + PortableGroup::TagGroupTaggedComponent tag_component; + if (TAO::PG_Utils::get_tagged_component (member, tag_component)) + { + ACE_DEBUG ( (LM_DEBUG, + ACE_TEXT ("%T %n (%P|%t) - %s: Group: .") + ACE_TEXT (" version: %u\n"), + + label, + tag_component.object_group_ref_version + )); + } + else + { + ACE_DEBUG ( (LM_DEBUG, + ACE_TEXT ("%T %n (%P|%t) - %s: No group information found.\n"), + label + )); + } +} +#endif // debug code + + + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h index 89caed4f749..7a4c511e45c 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h @@ -38,7 +38,7 @@ namespace TAO #include <ace/Hash_Map_Manager_T.h> #include "PG_Location_Hash.h" #include "PG_Location_Equal_To.h" - +#include <tao/IORManipulation/IORC.h> ///////////////////// // Forward references @@ -102,14 +102,29 @@ namespace TAO TAO_PG_Location_Equal_To, MemberMapMutex> MemberMap_Iterator; - public: - /// Constructor - PG_Object_Group ( + /** + * Private constructor -- use static create method. + */ + private: + TAO::PG_Object_Group::PG_Object_Group ( CORBA::ORB_ptr orb, - PortableGroup::ObjectGroupId oid, + TAO_IOP::TAO_IOR_Manipulation_ptr iorm, + CORBA::Object_ptr empty_group, + const PortableGroup::TagGroupTaggedComponent & tag_component, const char * type_id, PortableGroup::Criteria the_criteria); + public: + /** + * Static creation method needed because exceptions can happen. + */ + static PG_Object_Group * create ( + CORBA::ORB_ptr orb, + CORBA::Object_ptr empty_group, // empty group as created by ObjectManager + const char * type_id, + PortableGroup::Criteria the_criteria + ACE_ENV_ARG_DECL); + /// Destructor ~PG_Object_Group (); @@ -124,16 +139,6 @@ namespace TAO void set_typeid (PortableGroup::TypeId type_id); - /// Set a reference to the group (IOGR) - /// @param reference the new IOGR for this group. - /// @param version of this IOGR - /// @param distribute bool if true, distribute IOGR to all members - void set_reference ( - PortableGroup::ObjectGroup_ptr reference, - PortableGroup::ObjectGroupRefVersion version, - int distribute - ACE_ENV_ARG_DECL); - /// return a duplicated reference to this group (IOGR) PortableGroup::ObjectGroup_ptr reference()const; @@ -155,18 +160,6 @@ namespace TAO void group_specific_factories (PortableGroup::FactoryInfos & result) const; /** - * Set the member at "location" to be primary. - * - * Note: primary location is a concept from FT CORBA. - * It doesn't hurt other PortableGroup-based services to - * have these two methods and the underlying members. - */ - void set_primary_location ( - const PortableGroup::Location & location - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((PortableGroup::MemberNotFound)); - - /** * get location of primary member */ const PortableGroup::Location & primary_location() const; @@ -177,74 +170,55 @@ namespace TAO */ PortableGroup::TypeId get_type_id ()const; + void set_properties_dynamically ( + const PortableGroup::Properties & overrides + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableGroup::InvalidProperty, + PortableGroup::UnsupportedProperty)); + void get_properties (PortableGroup::Properties_var & result) const; - ///////////////////////////////////////////// - // Applicable ObjectGroupManager(OGM) methods - // The following methods in OGM all have an object group as the - // first parameter. The OGM should implement these methods by finding - // the corresponding TAO_PG_Object_Group and delegating to these methods. -#ifdef NOT_IMPLEMENTED - void create_member ( - const PortableGroup::Location & the_location, - const char * type_id, - const PortableGroup::Criteria & the_criteria - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberAlreadyPresent, - PortableGroup::ObjectNotCreated, - PortableGroup::InvalidCriteria, - PortableGroup::CannotMeetCriteria)); -#endif - - void add_member ( - const PortableGroup::Location & the_location, + PortableGroup::ObjectGroupId get_object_group_id () const; + + /** + * Add a new member to the group. + * @param reference a group that the ObjectManager has already operated upon. + * @param the_location the location for the new member + * @param member_ior_string the IOR for the new memeber (expressed as a string.) + */ + void add_member ( + const PortableGroup::Location & the_location, CORBA::Object_ptr member - ACE_ENV_ARG_DECL) + ACE_ENV_ARG_PARAMETER) + ACE_THROW_SPEC ( (CORBA::SystemException, + PortableGroup::ObjectNotAdded)); + + + int set_primary_member ( + TAO_IOP::TAO_IOR_Property * prop, + const PortableGroup::Location & the_location + ACE_ENV_ARG_DECL) ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberAlreadyPresent, - PortableGroup::ObjectNotAdded)); + CORBA::SystemException + , PortableGroup::MemberNotFound + )); -#ifdef NOT_IMPLEMENTED void remove_member ( const PortableGroup::Location & the_location ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberNotFound)); -#endif - -#ifdef NOT_IMPLEMENTED - void locations_of_members ( - PortableGroup::Locations & locations - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)); -#endif - - PortableGroup::ObjectGroupId get_object_group_id () const; - -#ifdef NOT_IMPLEMENTED - CORBA::Object_ptr get_member_ref ( - const PortableGroup::Location & loc - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC (( - CORBA::SystemException, - PortableGroup::MemberNotFound)); -#endif + ACE_THROW_SPEC ( (CORBA::SystemException, + PortableGroup::MemberNotFound)); - void set_properties_dynamically ( - const PortableGroup::Properties & overrides - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableGroup::InvalidProperty, - PortableGroup::UnsupportedProperty)); ///////////////////////// // Implementation methods private: + int increment_version (); + void distribute_iogr (ACE_ENV_ARG_DECL); + + ///////////////////////// // Forbidden methods private: @@ -281,23 +255,35 @@ namespace TAO * Implementation methods should assume the mutex is * locked if necessary. */ - ACE_SYNCH_MUTEX internals_; - typedef ACE_Guard<ACE_SYNCH_MUTEX> InternalGuard; + TAO_SYNCH_MUTEX internals_; + typedef ACE_Guard<TAO_SYNCH_MUTEX> InternalGuard; CORBA::ORB_var orb_; + // The ORB's IORManipulation object + TAO_IOP::TAO_IOR_Manipulation_var iorm_; + + /// boolean true if empty group + int empty_; + ACE_CString role_; PortableGroup::TypeId type_id_; - PortableGroup::ObjectGroupId group_id_; + + /** + * the GroupTaggedComponent that defines this group + * contains: + * GIOP::Version component_version; + * TAO_String_Manager group_domain_id; + * PortableGroup::ObjectGroupId object_group_id; + * PortableGroup::ObjectGroupRefVersion object_group_ref_version; + */ + PortableGroup::TagGroupTaggedComponent tagged_component_; + /** * the reference (IOGR) to this group */ PortableGroup::ObjectGroup_var reference_; - CORBA::String_var IOGR_; - PortableGroup::ObjectGroupRefVersion version_; - - /** * The CORBA object id assigned to this object group @@ -309,6 +295,11 @@ namespace TAO PortableGroup::Location primary_location_; + // Miscellaneous properties passed to create_object when this group + // was initially created. To be used to create new members. + PortableGroup::Properties properties_; + + // Cached property information PortableGroup::MembershipStyleValue membership_style_; @@ -316,10 +307,6 @@ namespace TAO PortableGroup::MinimumNumberMembersValue minimum_number_members_; PortableGroup::FactoryInfos group_specific_factories_; - // Miscellaneous properties passed to create_object when this group - // was initially created. To be used to create new members. - PortableGroup::Properties properties_; - }; } // namespace TAO diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp index 246d4f96613..ae80e54c94f 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group_Map.cpp @@ -50,9 +50,13 @@ int TAO::PG_Object_Group_Map::find_group (PortableGroup::ObjectGroupId group_id, int TAO::PG_Object_Group_Map::find_group (PortableGroup::ObjectGroup_ptr object_group, ::TAO::PG_Object_Group *& group) const { + int result = 0; PortableGroup::TagGroupTaggedComponent tc; - TAO::PG_Utils::get_tagged_component (object_group, tc); - return find_group (tc.object_group_id, group); + if (TAO::PG_Utils::get_tagged_component (object_group, tc)) + { + result = find_group (tc.object_group_id, group); + } + return result; } int TAO::PG_Object_Group_Map::destroy_group (PortableGroup::ObjectGroupId group_id) diff --git a/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp b/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp index 0ae5d663b52..13d05d2d906 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp @@ -21,16 +21,13 @@ FTAPP::FT_Creator::FT_Creator () - : orb_ (0) - , registry_ior_ (0) - , registry_ (0) - , naming_context_ () + : registry_ior_ (0) , replication_manager_ (0) , have_replication_manager_ (0) , write_iors_ (0) , write_iogr_ (0) - , ns_register_ (1) , iogr_seq_ (0) + , ns_register_ (1) , prefix_ ("") { } @@ -132,22 +129,32 @@ void FTAPP::FT_Creator::usage(ostream & out)const -int FTAPP::FT_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) +int FTAPP::FT_Creator::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { - int result = 1; - this->orb_ = orb; + int result = 0; + this->orb_ = CORBA::ORB::_duplicate (orb); // if a factory IOR was specified on command line if ( this->registry_ior_ != 0) { - result = this->creator_.set_factory_registry(this->registry_ior_ ACE_ENV_ARG_PARAMETER); + CORBA::Object_var registry_obj = this->orb_->string_to_object (this->registry_ior_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + PortableGroup::FactoryRegistry_var registry = PortableGroup::FactoryRegistry::_narrow(registry_obj ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + if (! CORBA::is_nil (registry)) + { + result = this->creator_.set_factory_registry(registry.in()); + } + } + + if (result == 0) + { + result = this->creator_.init (orb ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); } - result = this->creator_.init (orb ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - if (this->ns_register_) + if (result == 0 && this->ns_register_) { CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); @@ -183,7 +190,7 @@ int FTAPP::FT_Creator::run (ACE_ENV_SINGLE_ARG_DECL) if (this->write_iogr_) { - CORBA::String_var iogr = this->orb_->object_to_string (group.in () ACE_ENV_ARG_PARAMETER); + CORBA::String_var iogr = this->orb_->object_to_string (group ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (1); char iogr_filename[1000]; @@ -227,9 +234,9 @@ int FTAPP::FT_Creator::run (ACE_ENV_SINGLE_ARG_DECL) } typeCount = this->unregister_roles_.size(); - for ( size_t nUnreg = 0; result == 0 && nUnreg < typeCount; ++nUnreg) + for ( nType = 0; result == 0 && nType < typeCount; ++nType) { - const char * role = this->unregister_roles_[nUnreg].c_str(); + const char * role = this->unregister_roles_[nType].c_str(); result = this->creator_.unregister_role (role); } @@ -277,7 +284,7 @@ main (int argc, char *argv[]) } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - template class ACE_Vector<ACE_CString>; + template ACE_Vector<ACE_CString>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) # pragma instantiate ACE_Vector<ACE_CString> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/tests/FT_App/FT_Creator.h b/TAO/orbsvcs/tests/FT_App/FT_Creator.h index 4b80f0279a6..c0ca6d8d2be 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_Creator.h +++ b/TAO/orbsvcs/tests/FT_App/FT_Creator.h @@ -38,7 +38,7 @@ namespace FTAPP // initialization int parse_args (int argc, char *argv[]); - int init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL); + int init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); //////////// // execution @@ -66,7 +66,6 @@ namespace FTAPP TAO::Object_Group_Creator creator_; CORBA::ORB_var orb_; const char * registry_ior_; - PortableGroup::FactoryRegistry_var registry_; StringVec create_roles_; StringVec unregister_roles_; diff --git a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp index 5d7c741da79..5372248bbab 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp @@ -49,28 +49,19 @@ static const char * criterion_initial_value = "INITIAL_VALUE"; // FT_ReplicaFactory_i Construction/destruction FT_ReplicaFactory_i::FT_ReplicaFactory_i () - : identity_ ("") - , orb_ (0) - , poa_ (0) - , object_id_ (0) -// ,ior_() - , ior_output_file_ (0) - , have_replication_manager_ (0) - , replication_manager_ (0) - , factory_registry_ior_ (0) + : ior_output_file_(0) + , factory_registry_ior_(0) , factory_registry_ (0) - , registered_ (0) - , test_output_file_ (0) + , registered_(0) , ns_name_(0) - , naming_context_ (0) - , this_name_ (1) -// , roles_() , location_("unknown") , quit_on_idle_(0) , unregister_by_location_(0) -// , replicas_() + , test_output_file_(0) , empty_slots_(0) , quit_requested_(0) + , have_replication_manager_(0) + , replication_manager_(0) { ACE_DEBUG((LM_DEBUG, "TestReplica type_id: %s\n", FT_TEST::_tc_TestReplica->id() )); // ACE_DEBUG((LM_DEBUG, "Hobbit type_id: %s\n", FT_TEST::_tc_Hobbit->id() )); @@ -278,14 +269,14 @@ int FT_ReplicaFactory_i::idle (int & result) -int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) { int result = 0; // ugly but effective TAO_debug_level++; - this->orb_ = CORBA::ORB::_duplicate (orb); + this->orb_ = orb; // Use the ROOT POA for now CORBA::Object_var poa_object = @@ -306,7 +297,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - if (CORBA::is_nil(this->poa_.in ())) + if (CORBA::is_nil(this->poa_)) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" (%P|%t) Unable to narrow the POA.\n")), @@ -341,8 +332,8 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) CORBA::Object_var reg_obj = this->orb_->string_to_object(factory_registry_ior_ ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - this->factory_registry_ = ::PortableGroup::FactoryRegistry::_narrow(reg_obj.in ()); - if (CORBA::is_nil(this->factory_registry_.in ())) + this->factory_registry_ = ::PortableGroup::FactoryRegistry::_narrow(reg_obj); + if (CORBA::is_nil(this->factory_registry_)) { ACE_ERROR (( LM_ERROR, "Can't resolve Factory Registry IOR %s\n", @@ -362,14 +353,14 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) ACE_TRY_CHECK; this->replication_manager_ = ::FT::ReplicationManager::_narrow(rm_obj.in() ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (!CORBA::is_nil (replication_manager_.in ())) + if (!CORBA::is_nil (replication_manager_)) { this->have_replication_manager_ = 1; // empty criteria ::PortableGroup::Criteria criteria; this->factory_registry_ = this->replication_manager_->get_factory_registry(criteria ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (CORBA::is_nil (this->factory_registry_.in ())) + if (CORBA::is_nil (this->factory_registry_)) { ACE_ERROR ((LM_ERROR,"ReplicaFactory: ReplicationManager failed to return FactoryRegistry. Factory will not be registered.\n" )); } @@ -378,7 +369,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { this->factory_registry_ = ::PortableGroup::FactoryRegistry::_narrow(rm_obj.in() ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (!CORBA::is_nil(this->factory_registry_.in ())) + if (!CORBA::is_nil(this->factory_registry_)) { ACE_DEBUG ((LM_DEBUG,"Found a FactoryRegistry DBA ReplicationManager\n" )); } @@ -397,7 +388,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) } - if ( ! CORBA::is_nil (this->factory_registry_.in ())) + if ( ! CORBA::is_nil (this->factory_registry_)) { size_t roleCount = roles_.size(); for (size_t nRole = 0; nRole < roleCount; ++nRole) @@ -405,7 +396,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) const char * roleName = this->roles_[nRole].c_str(); PortableGroup::FactoryInfo info; - info.the_factory = ::PortableGroup::GenericFactory::_narrow(this_obj.in ()); + info.the_factory = ::PortableGroup::GenericFactory::_narrow(this_obj); info.the_location.length(1); info.the_location[0].id = CORBA::string_dup(this->location_); info.the_criteria.length(1); @@ -504,7 +495,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) ACE_CHECK_RETURN (-1); ::CORBA::Object_var replica_obj = poa->servant_to_reference(replica ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - ::CORBA::String_var replicaIOR = this->orb_->object_to_string(replica_obj.in () ACE_ENV_ARG_PARAMETER); + ::CORBA::String_var replicaIOR = this->orb_->object_to_string(replica_obj ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); write_ior (this->test_output_file_, replicaIOR); } @@ -624,7 +615,6 @@ CORBA::Object_ptr FT_ReplicaFactory_i::create_object ( )) { METHOD_ENTRY(FT_ReplicaFactory_i::create_object); - ACE_UNUSED_ARG (type_id); InternalGuard guard (this->internals_); ::TAO_PG::Properties_Decoder decoder (the_criteria); @@ -651,6 +641,7 @@ CORBA::Object_ptr FT_ReplicaFactory_i::create_object ( // missingParameter = 1; // missingParameterName = PortableGroup::role_criterion; } + if (missingParameter) { ACE_ERROR ((LM_ERROR, @@ -762,9 +753,9 @@ void FT_ReplicaFactory_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) // competence-challenged compilers. #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - template class ACE_Vector<FT_TestReplica_i *>; - template class ACE_Guard<ACE_Mutex>; - template class ACE_Vector<ACE_CString>; + template ACE_Vector<FT_TestReplica_i *>; + template ACE_Guard<ACE_Mutex>; + template ACE_Vector<ACE_CString>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) # pragma instantiate ACE_Vector<FT_TestReplica_i *> # pragma instantiate ACE_Guard<ACE_Mutex> diff --git a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp index 0e2f8d3c32d..35fd0954596 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp @@ -34,40 +34,17 @@ TAO::Object_Group_Creator::~Object_Group_Creator () { } -int TAO::Object_Group_Creator::set_factory_registry ( const char * factory_ior) -{ - int result = 1; - - ACE_TRY_NEW_ENV - { - CORBA::Object_var registry_obj = this->orb_->string_to_object (factory_ior ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - this->registry_ = PortableGroup::FactoryRegistry::_narrow(registry_obj ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (! CORBA::is_nil (registry_)) - { - result = 0; // success - } - } - ACE_CATCHANY - { - result = 1; - } - ACE_ENDTRY; - return result; -} - int TAO::Object_Group_Creator::set_factory_registry (PortableGroup::FactoryRegistry_ptr factory) { - this->registry_ = factory; - return 0; + this->registry_ = PortableGroup::FactoryRegistry::_duplicate (factory); + return CORBA::is_nil (this->registry_.in()) ? -1 : 0 ; } -int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) +int TAO::Object_Group_Creator::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) { - int result = 1; - this->orb_ = orb; + int result = 0; + this->orb_ = CORBA::ORB::_duplicate(orb); if (CORBA::is_nil (this->registry_)) { @@ -104,7 +81,7 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) ACE_ERROR ((LM_ERROR, "%T %n (%P|%t) Object_Group_Creator: ReplicationManager failed to return FactoryRegistry.\n" )); - ACE_THROW (CORBA::NO_IMPLEMENT()); + ACE_TRY_THROW (CORBA::NO_IMPLEMENT()); } } else @@ -112,7 +89,7 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) ACE_ERROR ((LM_ERROR, "%T %n (%P|%t) Object_Group_Creator: resolve_initial_references for ReplicationManager failed.\n" )); - ACE_THROW (CORBA::OBJECT_NOT_EXIST()); + ACE_TRY_THROW (CORBA::OBJECT_NOT_EXIST()); } } ACE_CATCHANY @@ -152,15 +129,17 @@ int TAO::Object_Group_Creator::create_detector_for_replica ( { int result = 0; - CORBA::ULong detector_count = this->detector_infos_->length(); - for (CORBA::ULong n_detector = 0; result == 0 && n_detector < detector_count; ++n_detector) + if (this->have_replication_manager_) { - PortableGroup::FactoryInfo & info = (*this->detector_infos_)[n_detector]; - if ( info.the_location == location || n_detector + 1 == detector_count) + CORBA::ULong detector_count = this->detector_infos_->length(); + for (CORBA::ULong n_detector = 0; result == 0 && n_detector < detector_count; ++n_detector) { - TAO_PG::Properties_Encoder encoder; + PortableGroup::FactoryInfo & info = (*this->detector_infos_)[n_detector]; + if ( info.the_location == location || n_detector + 1 == detector_count) + { + TAO_PG::Properties_Encoder encoder; - PortableGroup::Value value; + PortableGroup::Value value; /* ////////////////// @@ -171,49 +150,50 @@ int TAO::Object_Group_Creator::create_detector_for_replica ( encoder.add(::FT::FT_NOTIFIER, value); */ - FT::PullMonitorable_ptr monitorable = FT::PullMonitorable::_narrow (replica); - value <<= monitorable; - encoder.add (::FT::FT_MONITORABLE, value); + FT::PullMonitorable_ptr monitorable = FT::PullMonitorable::_narrow (replica); + value <<= monitorable; + encoder.add (::FT::FT_MONITORABLE, value); - FT::FTDomainId domain_id = 0; - value <<= domain_id; - encoder.add (::FT::FT_DOMAIN_ID, value); + FT::FTDomainId domain_id = 0; + value <<= domain_id; + encoder.add (::FT::FT_DOMAIN_ID, value); - value <<= location; - encoder.add (::FT::FT_LOCATION, value); + value <<= location; + encoder.add (::FT::FT_LOCATION, value); - value <<= type_id; - encoder.add (::FT::FT_TYPE_ID, value); + value <<= type_id; + encoder.add (::FT::FT_TYPE_ID, value); - value <<= group_id; - encoder.add (::FT::FT_GROUP_ID, value); + value <<= group_id; + encoder.add (::FT::FT_GROUP_ID, value); - value <<= CORBA::string_dup (role); - encoder.add (PortableGroup::role_criterion, value); - - // allocate and populate the criteria - FT::Criteria_var criteria; - ACE_NEW_NORETURN (criteria, - FT::Criteria); - if (criteria.ptr() == 0) - { - ACE_ERROR((LM_ERROR, - "%T %n (%P|%t)Object_Group_Creater: Error cannot allocate criteria.\n" - )); - result = -1; - } - else - { - encoder.encode(criteria); - FT::GenericFactory::FactoryCreationId_var factory_creation_id; + value <<= CORBA::string_dup (role); + encoder.add (PortableGroup::role_criterion, value); - info.the_factory->create_object ( - type_id, - criteria.in(), - factory_creation_id - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - result = 1; + // allocate and populate the criteria + FT::Criteria_var criteria; + ACE_NEW_NORETURN (criteria, + FT::Criteria); + if (criteria.ptr() == 0) + { + ACE_ERROR((LM_ERROR, + "%T %n (%P|%t)Object_Group_Creater: Error cannot allocate criteria.\n" + )); + result = -1; + } + else + { + encoder.encode(criteria); + FT::GenericFactory::FactoryCreationId_var factory_creation_id; + + info.the_factory->create_object ( + type_id, + criteria.in(), + factory_creation_id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + result = 1; + } } } } @@ -286,7 +266,7 @@ CORBA::Object_ptr TAO::Object_Group_Creator::create_group( CORBA::Object_var created_obj = info.the_factory->create_object ( type_id.in(), info.the_criteria, - factory_creation_id + factory_creation_id.out() ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil()); if ( !CORBA::is_nil(created_obj) ) @@ -354,11 +334,14 @@ CORBA::Object_ptr TAO::Object_Group_Creator::create_group( } } - group = this->replication_manager_->add_member (group, - info.the_location, - created_obj - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (CORBA::Object::_nil()); + if (this->have_replication_manager_) + { + group = this->replication_manager_->add_member (group, + info.the_location, + created_obj + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil()); + } } else { @@ -368,7 +351,7 @@ CORBA::Object_ptr TAO::Object_Group_Creator::create_group( } } - if (first_location != 0) + if (first_location != 0 && this->have_replication_manager_) { group = this->replication_manager_->set_primary_member (group.in(), * first_location ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil()); diff --git a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h index 0a0bfc89f10..3dcfb698c76 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h @@ -39,12 +39,11 @@ namespace TAO ///////////////// // pre-init methods - int set_factory_registry ( const char * factory_ior); int set_factory_registry (PortableGroup::FactoryRegistry_ptr factory); ///////////////// // initialization - int init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL); + int init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); ///////////////// // functionality diff --git a/TAO/orbsvcs/tests/FT_App/replica.cmd b/TAO/orbsvcs/tests/FT_App/replica.cmd index 449984a33e9..6c242ad4a00 100755 --- a/TAO/orbsvcs/tests/FT_App/replica.cmd +++ b/TAO/orbsvcs/tests/FT_App/replica.cmd @@ -1,6 +1,6 @@ @if "%1a" == "a" goto error @if "%2a" == "a" goto error -release\ft_replica -o r1.ior -q -f none -l %1 -i %2 %3 %4 %5 %6 %7 %8 %9 +release\ft_replica -o %1.ior -q -f none -l %1 -i %2 %3 %4 %5 %6 %7 %8 %9 @goto end @:error @echo Usage %0 location role [options] diff --git a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl index d54dce3e5ac..e94f7427201 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl @@ -167,10 +167,10 @@ my($REG) = new PerlACE::Process (".$build_directory/ft_registry", "-o $registry_ my($FAC1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ior -f file://$registry_ior -l $location1 -i $species1 -q"); my($FAC2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -f file://$registry_ior -l $location2 -i $species1 -i $species2 -i $species3 -q -u"); my($FAC3) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory3_ior -f file://$registry_ior -l $location3 -i $species2 -q -u"); -#intermediate test: resolve factory IOR as file: url -#my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-f file://$registry_ior -t $species1 -t $species2 -t $species1 -k $species3"); -#ultimate test (for now): use ORBInitRef/RIR to find ReplicationManager (or factory registry DBA replication manager): -my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-ORBInitRef ReplicationManager=file://$registry_ior -t $species1 -t $species2 -t $species1 -k $species3"); +# resolve factory IOR as file: url +#my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-f file://$registry_ior -r $species1 -r $species2 -r $species1 -u $species3"); +# -n means no name service -i means write individual iors +my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-f file://$registry_ior -r $species1 -r $species2 -r $species1 -u $species3 -n -i"); my($CL1); my($CL2); @@ -195,7 +195,7 @@ $REG->Spawn (); print "TEST: waiting for registry's IOR\n" if ($verbose); if (PerlACE::waitforfile_timed ($registry_ior, 5) == -1) { - print STDERR "ERROR: cannot find file <$registry_ior>\n"; + print STDERR "TEST ERROR: cannot find file <$registry_ior>\n"; $REG->Kill (); $REG->TimedWait (1); exit 1; } @@ -208,7 +208,7 @@ $FAC1->Spawn (); print "TEST: waiting for factory 1's IOR\n" if ($verbose); if (PerlACE::waitforfile_timed ($factory1_ior, 5) == -1) { - print STDERR "ERROR: cannot find file <$factory1_ior>\n"; + print STDERR "TEST ERROR: cannot find file <$factory1_ior>\n"; $REG->Kill (); $REG->TimedWait (1); $FAC1->Kill (); $FAC1->TimedWait (1); exit 1; @@ -219,7 +219,7 @@ $FAC2->Spawn (); print "TEST: waiting for factory 2's IOR\n" if ($verbose); if (PerlACE::waitforfile_timed ($factory2_ior, 5) == -1) { - print STDERR "ERROR: cannot find file <$factory2_ior>\n"; + print STDERR "TEST ERROR: cannot find file <$factory2_ior>\n"; $FAC1->Kill (); $FAC1->TimedWait (1); $REG->Kill (); $REG->TimedWait (1); $FAC2->Kill (); $FAC2->TimedWait (1); @@ -231,7 +231,7 @@ $FAC3->Spawn (); print "TEST: waiting for factory 3's IOR\n" if ($verbose); if (PerlACE::waitforfile_timed ($factory3_ior, 5) == -1) { - print STDERR "ERROR: cannot find file <$factory3_ior>\n"; + print STDERR "TEST ERROR: cannot find file <$factory3_ior>\n"; $FAC1->Kill (); $FAC1->TimedWait (1); $FAC2->Kill (); $FAC2->TimedWait (1); $REG->Kill (); $REG->TimedWait (1); @@ -247,27 +247,27 @@ $CTR->Spawn (); print "TEST: waiting for Replica IOR files from object group creator\n" if ($verbose); if (PerlACE::waitforfile_timed ($replica1_ior, 5) == -1){ - print STDERR "ERROR: cannot find file <$replica1_ior>\n"; + print STDERR "TEST ERROR: cannot find file <$replica1_ior>\n"; $status = 1; } elsif (PerlACE::waitforfile_timed ($replica2_ior, 5) == -1){ - print STDERR "ERROR: cannot find file <$replica2_ior> \n"; + print STDERR "TEST ERROR: cannot find file <$replica2_ior> \n"; $status = 1; } elsif (PerlACE::waitforfile_timed ($replica3_ior, 5) == -1){ - print STDERR "ERROR: cannot find file <$replica3_ior> \n"; + print STDERR "TEST ERROR: cannot find file <$replica3_ior> \n"; $status = 1; } elsif (PerlACE::waitforfile_timed ($replica4_ior, 5) == -1){ - print STDERR "ERROR: cannot find file <$replica4_ior> \n"; + print STDERR "TEST ERROR: cannot find file <$replica4_ior> \n"; $status = 1; } elsif (PerlACE::waitforfile_timed ($replica5_ior, 5) == -1){ - print STDERR "ERROR: cannot find file <$replica5_ior> \n"; + print STDERR "TEST ERROR: cannot find file <$replica5_ior> \n"; $status = 1; } elsif (PerlACE::waitforfile_timed ($replica6_ior, 5) == -1){ - print STDERR "ERROR: cannot find file <$replica6_ior> \n"; + print STDERR "TEST ERROR: cannot find file <$replica6_ior> \n"; $status = 1; } @@ -283,7 +283,7 @@ if($status != 0){ print "\nTEST: wait for object group creator.\n" if ($verbose); $config = $CTR->WaitKill (5); if ($config != 0) { - print STDERR "ERROR: configuration manager returned $config\n"; + print STDERR "TEST ERROR: configuration manager returned $config\n"; $FAC3->Kill (); $FAC3->TimedWait (1); $FAC2->Kill (); $FAC2->TimedWait (1); $FAC1->Kill (); $FAC1->TimedWait (1); @@ -299,7 +299,7 @@ print "\nTEST: starting client " . $CL1->CommandLine . "\n" if ($verbose); $client = $CL1->SpawnWaitKill (60); if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; + print STDERR "TEST ERROR: client returned $client\n"; $status = 1; } @@ -307,7 +307,7 @@ print "\nTEST: starting client again " . $CL2->CommandLine . "\n" if ($verbose); $client2 = $CL2->SpawnWaitKill (60); if ($client2 != 0) { - print STDERR "ERROR: client returned $client2\n"; + print STDERR "TEST ERROR: client returned $client2\n"; $status = 1; } @@ -315,7 +315,7 @@ print "\nTEST: starting client, one more time with feeling " . $CL3->CommandLine $client3 = $CL3->SpawnWaitKill (60); if ($client3 != 0) { - print STDERR "ERROR: client returned $client3\n"; + print STDERR "TEST ERROR: client returned $client3\n"; $status = 1; } @@ -325,28 +325,28 @@ if ($client3 != 0) { print "\nTEST: wait for factory 1.\n" if ($verbose); $factory1 = $FAC1->WaitKill (30); if ($factory1 != 0) { - print STDERR "ERROR: replica returned $factory 1\n"; + print STDERR "TEST ERROR: replica returned $factory 1\n"; $status = 1; } print "\nTEST: wait for factory 2.\n" if ($verbose); $factory2 = $FAC2->WaitKill (30); if ($factory2 != 0) { - print STDERR "ERROR: factory 2 returned $factory2\n"; + print STDERR "TEST ERROR: factory 2 returned $factory2\n"; $status = 1; } print "\nTEST: wait for factory 3.\n" if ($verbose); $factory3 = $FAC3->WaitKill (30); if ($factory3 != 0) { - print STDERR "ERROR: factory 3 returned $factory3\n"; + print STDERR "TEST ERROR: factory 3 returned $factory3\n"; $status = 1; } print "\nTEST: wait for FactoryRegistry.\n" if ($verbose); $registry = $REG->WaitKill (30); if ($registry != 0) { - print STDERR "ERROR: FactoryRegistry returned $registry\n"; + print STDERR "TEST ERROR: FactoryRegistry returned $registry\n"; $status = 1; } |