diff options
author | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-10-25 17:59:13 +0000 |
---|---|---|
committer | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-10-25 17:59:13 +0000 |
commit | 2432afacffc3bb0cde564e1885eac8c098f748ef (patch) | |
tree | a36e3a3b56dfb680ef81132d4fac03cd3d072f0e | |
parent | c8f786a991e3cfa8e527c7a0a85134ffd9e1c493 (diff) | |
download | ATCD-2432afacffc3bb0cde564e1885eac8c098f748ef.tar.gz |
ChangeLogTag: Fri Oct 24 14:42:39 2003 Dale Wilson <wilson_d@ociweb.com>
30 files changed, 1750 insertions, 587 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index c542a85598f..0d29ea54406 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,66 @@ +Fri Oct 24 14:42:39 2003 Dale Wilson <wilson_d@ociweb.com> + + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp: + Fix logic error in shutdown that caused fini to be called twice. + Implement set_primary using IORManipulator (not working, yet) + add_member creates IOGR's (but not very well, so far) + + * orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp: + temporary patch for changed method name in RegistrationFactory + + * orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h: + * orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp: + Get FaultNotifier from ReplicationManager + Register with ReplicationManager:FactoryRegistry + + * orbsvcs/Fault_Notifier/FT_Notifier_i.h: + * orbsvcs/Fault_Notifier/FT_Notifier_i.cpp: + Register with ReplicationManager + + * orbsvcs/orbsvcs/PortableGroup.idl: + * orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h: + * orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp: + fix spelling error s/criteron/criterion/ + + * orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp: + Add a missing/needed CORBA::string_dup + + * orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp: + * orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h: + * orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp: + * orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h: + * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h: + * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp: + Fix race condition in managing factory creation ID. + After fix, ObjectGroupManager assigns object group ids + using full 64 bit PortableGroup::ObjectGroupId rather than + relying on GenericFactory to assign them. Factory + creation id is now a ObjectGroupId in an Any. + + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp: + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h: + * orbsvcs/tests/FT_App/FT_Creator.cpp: + * orbsvcs/tests/FT_App/FT_Creator.h: + * orbsvcs/tests/FT_App/FT_App.mpc: + Dump intermediate IOGRs as members are added. + split application main from ObjectGroupCreator object. + + * orbsvcs/tests/FT_App/run_test_detector.pl: + * orbsvcs/tests/FT_App/run_test_fault_consumer.pl: + * orbsvcs/tests/FT_App/run_test_registry.pl: + * orbsvcs/tests/FT_App/run_test_replication_mgr.pl: + * orbsvcs/tests/FT_App/run_test_rmregistry.pl: + add message to indicate client vs infrastructure reinvocation + switch to corbaloc addressing of ReplicationManager initial reference. + + * orbsvcs/tests/FT_App/run_test_rmnotifier.pl: + new test: test notifier registration with replication manager + * orbsvcs/tests/FT_App/run_test_iogr.pl: + new test. ft_create makes IOGRs + + These changes were made in the oci_haft branch. + Wed Oct 22 00:11:36 2003 Steve Totten <totten_s@ociweb.com> * orbsvcs/tests/FT_App/run_test_replication_mgr.pl: diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp index fa2d819be3a..79b26d690b1 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp @@ -315,8 +315,6 @@ int TAO::FT_ReplicationManager::fini (ACE_ENV_SINGLE_ARG_DECL) result = this->fault_consumer_.fini (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK_RETURN (-1); - this->quit_ = 1; - return result; } @@ -474,7 +472,7 @@ void TAO::FT_ReplicationManager::shutdown_i ( ACE_THROW_SPEC ((CORBA::SystemException)) { int result = 0; - result = this->fini (ACE_ENV_SINGLE_ARG_PARAMETER); + quit_ = 1; ACE_CHECK; // this->orb_->shutdown (0 ACE_ENV_SINGLE_ARG_PARAMETER); @@ -606,11 +604,27 @@ TAO::FT_ReplicationManager::set_primary_member ( , FT::BadReplicationStyle )) { - // Not yet implemented. + PortableGroup::ObjectGroup_var member = this->object_group_manager_.get_member_ref ( + object_group, + the_location + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (member) ) { - int _TODO_must_implement_set_primary_; + ACE_THROW (PortableGroup::MemberNotFound ()); + ACE_CHECK; } - return (FT::ObjectGroup::_nil ()); + FT::TagFTGroupTaggedComponent ft_tag_component; + TAO_FT_IOGR_Property prop (ft_tag_component); + if (! iorm_->set_primary (&prop, member, object_group ACE_ENV_ARG_PARAMETER)) + { + ACE_ERROR ((LM_ERROR, + "ReplicationManager::set_primary_member: Can't set primary in IOGR .\n" + )); + } + ACE_CHECK; + return object_group->_duplicate (object_group); } PortableGroup::ObjectGroup_ptr @@ -647,11 +661,44 @@ TAO::FT_ReplicationManager::add_member ( PortableGroup::MemberAlreadyPresent, PortableGroup::ObjectNotAdded)) { - return - this->object_group_manager_.add_member (object_group, - the_location, - member - ACE_ENV_ARG_PARAMETER); + ///////////////////////////////////////////// + // 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 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + iors [1] = member; + + // Now merge the list into one new IOGR + PortableGroup::ObjectGroup_var merged = + iorm_->merge_iors (iors ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + FT::TagFTGroupTaggedComponent ft_tag_component; + TAO_FT_IOGR_Property prop (ft_tag_component); + if (! iorm_->is_primary_set (&prop, merged.in () + ACE_ENV_ARG_PARAMETER) ) + { +#if 10 // DEBUG_DISABLE + ACE_CHECK; + if (! iorm_->set_primary (&prop, member, merged.in () ACE_ENV_ARG_PARAMETER)) + { + ACE_ERROR ((LM_ERROR, + "Can't set primary in IOGR after adding first replica.\n" + )); + } +#endif //DEBUG_DISABLE + } + ACE_CHECK; + + return merged._retn(); + } PortableGroup::ObjectGroup_ptr @@ -784,4 +831,3 @@ TAO::FT_ReplicationManager::delete_object ( ACE_ENV_ARG_PARAMETER); ACE_CHECK; } - diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp index 752e4df60b2..9667836fa9c 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp @@ -160,7 +160,7 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::get_type_id ( -1); } - std::cout << std::endl << std::endl << std::endl + std::cout << std::endl << std::endl << std::endl << type_id_value << std::endl << std::endl << std::endl; @@ -867,10 +867,15 @@ int TAO::FT_ReplicationManagerFaultAnalyzer::add_members ( fake_criteria ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; + + // @@ DLW SAYS: we need to find out the role played by this object + // group so we can use the correct set of factories. // Get the list of factories for the type of the failed replica. +// PortableGroup::FactoryInfos_var factories_by_type = + CORBA::String_var type_id; PortableGroup::FactoryInfos_var factories_by_type = - factory_registry->list_factories_by_type ( - fault_event_desc.type_id.in() ACE_ENV_ARG_PARAMETER); + factory_registry->list_factories_by_role ( + fault_event_desc.type_id.in(), type_id ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; // @@ -944,4 +949,3 @@ template class ACE_Unbounded_Set_Iterator<FT::Location>; #pragma instantiate ACE_Unbounded_Set_Iterator<FT::Location> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - diff --git a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp index a7ef0d43542..66b55475e01 100644 --- a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp +++ b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp @@ -41,16 +41,28 @@ return /* value goes here */ +// todo: find me a home +static const char * role_name = "FaultDetector"; + + ////////////////////////////////////////////////////// // FT_FaultDetectorFactory_i Construction/destruction TAO::FT_FaultDetectorFactory_i::FT_FaultDetectorFactory_i () - : ior_output_file_(0) - , ns_name_(0) - , quit_on_idle_(0) - , empty_slots_(0) - , quit_requested_(0) + : ior_output_file_ (0) + , ns_name_ (0) + , quit_on_idle_ (0) + , empty_slots_ (0) + , quit_requested_ (0) + , domain_ (CORBA::string_dup("default_domain")) + , location_ (1) + , rm_register_ (1) + , replication_manager_ (0) + , factory_registry_ (0) + , registered_ (0) { + this->location_.length(1); + this->location_[0].id = CORBA::string_dup("default_location"); } TAO::FT_FaultDetectorFactory_i::~FT_FaultDetectorFactory_i () @@ -108,16 +120,28 @@ int TAO::FT_FaultDetectorFactory_i::write_ior() int TAO::FT_FaultDetectorFactory_i::parse_args (int argc, char * argv[]) { - ACE_Get_Opt get_opts (argc, argv, "o:q"); + ACE_Get_Opt get_opts (argc, argv, "d:l:o:q"); int c; while ((c = get_opts ()) != -1) { switch (c) { + case 'd': + this->domain_ = CORBA::string_dup (get_opts.opt_arg ()); + break; + case 'l': + this->location_.length(1); + this->location_[0].id = CORBA::string_dup(get_opts.opt_arg ()); + break; case 'o': this->ior_output_file_ = get_opts.opt_arg (); break; + case 'r': + { + this->rm_register_ = ! this->rm_register_; + break; + } case 'q': { this->quit_on_idle_ = 1; @@ -129,7 +153,10 @@ int TAO::FT_FaultDetectorFactory_i::parse_args (int argc, char * argv[]) default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s" + " -d <FT Domain>" + " -l <FT Location>" " -o <iorfile>" + " -r <disable registering with replication manager>" " -q{uit on idle}" "\n", argv [0]), @@ -166,22 +193,6 @@ int TAO::FT_FaultDetectorFactory_i::idle (int & result) } -int TAO::FT_FaultDetectorFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) -{ - if (this->ior_output_file_ != 0) - { - ACE_OS::unlink (this->ior_output_file_); - this->ior_output_file_ = 0; - } - if (this->ns_name_ != 0) - { - this->naming_context_->unbind (this_name_ - ACE_ENV_ARG_PARAMETER); - this->ns_name_ = 0; - } - return 0; -} - int TAO::FT_FaultDetectorFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) { int result = 0; @@ -235,17 +246,83 @@ int TAO::FT_FaultDetectorFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (this->ior_output_file_ != 0) + this->identity_ = "FaultDetectorFactory"; + + /////////////////////////////// + // Register with ReplicationManager + if (this->rm_register_) { - this->identity_ = "file:"; - this->identity_ += this->ior_output_file_; - result = write_ior(); + ACE_TRY_NEW_ENV + { + CORBA::Object_var rm_obj = orb->resolve_initial_references("ReplicationManager" ACE_ENV_ARG_PARAMETER); + 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_)) + { + // capture the default notifier + this->notifier_ = this->replication_manager_->get_fault_notifier (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // register with ReplicationManager::RegistrationFactory + PortableGroup::Criteria criteria(0); + this->factory_registry_ = this->replication_manager_->get_factory_registry (criteria ACE_ENV_ARG_PARAMETER) + ACE_TRY_CHECK; + + if (! CORBA::is_nil(factory_registry_)) + { + PortableGroup::FactoryInfo info; + info.the_factory = ::PortableGroup::GenericFactory::_narrow(this_obj); + info.the_location = this->location_; + info.the_criteria.length(1); + info.the_criteria[0].nam.length(1); + info.the_criteria[0].nam[0].id = CORBA::string_dup(PortableGroup::role_criterion); + info.the_criteria[0].val <<= CORBA::string_dup(role_name); + + ACE_DEBUG ((LM_DEBUG, + "FaultDetector registering with ReplicationManager.\n" + )); + this->factory_registry_->register_factory( + role_name, + role_name, + info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "FaultDetector Registration complete.\n" + )); + this->registered_ = 1; + } + else + { + ACE_ERROR ((LM_ERROR,"FaultNotifier: ReplicationManager doesn't have RegistrationFactory.\n" )); + } + } + else + { + ACE_ERROR ((LM_ERROR,"FaultNotifier: Can't resolve ReplicationManager, It will not be registered.\n" )); + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "ReplicaFactory: Exception resolving ReplicationManager, and no -f option was given. Factory will not be registered.\n" ); + } + ACE_ENDTRY; } else { - // if no IOR file specified, - // then always try to register with name service - this->ns_name_ = "FT_FaultDetectorFactory"; + ACE_DEBUG ((LM_DEBUG, + "FaultNotifier: ReplicationManager registration disabled.\n" + )); + } + + if (this->ior_output_file_ != 0) + { + this->identity_ = "file:"; + this->identity_ += this->ior_output_file_; + write_ior(); } if (this->ns_name_ != 0) @@ -278,6 +355,23 @@ int TAO::FT_FaultDetectorFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) return result; } +int TAO::FT_FaultDetectorFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->ior_output_file_ != 0) + { + ACE_OS::unlink (this->ior_output_file_); + this->ior_output_file_ = 0; + } + if (this->ns_name_ != 0) + { + this->naming_context_->unbind (this_name_ + ACE_ENV_ARG_PARAMETER); + this->ns_name_ = 0; + } + return 0; +} + + CORBA::ULong TAO::FT_FaultDetectorFactory_i::allocate_id() { CORBA::ULong id = this->detectors_.size(); @@ -417,12 +511,19 @@ CORBA::Object_ptr TAO::FT_FaultDetectorFactory_i::create_object ( FT::FaultNotifier_ptr notifier; if (! ::TAO_PG::find (decoder, ::FT::FT_NOTIFIER, notifier) ) { - ACE_ERROR ((LM_ERROR, - "FaultDetectorFactory::create_object: Missing parameter %s\n", - ::FT::FT_NOTIFIER - )); - missingParameter = 1; - missingParameterName = ::FT::FT_NOTIFIER; + if (! CORBA::is_nil (this->notifier_)) + { + notifier = FT::FaultNotifier::_duplicate (this->notifier_); + } + else + { + ACE_ERROR ((LM_ERROR, + "FaultDetectorFactory::create_object: Missing parameter %s\n", + ::FT::FT_NOTIFIER + )); + missingParameter = 1; + missingParameterName = ::FT::FT_NOTIFIER; + } } FT::PullMonitorable_ptr monitorable; @@ -439,23 +540,27 @@ CORBA::Object_ptr TAO::FT_FaultDetectorFactory_i::create_object ( FT::FTDomainId domain_id = 0; if (! ::TAO_PG::find (decoder, ::FT::FT_DOMAIN_ID, domain_id) ) { - ACE_ERROR ((LM_ERROR, - "FaultDetectorFactory::create_object: Missing parameter %s\n", - ::FT::FT_DOMAIN_ID - )); - missingParameter = 1; - missingParameterName = ::FT::FT_DOMAIN_ID; + domain_id = this->domain_; + +// ACE_ERROR ((LM_ERROR, +// "FaultDetectorFactory::create_object: Missing parameter %s\n", +// ::FT::FT_DOMAIN_ID +// )); +// missingParameter = 1; +// missingParameterName = ::FT::FT_DOMAIN_ID; } - FT::Location * object_location; + FT::Location * object_location = 0; if (! ::TAO_PG::find (decoder, ::FT::FT_LOCATION, object_location) ) { - ACE_ERROR ((LM_ERROR, - "FaultDetectorFactory::create_object: Missing parameter %s\n", - ::FT::FT_LOCATION - )); - missingParameter = 1; - missingParameterName = ::FT::FT_LOCATION; + object_location = & this->location_; + +// ACE_ERROR ((LM_ERROR, +// "FaultDetectorFactory::create_object: Missing parameter %s\n", +// ::FT::FT_LOCATION +// )); +// missingParameter = 1; +// missingParameterName = ::FT::FT_LOCATION; } FT::TypeId object_type = 0; @@ -585,4 +690,3 @@ CORBA::Boolean TAO::FT_FaultDetectorFactory_i::is_alive (ACE_ENV_SINGLE_ARG_DECL # pragma instantiate ACE_Guard<ACE_SYNCH_MUTEX> # pragma instantiate auto_ptr<TAO::Fault_Detector_i>; #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - diff --git a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h index 4561860c82d..11e48d0f7f1 100644 --- a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h +++ b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.h @@ -33,6 +33,7 @@ namespace TAO // Includes needed by this header #include <ace/Vector_T.h> #include <orbsvcs/FT_FaultDetectorFactoryS.h> +#include <orbsvcs/FT_ReplicationManagerC.h> #include <ace/Thread_Manager.h> ///////////////////// @@ -128,7 +129,7 @@ namespace TAO int fini (ACE_ENV_SINGLE_ARG_DECL); /** - * Idle-time activity. + * Idle-time activity. * * @param result is set to process return code if return value is non-zero. * @return zero to continue; nonzero to exit @@ -236,7 +237,7 @@ namespace TAO typedef ACE_Guard<ACE_SYNCH_MUTEX> InternalGuard; /** - * The orb + * The orb */ CORBA::ORB_var orb_; @@ -276,6 +277,43 @@ namespace TAO int quit_on_idle_; /** + * the FT::Domain where we're operating + */ + PortableGroup::GroupDomainId domain_; + + /** + * the FT::Location within the domain + */ + PortableGroup::Location location_; + + /** + * the notifer to use by default + */ + + FT::FaultNotifier_var notifier_; + + /** + * bool: if true, register with ReplicationManager. + * default is true. -x turns it off. + */ + int rm_register_; + + /** + * the replication manager + */ + ::FT::ReplicationManager_var replication_manager_; + + /** + * bool: if true the registration with ReplicationManager was successful. + */ + int registered_; + + /** + * The factory registry with which to register. + */ + PortableGroup::FactoryRegistry_var factory_registry_; + + /** * A human-readable string to distinguish this from other Notifiers. */ ACE_CString identity_; @@ -287,13 +325,13 @@ namespace TAO /** * A vector of FaultDetectors. Note that the FaultDetector ID - * is an index into this vector. + * is an index into this vector. */ DetectorVec detectors_; /** - * count of empty entries in detectors_ - * Used to determine when the factory is idle, and to avoid + * count of empty entries in detectors_ + * Used to determine when the factory is idle, and to avoid * fruitless searches for empty slots. */ size_t empty_slots_; diff --git a/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp b/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp index 933e77fd05a..598b32772f4 100644 --- a/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp +++ b/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp @@ -48,6 +48,9 @@ TAO::FT_FaultNotifier_i::FT_FaultNotifier_i () , quit_on_idle_(0) , quitting_(0) , gone_(0) + , rm_register_(1) + , registered_(0) + , replication_manager_(0) { } @@ -113,7 +116,7 @@ int TAO::FT_FaultNotifier_i::write_ior() int TAO::FT_FaultNotifier_i::parse_args (int argc, char * argv[]) { - ACE_Get_Opt get_opts (argc, argv, "o:vq"); + ACE_Get_Opt get_opts (argc, argv, "o:rq"); int c; while ((c = get_opts ()) != -1) @@ -125,14 +128,14 @@ int TAO::FT_FaultNotifier_i::parse_args (int argc, char * argv[]) this->ior_output_file_ = get_opts.opt_arg (); break; } - case 'q': + case 'r': { - this->quit_on_idle_ = 1; + this->rm_register_ = ! this->rm_register_; break; } - case 'v': + case 'q': { - this->verbose_ = 1; + this->quit_on_idle_ = 1; break; } case '?': @@ -142,6 +145,8 @@ int TAO::FT_FaultNotifier_i::parse_args (int argc, char * argv[]) ACE_ERROR_RETURN ((LM_ERROR, "usage: %s" " -o <iorfile>" + " -r disable registration with ReplicationManager" + " -q(uit on idle)" "\n", argv [0]), -1); @@ -189,8 +194,28 @@ int TAO::FT_FaultNotifier_i::fini (ACE_ENV_SINGLE_ARG_DECL) this->ns_name_ = 0; } - int TODO_unregister_with_ReplicationManager; + if (this->registered_) + { + ACE_TRY + { + this->replication_manager_->register_fault_notifier(::FT::FaultNotifier::_nil ()); + ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG, + "FaultNotifier unregistered from ReplicationManager.\n" + )); + } + ACE_CATCHANY + { + ACE_DEBUG ((LM_DEBUG, + "FaultNotifier Can't unregistered from ReplicationManager.\n" + )); + // complain, but otherwise ignore this error + // RM may be down. + } + ACE_ENDTRY; + this->registered_ = 0; + } return 0; } @@ -231,7 +256,6 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); @@ -344,6 +368,54 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) result = -1; } // everything else happens when subscriber shows up + + /////////////////////////////// + // Register with ReplicationManager + if (this->rm_register_) + { + ACE_TRY_NEW_ENV + { + CORBA::Object_var rm_obj = orb->resolve_initial_references("ReplicationManager" ACE_ENV_ARG_PARAMETER); + 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_)) + { + // @@: should we check to see if there's already one registered? + FT::FaultNotifier_var notifier = FT::FaultNotifier::_narrow (this_obj); + if (! CORBA::is_nil (notifier)) + { + this->replication_manager_->register_fault_notifier(notifier.in ()); + ACE_DEBUG ((LM_DEBUG, + "FaultNotifier registered with ReplicationManager.\n" + )); + this->registered_ = 1; + } + else + { + ACE_ERROR ((LM_ERROR, + "Error: Registration failed. This is not a FaultNotifier (should not occur.)\n" + )); + } + } + else + { + ACE_ERROR ((LM_ERROR,"FaultNotifier: Can't resolve ReplicationManager, It will not be registered.\n" )); + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "ReplicaFactory: Exception resolving ReplicationManager, and no -f option was given. Factory will not be registered.\n" ); + } + ACE_ENDTRY; + } + else + { + ACE_DEBUG ((LM_DEBUG, + "FaultNotifier: ReplicationManager registration disabled.\n" + )); + } /////////////////////////////// // Set up and ready for action // publish our IOR @@ -356,12 +428,6 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) this->identity_ += this->ior_output_file_; result = write_ior(); } - else - { - // if no IOR file specified, - // then always try to register with name service - this->ns_name_ = "FT_FaultNotifier"; - } } if (result == 0) @@ -399,8 +465,6 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) } } - int TODO_register_with_ReplicationManager; - return result; } @@ -635,7 +699,7 @@ void TAO::FT_FaultNotifier_i::disconnect_consumer ( this->consumer_disconnects_ += 1; if (this->quit_on_idle_) { - if (! this->quitting_ + if (! this->quitting_ && this->consumer_connects_ == this->consumer_disconnects_) { ACE_ERROR((LM_ERROR, diff --git a/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.h b/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.h index 3981088720e..936b6f2fc02 100644 --- a/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.h +++ b/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.h @@ -35,6 +35,7 @@ namespace TAO #include <orbsvcs/FT_NotifierS.h> +#include <orbsvcs/FT_ReplicationManagerC.h> #include <orbsvcs/Notify/Notify_EventChannelFactory_i.h> #include <ace/Vector_t.h> @@ -171,7 +172,7 @@ namespace TAO typedef ACE_Guard<ACE_SYNCH_MUTEX> InternalGuard; /** - * The orb + * The orb */ CORBA::ORB_var orb_; @@ -206,6 +207,22 @@ namespace TAO CosNaming::Name this_name_; /** + * bool: if true, register with ReplicationManager. + * default is true. -r turns it off. + */ + int rm_register_; + + /** + * the replication manager + */ + ::FT::ReplicationManager_var replication_manager_; + + /** + * bool: if true the registration with ReplicationManager was successful. + */ + int registered_; + + /** * A human-readable string to distinguish this from other Notifiers. */ ACE_CString identity_; @@ -237,11 +254,6 @@ namespace TAO ::CosNotifyChannelAdmin::StructuredProxyPushConsumer_var structured_proxy_push_consumer_; ::CosNotifyChannelAdmin::SequenceProxyPushConsumer_var sequence_proxy_push_consumer_; - /** - * boolean true means display debug messages (default is false) - */ - int verbose_; - /* * boolean quit when all consumers disconnect */ diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup.idl b/TAO/orbsvcs/orbsvcs/PortableGroup.idl index 313697f984b..135ebd41938 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup.idl +++ b/TAO/orbsvcs/orbsvcs/PortableGroup.idl @@ -221,12 +221,16 @@ module PortableGroup /** * Reserved criteria name for specifing role. */ - const string role_criteron = "org.omg.portablegroup.Role"; + const string role_criterion = "org.omg.portablegroup.Role"; /** * Interface to allow generic factories for replicas to register themselves. * Factories are distinguished by the role to be played by the created-object (role) and the * location at which they create the object (FactoryInfo.the_location) + * + * Because this is an extension to the FT CORBA specification applications that wish to + * adhere to the specification as written should use the type id as the role name when + * interacting with the FactoryRegistry. */ interface FactoryRegistry { diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp index cf09c0b4c5f..a3a8cb935c5 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp @@ -7,7 +7,7 @@ #include <ace/Get_Opt.h> #include <ace/Vector_T.h> #include <tao/PortableServer/ORB_Manager.h> -#include <orbsvcs/PortableGroup/PG_Operators.h> // Borrow operator == on CosNaming::Name +#include "PG_Operators.h" // operator == on CosNaming::Name // Use this macro at the beginning of CORBA methods // to aid in debugging. @@ -604,14 +604,14 @@ void TAO::PG_FactoryRegistry::unregister_factory_by_location ( METHOD_ENTRY(TAO::PG_FactoryRegistry::list_factories_by_role); // allocate stucture to be returned. - PortableGroup::FactoryInfos_var result; + PortableGroup::FactoryInfos_var result = 0; ACE_NEW_THROW_EX (result, ::PortableGroup::FactoryInfos(), CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_NO)); - RoleInfo * role_info; + RoleInfo * role_info = 0; if (this->registry_.find(role, role_info) == 0) { - type_id = role_info->type_id_.c_str(); + type_id = CORBA::string_dup(role_info->type_id_.c_str()); (*result) = role_info->infos_; } else diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp index a2214cc57e3..a106f168d16 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.cpp @@ -10,18 +10,18 @@ ACE_RCSID (PortableGroup, #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Hash_Map_Entry<ACE_UINT32, TAO_PG_Factory_Set>; -template class ACE_Hash_Map_Manager_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Entry<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set>; +template class ACE_Hash_Map_Manager_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Base_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Hash_Map_Entry<ACE_UINT32, TAO_PG_Factory_Set> -#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_UINT32, TAO_PG_Factory_Set, ACE_Hash<ACE_UINT32>, ACE_Equal_To<ACE_UINT32>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Entry<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set> +#pragma instantiate ACE_Hash_Map_Manager_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, ACE_Hash<PortableGroup::ObjectGroupId>, ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h index 09df905cf90..d3747ef190d 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Factory_Map.h @@ -31,10 +31,10 @@ /// Factory hash map. typedef ACE_Hash_Map_Manager_Ex< - ACE_UINT32, + PortableGroup::ObjectGroupId, TAO_PG_Factory_Set, - ACE_Hash<ACE_UINT32>, - ACE_Equal_To<ACE_UINT32>, + ACE_Hash<PortableGroup::ObjectGroupId>, + ACE_Equal_To<PortableGroup::ObjectGroupId>, ACE_Null_Mutex> TAO_PG_Factory_Map; #include /**/ "ace/post.h" diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp index 1ffbb7ba000..028ae48b775 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.cpp @@ -18,7 +18,7 @@ TAO_PG_GenericFactory::TAO_PG_GenericFactory ( TAO_PG_ObjectGroupManager & object_group_manager, TAO_PG_PropertyManager & property_manager) : poa_ (), - next_group_id_(0), +// next_group_id_(0), object_group_manager_ (object_group_manager), property_manager_ (property_manager), factory_map_ (TAO_PG_MAX_OBJECT_GROUPS), @@ -26,6 +26,8 @@ TAO_PG_GenericFactory::TAO_PG_GenericFactory ( lock_ () { this->object_group_manager_.generic_factory (this); + this->domain_id_ = "default-domain"; + } TAO_PG_GenericFactory::~TAO_PG_GenericFactory (void) @@ -69,6 +71,10 @@ TAO_PG_GenericFactory::create_object ( PortableGroup::InvalidProperty, PortableGroup::CannotMeetCriteria)) { + + PortableGroup::ObjectGroup_var object_group = PortableGroup::ObjectGroup::_nil(); + + PortableGroup::Properties_var properties = this->property_manager_.get_type_properties (type_id ACE_ENV_ARG_PARAMETER); @@ -94,52 +100,34 @@ TAO_PG_GenericFactory::create_object ( ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); - CORBA::ULong fcid = 0; - - { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - CORBA::Object::_nil ()); - - // Start out with an initial value. - fcid = this->next_fcid_; - - // Loop until a free FactoryCreationId is found, being careful to - // search through the range of FactoryCreationIds only once. - while (this->factory_map_.find (this->next_fcid_) == 0) - { - this->next_fcid_++; - - // If this is true, then no FactoryCreationIds are available. - // This is highly unlikely since TAO implements a - // FactoryCreationId as a 32 bit unsigned integer, meaning - // that over 4 billion object groups are being managed by this - // generic factory! - if (this->next_fcid_ == fcid) - ACE_THROW_RETURN (PortableGroup::ObjectNotCreated (), - CORBA::Object::_nil ()); - } - // Just in case this->next_fcid_ was modified in the above search, - // reassign the value. - fcid = this->next_fcid_; - } + PortableGroup::ObjectGroupId group_id; +// PortableGroup::ObjectGroup_var + object_group = + this->object_group_manager_.create_object_group (type_id, // in + this->domain_id_, // in + the_criteria, // in + group_id // out + ACE_ENV_ARG_PARAMETER); - { - int _todo_get_the_domain_id_from_somewhere_; - } - const char * domain_id = "dummy-domain-id"; + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + // Allocate a new FactoryCreationId for use as an "out" parameter. + PortableGroup::GenericFactory::FactoryCreationId_var factory_id = 0; + ACE_NEW_THROW_EX (factory_id, + PortableGroup::GenericFactory::FactoryCreationId, + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO_DEFAULT_MINOR_CODE, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + *factory_id <<= group_id; - PortableGroup::ObjectGroup_var object_group = - this->object_group_manager_.create_object_group (++next_group_id_, - type_id, - domain_id, - the_criteria - ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); + TAO_PG_Factory_Set factory_set; const CORBA::ULong factory_infos_count = factory_infos.length (); @@ -157,25 +145,19 @@ TAO_PG_GenericFactory::create_object ( ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (this->factory_map_.bind (fcid, factory_set) != 0) - ACE_TRY_THROW (PortableGroup::ObjectNotCreated ()); - } - // Allocate a new FactoryCreationId for use as an "out" parameter. - PortableGroup::GenericFactory::FactoryCreationId * tmp = 0; - ACE_NEW_THROW_EX (tmp, - PortableGroup::GenericFactory::FactoryCreationId, - CORBA::NO_MEMORY ( - CORBA::SystemException::_tao_minor_code ( - TAO_DEFAULT_MINOR_CODE, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); + CORBA::ULong fcid = 0; + + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, + guard, + this->lock_, + CORBA::Object::_nil ()); - factory_creation_id = tmp; - *tmp <<= fcid; + if (this->factory_map_.bind (group_id, factory_set) != 0) + ACE_TRY_THROW (PortableGroup::ObjectNotCreated ()); + } } ACE_CATCHANY { @@ -184,7 +166,7 @@ TAO_PG_GenericFactory::create_object ( ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - this->object_group_manager_.destroy_object_group (next_group_id_ + this->object_group_manager_.destroy_object_group (group_id ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; @@ -193,16 +175,7 @@ TAO_PG_GenericFactory::create_object ( ACE_ENDTRY; ACE_CHECK_RETURN (CORBA::Object::_nil ()); - { - ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, - guard, - this->lock_, - CORBA::Object::_nil ()); - - // Object group was successfully created. Increment the next - // FactoryCreationId in preparation for the next object group. - this->next_fcid_++; - } + factory_creation_id = factory_id._retn(); return object_group._retn (); } @@ -215,9 +188,9 @@ TAO_PG_GenericFactory::delete_object ( ACE_THROW_SPEC ((CORBA::SystemException, PortableGroup::ObjectNotFound)) { - CORBA::ULong fcid = 0; + PortableGroup::ObjectGroupId group_id; - if (factory_creation_id >>= fcid) // Extract the actual FactoryCreationId. + if (factory_creation_id >>= group_id) // Extract the actual FactoryCreationId. { // Successfully extracted the FactoryCreationId. Now find the // TAO_PG_Factory_Set corresponding to it. @@ -227,7 +200,7 @@ TAO_PG_GenericFactory::delete_object ( // If no entry exists in the factory map, infrastructure // controlled membership was not used. TAO_PG_Factory_Map::ENTRY *entry = 0; - if (this->factory_map_.find (fcid, entry) == 0) + if (this->factory_map_.find (group_id, entry) == 0) { TAO_PG_Factory_Set & factory_set = entry->int_id_; @@ -237,23 +210,14 @@ TAO_PG_GenericFactory::delete_object ( ACE_ENV_ARG_PARAMETER); ACE_CHECK; - if (this->factory_map_.unbind (fcid) != 0) + if (this->factory_map_.unbind (group_id) != 0) ACE_THROW (CORBA::INTERNAL ()); -//TODO - fix this code. Factory-ids and group-ids are now different -{ - int _todo_fix_temporarily_disabled_code_; -} -#if 0 - PortableServer::ObjectId_var oid; - this->get_ObjectId (fcid, oid.out ()); - // Destroy the object group entry. this->object_group_manager_.destroy_object_group ( - oid.in () + group_id ACE_ENV_ARG_PARAMETER); ACE_CHECK; -#endif 0 } } else @@ -319,16 +283,6 @@ TAO_PG_GenericFactory::delete_member ( const PortableGroup::Location & location ACE_ENV_ARG_DECL) { - - //TODO - Fix this code. The original implementation for the load balancer assumed - // that the factory-creation-id was the same as the object-group-id. This - // is not longer true. The find below is supposed to be a factory-creation-id. -{ - int _todo_fix_temporarily_disabled_code_; -} - return; - -#if 0 ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_); // If no entry exists in the factory map, infrastructure @@ -382,7 +336,6 @@ TAO_PG_GenericFactory::delete_member ( } } } -#endif } void @@ -442,41 +395,6 @@ TAO_PG_GenericFactory::populate_object_group ( } void -TAO_PG_GenericFactory::get_ObjectId ( - CORBA::ULong fcid, - PortableServer::ObjectId_out oid) -{ - // Since the POA used by the LoadManager uses the NON_RETAIN - // policy, explicitly choose an ObjectId that is unique to a given - // type. - - // Make the ObjectId be the next value of the number of types that - // have been registered with the LoadManager. For example, if two - // types of objects have been registered with the LoadManager, then - // the ObjectId for the object currently being registered will be - // "3" since the object will be the third type of object registered - // with the LoadManager. Previously used values will not be reused - // to ensure that a ServantLocator does not inadvertently return a - // reference to an object that had a previously used ObjectId. - // Specifcally, the numerical value used for the ObjectId increases - // monotonically. - - // 4294967295UL -- Largest 32 bit unsigned integer - // 123456789012 -- 10 digits - // + 2 for "UL" (unnecessary, but let's be safe) - // + 1 for null terminator - // + 1 for good luck. :-) - const size_t MAX_OID_LEN = 14; - - char oid_str[MAX_OID_LEN] = { 0 }; - ACE_OS::sprintf (oid_str, - "%ul", - fcid); - - oid = PortableServer::string_to_ObjectId (oid_str); -} - -void TAO_PG_GenericFactory::process_criteria ( const char * type_id, const PortableGroup::Criteria & criteria, diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h index 304b4c9847b..488d169dae6 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_GenericFactory.h @@ -168,14 +168,6 @@ private: TAO_PG_Factory_Set & factory_set ACE_ENV_ARG_DECL); - /// Get a new ObjectId to be used when creating a new ObjectGroup. - /** - * An ObjectId created by this method will never be reused within - * the scope of a given ReplicationManager. A value suitable for - * use in a map association <ext_id> is also returned. - */ - void get_ObjectId (CORBA::ULong fcid, - PortableServer::ObjectId_out oid); /// Process criteria to be applied to the object group being /// created. @@ -205,7 +197,7 @@ private: /// The GroupCreationId that will be assigned to the next object /// group that is created. - PortableGroup::ObjectGroupId next_group_id_; +// PortableGroup::ObjectGroupId next_group_id_; /// Reference to the ObjectGroup map. TAO_PG_ObjectGroupManager & object_group_manager_; @@ -237,6 +229,8 @@ private: */ CORBA::ULong next_fcid_; + const char * domain_id_; + /// Lock used to synchronize access to the factory creation id /// index (i.e. next_fcid_). TAO_SYNCH_MUTEX lock_; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h index 38225806e67..ac32fbf6a2a 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Group_Guard.h @@ -14,7 +14,7 @@ #ifndef TAO_PG_GROUP_GUARD_H #define TAO_PG_GROUP_GUARD_H -#include "ace/pre.h" +#include /**/ "ace/pre.h" #include "ace/config-all.h" @@ -88,6 +88,6 @@ private: }; -#include "ace/post.h" +#include /**/ "ace/post.h" #endif /* TAO_PG_GROUP_GUARD_H */ diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp index 1ed50676c3b..c5ede6165f6 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp @@ -19,7 +19,9 @@ TAO_PG_ObjectGroupManager::TAO_PG_ObjectGroupManager (void) object_group_map_ (TAO_PG_MAX_OBJECT_GROUPS), location_map_ (TAO_PG_MAX_LOCATIONS), generic_factory_ (0), - lock_ () + lock_ (), + lock_ogid_ (), + next_ogid_ (1) // don't use ogid 0 { } @@ -499,29 +501,55 @@ TAO_PG_ObjectGroupManager::get_object_group_ref_from_id ( ACE_THROW_RETURN (CORBA::INTERNAL (), PortableGroup::ObjectGroup::_nil ()); - return + return PortableGroup::ObjectGroup::_duplicate (group_entry->object_group.in ()); } + + +void TAO_PG_ObjectGroupManager::allocate_ogid (PortableGroup::ObjectGroupId & ogid) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->lock_ogid_); + //@@ NOTE: as always, ACE_GUARD_XXXX does the wrong thing if the lock fails + + // The numerical value used for the ObjectId increases + // monotonically. + + ogid = this->next_ogid_; + this->next_ogid_ += 1; +} + +PortableServer::ObjectId * TAO_PG_ObjectGroupManager::convert_ogid_to_oid (PortableGroup::ObjectGroupId ogid) +{ + // 4294967295 -- Largest 32 bit unsigned integer + char oid_str[sizeof("4294967295") + 1]; + ACE_OS::snprintf (oid_str, sizeof(oid_str) - 1, + "%lu", + ACE_static_cast (ACE_UINT32,ogid)); + oid_str[sizeof(oid_str) - 1] = '\0'; + + return PortableServer::string_to_ObjectId (oid_str); +} + PortableGroup::ObjectGroup_ptr TAO_PG_ObjectGroupManager::create_object_group ( - PortableGroup::ObjectGroupId group_id, const char * type_id, const char * domain_id, - const PortableGroup::Criteria & the_criteria + const PortableGroup::Criteria & the_criteria, + PortableGroup::ObjectGroupId & group_id ACE_ENV_ARG_DECL) { + allocate_ogid(group_id); + PortableServer::ObjectId_var oid = convert_ogid_to_oid (group_id); + // Create a reference for the ObjectGroup corresponding to the // RepositoryId of the object being created. - PortableServer::ObjectId_var oid = - PortableServer::string_to_ObjectId (type_id); CORBA::Object_var object_group = - this->poa_->create_reference_with_id (oid, + this->poa_->create_reference_with_id (group_id, type_id ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (CORBA::Object::_nil ()); - // { int _TODO_replace_this_with_commemted_out_version_; } PortableGroup::TagGroupTaggedComponent tag_component; tag_component.group_version.major = (CORBA::Octet) 1; @@ -608,25 +636,18 @@ TAO_PG_ObjectGroupManager::type_id ( } PortableGroup::ObjectGroup_ptr -TAO_PG_ObjectGroupManager::object_group (const PortableServer::ObjectId & oid) +TAO_PG_ObjectGroupManager::object_group (const PortableGroup::ObjectGroupId ogid) { ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->lock_, PortableGroup::ObjectGroup::_nil ()); -{ - //TODO -- need to fix this code. The LoadBalancer uses this. - // Need to implement some sort of objectId-to-ObjectGroup nmap. - int _todo_fix_temporarily_disabled_code_; -} -#if 0 TAO_PG_ObjectGroup_Map_Entry * group_entry = 0; - if (this->object_group_map_.find (group_id, group_entry) == 0) + if (this->object_group_map_.find (ogid, group_entry) == 0) return PortableGroup::ObjectGroup::_duplicate (group_entry->object_group.in ()); else -#endif return PortableGroup::ObjectGroup::_nil (); } diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h index 0f900824f96..67f8fdf7589 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h @@ -179,10 +179,10 @@ public: * GenericFactory::create_object() method. */ PortableGroup::ObjectGroup_ptr create_object_group ( - PortableGroup::ObjectGroupId group_id, const char * type_id, const char * domain_id, - const PortableGroup::Criteria & the_criteria + const PortableGroup::Criteria & the_criteria, + PortableGroup::ObjectGroupId & group_id ACE_ENV_ARG_DECL); /// Destroy the object group corresponding to the given ObjectGroupId. @@ -218,7 +218,7 @@ public: * group corresponding to the given ObjectId exists. */ PortableGroup::ObjectGroup_ptr object_group ( - const PortableServer::ObjectId & oid); + const PortableGroup::ObjectGroupId ogid); /// Return the number of members in the given object group. CORBA::ULong member_count (PortableGroup::ObjectGroup_ptr group @@ -284,6 +284,16 @@ protected: CORBA::Object_ptr member ACE_ENV_ARG_DECL); + /** + * Allocate an ogid for a new object group + */ + void allocate_ogid (PortableGroup::ObjectGroupId & ogid); + + /** + * convert numeric OGID to Sequence<Octet> oid + */ + PortableServer::ObjectId * convert_ogid_to_oid (PortableGroup::ObjectGroupId ogid); + private: /// The orb @@ -310,6 +320,12 @@ private: /// Lock used to synchronize access to the underlying tables. TAO_SYNCH_MUTEX lock_; + /// Lock used to synchronize access to next_ogid_. + TAO_SYNCH_MUTEX lock_ogid_; + + /// Next ogid to be allocated. + PortableGroup::ObjectGroupId next_ogid_; + }; diff --git a/TAO/orbsvcs/tests/FT_App/FT_App.mpc b/TAO/orbsvcs/tests/FT_App/FT_App.mpc index 883935a6c11..afefaf323b4 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_App.mpc +++ b/TAO/orbsvcs/tests/FT_App/FT_App.mpc @@ -118,6 +118,7 @@ project(*Creator): taoclient, fault_tolerance, orbsvcsexe { exename = ft_create Source_Files { + FT_Creator.cpp TAO_Object_Group_Creator.cpp } diff --git a/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp b/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp new file mode 100644 index 00000000000..05f1abfdee4 --- /dev/null +++ b/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp @@ -0,0 +1,200 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file TAO_Object_Group_Creator.cpp + * + * $Id$ + * + * This file is part of Fault Tolerant CORBA. + * Main wrapped around TAO_Object_Group_Creator + * + * @author Dale Wilson <wilson_d@ociweb.com> + */ +//============================================================================= + +#include "FT_Creator.h" +#include <iostream> +#include <fstream> +#include <orbsvcs/PortableGroup/PG_Properties_Encoder.h> + +#include <ace/Get_Opt.h> + + +FTAPP::FT_Creator::FT_Creator () + : registry_ior_(0) + , registry_(0) + , replication_manager_(0) + , have_replication_manager_(0) + , make_iogr_(0) + , write_iors_(1) + , iogr_seq_(0) +{ +} + +FTAPP::FT_Creator::~FT_Creator () +{ +} + +int +FTAPP::FT_Creator::parse_args (int argc, char *argv[]) +{ + int result = 0; + + ACE_Get_Opt get_opts (argc, argv, "r:f:u:gi"); + int c; + + while (result == 0 && (c = get_opts ()) != -1) + { + switch (c) + { + case 'r': + { + this->create_roles_.push_back (get_opts.opt_arg ()); + break; + } + case 'u': + { + this->unregister_roles_.push_back (get_opts.opt_arg ()); + break; + } + case 'f': + { + this->registry_ior_ = get_opts.opt_arg (); + break; + } + + case 'g': + { + make_iogr_ = !make_iogr_; + break; + } + + case 'i': + { + write_iors_ = ! write_iors_; + break; + } + + default: + { + std::cerr << "Creator: Unknown argument -" << (char) c << std::endl; + usage(std::cerr); + result = 1; + break; + } + case '?': + { + usage(std::cerr); + result = 1; + break; + } + } + } + + if ( this->create_roles_.size() == 0 && this->unregister_roles_.size()) + { + std::cerr << "Creator: neither create (-t) nor kill (-k) specified. Nothing to do." << std::endl; + usage (std::cerr); + result = -1; + } + + return result; +} + +void FTAPP::FT_Creator::usage(ostream & out)const +{ + out << "usage" + << " -r <role for objects to be created>" + << " -f <factory registry ior file> (if not specified, ReplicationManager is used.)" + << " -u <role to be unregistered (for testing factory registry)>" + << " -g (toggle write iogr for each group (default is not to write iogrs))" + << " -i (toggle write ior for each object (default is to write iors))" + << std::endl; +} + + + +int FTAPP::FT_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) +{ + int result = 1; + this->orb_ = 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); + ACE_CHECK; + } + + result = this->creator_.init (orb ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + return result; +} + +int FTAPP::FT_Creator::run (ACE_ENV_SINGLE_ARG_DECL) +{ + int result = 0; + size_t typeCount = this->create_roles_.size(); + for ( size_t nType = 0; result == 0 && nType < typeCount; ++nType) + { + const char * role = this->create_roles_[nType].c_str(); + std::cout << std::endl << "Creator: Creating group of " << role << std::endl; + result = this->creator_.create_group (role, this->write_iors_, this->make_iogr_); + } + + typeCount = this->unregister_roles_.size(); + for ( nType = 0; result == 0 && nType < typeCount; ++nType) + { + const char * role = this->unregister_roles_[nType].c_str(); + result = this->creator_.unregister_role (role); + } + + return result; +} + +int FTAPP::FT_Creator::fini () +{ + return this->creator_.fini(); +} + +int +main (int argc, char *argv[]) +{ + int result = 0; + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + FTAPP::FT_Creator app; + result = app.parse_args(argc, argv); + if (result == 0) + { + result = app.init (orb ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + if (result == 0) + { + result = app.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + if (result == 0) + { + result = app.fini(); + } + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "FT_Creator::main\t\n"); + result = -1; + } + ACE_ENDTRY; + return result; +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + 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 new file mode 100644 index 00000000000..188ca583a11 --- /dev/null +++ b/TAO/orbsvcs/tests/FT_App/FT_Creator.h @@ -0,0 +1,99 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file TAO_FT_Creator.h + * + * $Id$ + * + * This file is part of Fault Tolerant CORBA. + * Main wrapped around TAO_Object_Group_Creator + * + * @author Dale Wilson <wilson_d@ociweb.com> + */ +//============================================================================= + +#ifndef FT_CREATOR_H +#define FT_CREATOR_H +#include <ace/ACE.h> + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "TAO_Object_Group_Creator.h" + +namespace FTAPP +{ + class FT_Creator + { + typedef ACE_Vector<ACE_CString> StringVec; + public: + /////////////////////////// + // construction/destruction + FT_Creator (); + + ~FT_Creator (); + + ///////////////// + // initialization + int parse_args (int argc, char *argv[]); + + int init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL); + + //////////// + // execution + int run (ACE_ENV_SINGLE_ARG_DECL); + + //////////// + // shut down + int fini (); + + ///////////////// + // implementation + private: + void usage (ostream & out)const; + + //////////////////// + // forbidden methods + private: + FT_Creator (const FT_Creator & rhs); + FT_Creator & operator = (const FT_Creator & rhs); + + //////////////// + // Data members + private: + + TAO::Object_Group_Creator creator_; + CORBA::ORB_var orb_; + const char * registry_ior_; + PortableGroup::FactoryRegistry_var registry_; + StringVec create_roles_; + StringVec unregister_roles_; + + + ::FT::ReplicationManager_var replication_manager_; + /** + * bool: true if we have a real replication manager + */ + int have_replication_manager_; + + /** + * bool: true if we should create IOGR's + */ + int make_iogr_; + + /** + * bool: true if we should write individual IOR files + */ + int write_iors_; + + /** + * sequence number applied to created IOGRs + */ + unsigned long iogr_seq_; + + }; + +} // namespace TAO + +#endif // FT_CREATOR_H diff --git a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp index ed6bcc413f8..b3579e1d52c 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp @@ -51,6 +51,7 @@ static const char * criterion_initial_value = "INITIAL_VALUE"; FT_ReplicaFactory_i::FT_ReplicaFactory_i () : ior_output_file_(0) , factory_registry_ior_(0) + , factory_registry_ (0) , registered_(0) , ns_name_(0) , location_("unknown") @@ -267,67 +268,6 @@ int FT_ReplicaFactory_i::idle (int & result) } -int FT_ReplicaFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) -{ - if (this->ior_output_file_ != 0) - { - ACE_OS::unlink (this->ior_output_file_); - this->ior_output_file_ = 0; - } - if (this->ns_name_ != 0) - { - this->naming_context_->unbind (this_name_ - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - this->ns_name_ = 0; - } - - if (registered_) - { - registered_ = 0; - - if (this->unregister_by_location_) - { - ACE_ERROR (( LM_INFO, - "%s: unregistering all factories at %s\n", - identity(), - location_ - )); - - PortableGroup::Location location(1); - location.length(1); - location[0].id = CORBA::string_dup(location_); - this->factory_registry_->unregister_factory_by_location ( - location - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - else - { - size_t roleCount = roles_.size(); - for (size_t nRole = 0; nRole < roleCount; ++nRole) - { - const char * roleName = this->roles_[nRole].c_str(); - ACE_ERROR (( LM_INFO, - "Factory for: %s@%s unregistering from factory registry\n", - roleName, - location_ - )); - - PortableGroup::Location location(1); - location.length(1); - location[0].id = CORBA::string_dup(location_); - this->factory_registry_->unregister_factory ( - roleName, - location - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - } - } - - return 0; -} int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) { @@ -412,7 +352,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) ACE_TRY_CHECK; if (!CORBA::is_nil (replication_manager_)) { - have_replication_manager_ = 1; + this->have_replication_manager_ = 1; // empty criteria ::PortableGroup::Criteria criteria; this->factory_registry_ = this->replication_manager_->get_factory_registry(criteria ACE_ENV_ARG_PARAMETER); @@ -447,44 +387,34 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) if ( ! CORBA::is_nil (this->factory_registry_)) { - ::PortableGroup::GenericFactory_var this_var = ::PortableGroup::GenericFactory::_narrow(this_obj); - if (! CORBA::is_nil(this_var)) + size_t roleCount = roles_.size(); + for (size_t nRole = 0; nRole < roleCount; ++nRole) { - size_t roleCount = roles_.size(); - for (size_t nRole = 0; nRole < roleCount; ++nRole) - { - const char * roleName = this->roles_[nRole].c_str(); + const char * roleName = this->roles_[nRole].c_str(); - PortableGroup::FactoryInfo info; - info.the_factory = this_var; - info.the_location.length(1); - info.the_location[0].id = CORBA::string_dup(location_); - info.the_criteria.length(1); - info.the_criteria[0].nam.length(1); - info.the_criteria[0].nam[0].id = CORBA::string_dup(PortableGroup::role_criteron); - info.the_criteria[0].val <<= CORBA::string_dup(roleName); + PortableGroup::FactoryInfo info; + 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); + info.the_criteria[0].nam.length(1); + info.the_criteria[0].nam[0].id = CORBA::string_dup(PortableGroup::role_criterion); + info.the_criteria[0].val <<= CORBA::string_dup(roleName); - ACE_ERROR (( LM_INFO, - "Factory: %s@%s registering with factory registry\n", - roleName, - location_ - )); - - this->factory_registry_->register_factory( - roleName, - FT_TEST::_tc_TestReplica->id(), - info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - this->registered_ = 1; - } - else - { - ACE_ERROR (( LM_ERROR, - "Unexpected error: object reference should be a ReplicaFactory?\n" + ACE_ERROR (( LM_INFO, + "Factory: %s@%s registering with factory registry\n", + roleName, + location_ )); + + this->factory_registry_->register_factory( + roleName, + FT_TEST::_tc_TestReplica->id(), + info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } + this->registered_ = 1; } int identified = 0; // bool @@ -570,6 +500,69 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) return result; } +int FT_ReplicaFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->ior_output_file_ != 0) + { + ACE_OS::unlink (this->ior_output_file_); + this->ior_output_file_ = 0; + } + if (this->ns_name_ != 0) + { + this->naming_context_->unbind (this_name_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + this->ns_name_ = 0; + } + + if (registered_) + { + registered_ = 0; + + if (this->unregister_by_location_) + { + ACE_ERROR (( LM_INFO, + "%s: unregistering all factories at %s\n", + identity(), + location_ + )); + + PortableGroup::Location location(1); + location.length(1); + location[0].id = CORBA::string_dup(location_); + this->factory_registry_->unregister_factory_by_location ( + location + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + size_t roleCount = roles_.size(); + for (size_t nRole = 0; nRole < roleCount; ++nRole) + { + const char * roleName = this->roles_[nRole].c_str(); + ACE_ERROR (( LM_INFO, + "Factory for: %s@%s unregistering from factory registry\n", + roleName, + location_ + )); + + PortableGroup::Location location(1); + location.length(1); + location[0].id = CORBA::string_dup(location_); + this->factory_registry_->unregister_factory ( + roleName, + location + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } + } + + return 0; +} + + void FT_ReplicaFactory_i::remove_replica(CORBA::ULong id, FT_TestReplica_i * replica) { InternalGuard guard (this->internals_); @@ -636,14 +629,14 @@ CORBA::Object_ptr FT_ReplicaFactory_i::create_object ( } const char * role = "replica"; - if (! ::TAO_PG::find (decoder, PortableGroup::role_criteron, role) ) + if (! ::TAO_PG::find (decoder, PortableGroup::role_criterion, role) ) { ACE_ERROR((LM_INFO, - "Property \"%s\" not found?\n", PortableGroup::role_criteron + "Property \"%s\" not found?\n", PortableGroup::role_criterion )); // not required. Otherwise: // missingParameter = 1; - // missingParameterName = PortableGroup::role_criteron; + // missingParameterName = PortableGroup::role_criterion; } if (missingParameter) diff --git a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h index 2ec4df9e817..c4959d5eb61 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h +++ b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h @@ -182,8 +182,8 @@ private: * Implementation methods should assume the mutex is * locked if necessary. */ - ACE_Mutex internals_; - typedef ACE_Guard<ACE_Mutex> InternalGuard; + ACE_SYNCH_MUTEX internals_; + typedef ACE_Guard<ACE_SYNCH_MUTEX> InternalGuard; /** * The orb @@ -217,7 +217,7 @@ private: int have_replication_manager_; /** - * The replication manager (if any + * The replication manager */ ::FT::ReplicationManager_var replication_manager_; @@ -256,6 +256,9 @@ private: // The roles used to register types StringVec roles_; + /** + * the FT::Location within the domain + */ const char * location_; /** 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 efaa8abf28a..2393614cae1 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp @@ -21,12 +21,9 @@ TAO::Object_Group_Creator::Object_Group_Creator () - : registry_filename_(0) - , registry_(0) + : registry_(0) , replication_manager_(0) , have_replication_manager_(0) - , make_iogr_(0) - , write_iors_(1) , iogr_seq_(0) { } @@ -35,113 +32,42 @@ TAO::Object_Group_Creator::~Object_Group_Creator () { } -int -TAO::Object_Group_Creator::parse_args (int argc, char *argv[]) +int TAO::Object_Group_Creator::set_factory_registry ( const char * factory_ior) { - int result = 0; - - ACE_Get_Opt get_opts (argc, argv, "r:f:u:gi"); - int c; + int result = 1; - while (result == 0 && (c = get_opts ()) != -1) + ACE_TRY_NEW_ENV { - switch (c) + 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_)) { - case 'r': - { - this->create_roles_.push_back (get_opts.opt_arg ()); - break; - } - case 'u': - { - this->unregister_roles_.push_back (get_opts.opt_arg ()); - break; - } - case 'f': - { - this->registry_filename_ = get_opts.opt_arg (); - break; - } - - case 'g': - { - make_iogr_ = !make_iogr_; - break; - } - - case 'i': - { - write_iors_ = ! write_iors_; - break; - } - - default: - { - std::cerr << "Creator: Unknown argument -" << (char) c << std::endl; - usage(std::cerr); - result = 1; - break; - } - case '?': - { - usage(std::cerr); - result = 1; - break; - } + result = 0; // success } } - - if ( this->create_roles_.size() == 0 && this->unregister_roles_.size()) + ACE_CATCHANY { - std::cerr << "Creator: neither create (-t) nor kill (-k) specified. Nothing to do." << std::endl; - usage (std::cerr); - result = -1; + result = 1; } - + ACE_ENDTRY; return result; } -void TAO::Object_Group_Creator::usage(ostream & out)const +int TAO::Object_Group_Creator::set_factory_registry (PortableGroup::FactoryRegistry_ptr factory) { - out << "usage" - << " -r <role for objects to be created>" - << " -f <factory registry ior file> (if not specified, ReplicationManager is used.)" - << " -u <role to be unregistered (for testing factory registry)>" - << " -g (toggle write iogr for each group (default is not to write iogrs))" - << " -i (toggle write ior for each object (default is to write iors))" - << std::endl; + this->registry_ = factory; + return 0; } - int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) { int result = 1; this->orb_ = orb; - // if a factory IOR was specified on command line - if ( this->registry_filename_ != 0) - { - ////////////////////////////////////// - // Try using the -f argument as an IOR - ACE_TRY_NEW_ENV - { - CORBA::Object_var registry_obj = this->orb_->string_to_object (this->registry_filename_ 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; - } - else // no -f option. Try RIR(RM) + if (CORBA::is_nil (this->registry_)) { /////////////////////////////// // Find the ReplicationManager @@ -150,11 +76,11 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) CORBA::Object_var rm_obj = orb->resolve_initial_references("ReplicationManager" ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - replication_manager_ = ::FT::ReplicationManager::_narrow(rm_obj.in() ACE_ENV_ARG_PARAMETER); + this->replication_manager_ = ::FT::ReplicationManager::_narrow(rm_obj.in() ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (!CORBA::is_nil (replication_manager_)) + if (!CORBA::is_nil (this->replication_manager_)) { - have_replication_manager_ = 1; + this->have_replication_manager_ = 1; // empty criteria ::PortableGroup::Criteria criteria; this->registry_ = this->replication_manager_->get_factory_registry(criteria ACE_ENV_ARG_PARAMETER); @@ -170,18 +96,7 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) } else { - - registry_ = ::PortableGroup::FactoryRegistry::_narrow(rm_obj.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (!CORBA::is_nil(registry_)) - { - std::cout << "Found a FactoryRegistry DBA ReplicationManager" << std::endl; - result = 0; // success - } - else - { - std::cerr << "Creator: Can't resolve ReplicationManager, and no -f option was given." << std::endl; - } + std::cerr << "Creator: Can't resolve ReplicationManager, and no factory registry option was given." << std::endl; } } ACE_CATCHANY @@ -197,26 +112,6 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) return result; } -int TAO::Object_Group_Creator::run (ACE_ENV_SINGLE_ARG_DECL) -{ - int result = 0; - size_t typeCount = this->create_roles_.size(); - for ( size_t nType = 0; result == 0 && nType < typeCount; ++nType) - { - const char * role = this->create_roles_[nType].c_str(); - result = create_group (role); - } - - typeCount = this->unregister_roles_.size(); - for ( nType = 0; result == 0 && nType < typeCount; ++nType) - { - const char * role = this->unregister_roles_[nType].c_str(); - result = unregister_role (role); - } - - return result; -} - int TAO::Object_Group_Creator::unregister_role(const char * role ACE_ENV_ARG_DECL) { int result = 0; @@ -226,12 +121,10 @@ int TAO::Object_Group_Creator::unregister_role(const char * role ACE_ENV_ARG_DEC return result; } -int TAO::Object_Group_Creator::create_group(const char * role ACE_ENV_ARG_DECL) +int TAO::Object_Group_Creator::create_group(const char * role, int write_iors, int write_iogr ACE_ENV_ARG_DECL) { int result = 0; - std::cout << std::endl << "Creator: Creating group of " << role << std::endl; - CORBA::String_var type_id; ::PortableGroup::FactoryInfos_var infos = this->registry_->list_factories_by_role (role, type_id ACE_ENV_ARG_PARAMETER) @@ -246,8 +139,8 @@ int TAO::Object_Group_Creator::create_group(const char * role ACE_ENV_ARG_DECL) /////////////////////////// // Begin with an empty IOGR ::PortableGroup::GenericFactory::FactoryCreationId_var creation_id; - CORBA::Object_var iogr; - if (make_iogr_ && this->have_replication_manager_) + CORBA::Object_var group; + if (write_iogr && this->have_replication_manager_) { PortableGroup::Criteria criteria(1); criteria.length(1); @@ -255,7 +148,7 @@ int TAO::Object_Group_Creator::create_group(const char * role ACE_ENV_ARG_DECL) criteria[0].nam[0].id = PortableGroup::PG_MEMBERSHIP_STYLE; criteria[0].val <<= PortableGroup::MEMB_APP_CTRL; - iogr = this->replication_manager_->create_object( + group = this->replication_manager_->create_object( type_id.in(), criteria, creation_id @@ -267,6 +160,28 @@ int TAO::Object_Group_Creator::create_group(const char * role ACE_ENV_ARG_DECL) for (CORBA::ULong nFact = 0; nFact < count; ++nFact) { + +#define DUMP_EM_ALL +#ifdef DUMP_EM_ALL + if (write_iogr && this->have_replication_manager_) + { + const char * group_ior = orb_->object_to_string (group ACE_ENV_ARG_PARAMETER ); + char group_ior_filename[200]; // "${role}_$(location)_${factory_id}.ior" + + ACE_OS::snprintf(group_ior_filename, sizeof(group_ior_filename)-1, "%s_%lu_%lu.group", + role, + this->iogr_seq_, + ACE_static_cast(unsigned long, nFact)); + + std::cout << "Creator: Writing ior before factory " << nFact << " to " << group_ior_filename << std::endl; + + if (write_ior_file(group_ior_filename, group_ior) != 0) + { + std::cerr << "Creator: Error writing ior [" << group_ior << "] to " << group_ior_filename << std::endl; + } + } +#endif //DUMP_EM_ALL + ::PortableGroup::FactoryInfo info = infos[nFact]; /* struct FactoryInfo { GenericFactory the_factory; @@ -290,7 +205,7 @@ int TAO::Object_Group_Creator::create_group(const char * role ACE_ENV_ARG_DECL) ACE_CHECK; - if (write_iors_) + if (write_iors) { //////////////////////////////////// // Somewhat of a hack @@ -327,18 +242,20 @@ int TAO::Object_Group_Creator::create_group(const char * role ACE_ENV_ARG_DECL) } } - if (make_iogr_ && this->have_replication_manager_) + if (write_iogr && this->have_replication_manager_) { - iogr = this->replication_manager_->add_member (iogr, + group = this->replication_manager_->add_member (group, info.the_location, created_obj ACE_ENV_ARG_PARAMETER); ACE_CHECK; +#if 0 // DEBUG_DISABLE if (nFact == 0) { - iogr = this->replication_manager_->set_primary_member(iogr, info.the_location + group = this->replication_manager_->set_primary_member(group, info.the_location ACE_ENV_ARG_PARAMETER); } +#endif// DEBUG_DISABLE } } else @@ -349,22 +266,22 @@ int TAO::Object_Group_Creator::create_group(const char * role ACE_ENV_ARG_DECL) std::cout << "Creator: Successfully created group of " << role << std::endl; - if(make_iogr_ && have_replication_manager_) + if(write_iogr && have_replication_manager_) { - const char * replica_iogr = orb_->object_to_string (iogr ACE_ENV_ARG_PARAMETER ); + const char * group_iogr = orb_->object_to_string (group ACE_ENV_ARG_PARAMETER ); ACE_CHECK; - char replica_iogr_filename[200]; + char group_ior_filename[200]; - ACE_OS::snprintf(replica_iogr_filename, sizeof(replica_iogr_filename)-1, "%s_%lu.iogr", + ACE_OS::snprintf(group_ior_filename, sizeof(group_ior_filename)-1, "%s_%lu.iogr", role, this->iogr_seq_); - replica_iogr_filename[sizeof(replica_iogr_filename)-1] = '\0'; + group_ior_filename[sizeof(group_ior_filename)-1] = '\0'; - std::cout << "Creator: Writing ior for created object to " << replica_iogr_filename << std::endl; + std::cout << "Creator: Writing ior for created object group to " << group_ior_filename << std::endl; - if (write_ior_file(replica_iogr_filename, replica_iogr) != 0) + if (write_ior_file(group_ior_filename, group_iogr) != 0) { - std::cerr << "Creator: Error writing ior [" << replica_iogr << "] to " << replica_iogr_filename << std::endl; + std::cerr << "Creator: Error writing ior [" << group_iogr << "] to " << group_ior_filename << std::endl; } this->iogr_seq_ += 1; } @@ -380,8 +297,6 @@ int TAO::Object_Group_Creator::fini () return 0; } - - int TAO::Object_Group_Creator::write_ior_file(const char * outputFile, const char * ior) { int result = -1; @@ -401,45 +316,8 @@ int TAO::Object_Group_Creator::write_ior_file(const char * outputFile, const cha return result; } -int -main (int argc, char *argv[]) -{ - int result = 0; - ACE_TRY_NEW_ENV - { - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - TAO::Object_Group_Creator app; - result = app.parse_args(argc, argv); - if (result == 0) - { - result = app.init (orb ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (result == 0) - { - result = app.run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - if (result == 0) - { - result = app.fini(); - } - } - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Object_Group_Creator::main\t\n"); - result = -1; - } - ACE_ENDTRY; - return result; -} - - - #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - template ACE_Vector<ACE_CString>; +// template ACE_Vector<ACE_CString>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -# pragma instantiate ACE_Vector<ACE_CString> +//# pragma instantiate ACE_Vector<ACE_CString> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ 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 52653c6cfc5..dcd18de0d47 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h @@ -38,14 +38,18 @@ namespace TAO ~Object_Group_Creator (); ///////////////// - // initialization - int parse_args (int argc, char *argv[]); + // 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); - //////////// - // execution - int run (ACE_ENV_SINGLE_ARG_DECL); + ///////////////// + // functionality + int create_group(const char * role, int write_iors, int write_iogr ACE_ENV_ARG_DECL); + int unregister_role(const char * role ACE_ENV_ARG_DECL); //////////// // shut down @@ -54,12 +58,8 @@ namespace TAO ///////////////// // implementation private: - void usage (ostream & out)const; int write_ior_file(const char * outputFile, const char * ior); - int create_group(const char * role ACE_ENV_ARG_DECL); - int unregister_role(const char * role ACE_ENV_ARG_DECL); - //////////////////// // forbidden methods private: @@ -70,29 +70,16 @@ namespace TAO // Data members private: CORBA::ORB_var orb_; - const char * registry_filename_; PortableGroup::FactoryRegistry_var registry_; - StringVec create_roles_; - StringVec unregister_roles_; - ::FT::ReplicationManager_var replication_manager_; + /** * bool: true if we have a real replication manager */ int have_replication_manager_; /** - * bool: true if we should create IOGR's - */ - int make_iogr_; - - /** - * bool: true if we should write individual IOR files - */ - int write_iors_; - - /** * sequence number applied to created IOGRs */ unsigned long iogr_seq_; diff --git a/TAO/orbsvcs/tests/FT_App/run_test_detector.pl b/TAO/orbsvcs/tests/FT_App/run_test_detector.pl index da6cadacee4..8cf8cfaf395 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_detector.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_detector.pl @@ -123,10 +123,11 @@ my($REP2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ my($DET) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Detector$build_directory/Fault_Detector", "-o $detector_ior -q"); my($NOT) = new PerlACE::Process (".$build_directory/ft_notifier", "-o $notifier_ior -q -d file://$detector_ior -r file://$replica1_ior -r file://$replica2_ior"); my($CL); -if (simulated) { +if ($simulated) { + print "\nTEST: Preparing Client Mediated Fault Tolerance test.\n" if ($verbose); $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); }else{ - #todo figure out how to get iogr + print "\nTEST: Preparing IOGR based test.\n" if ($verbose); $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); } diff --git a/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl b/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl index 61aa981c79a..41a46444c5f 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl @@ -143,10 +143,11 @@ my($NOT) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Notifier$build_ my($CONS) = new PerlACE::Process (".$build_directory/ft_fault_consumer", "-o $ready_file -n file://$notifier_ior -q -d file://$detector_ior -r file://$replica1_ior -r file://$replica2_ior"); my($CL); -if (simulated) { +if ($simulated) { + print "\nTEST: Preparing Client Mediated Fault Tolerance test.\n" if ($verbose); $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); }else{ - #todo figure out how to get iogr + print "\nTEST: Preparing IOGR based test.\n" if ($verbose); $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); } diff --git a/TAO/orbsvcs/tests/FT_App/run_test_iogr.pl b/TAO/orbsvcs/tests/FT_App/run_test_iogr.pl new file mode 100644 index 00000000000..d8749d5b201 --- /dev/null +++ b/TAO/orbsvcs/tests/FT_App/run_test_iogr.pl @@ -0,0 +1,395 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +# Purpose: +# To test the FactoryRegistry as a component of ReplicationManager +# +# Process being tested: +# FT_ReplicationManager +# implements PortableGroup::FactoryRegistry interface. +# Processes used in test: +# FT_Replica * 3 +# implements GenericFactory interface to create TestReplicas +# TestReplica implements TestReplica interface. +# TestReplica implements PullMonitorable interface. +# FT_Client +# client for TestReplica interface. +# client for PullMonitorable. +# Object Group Creator +# Creates groups of objects. +# +# Test Scenario (***Test: marks behavior being tested): +# +# First the test starts The ReplicationManager, +# Then starts three factories. Each factory exists at a separate location. +# The locations are named shire, bree, and rivendell. In a "real" system +# these locations would be on separate computers. +# +# The factory at the shire location knows how to create hobbits. +# The factory at the bree location knows how to create hobbits, elves, and humans. +# The factory at rivendell can create elves. +# Hobbits, elves, and humans are roles for TestReplica objects. A creation parameter +# included as part of the registration information specifies which role they are playing. +# +# ***Test: The factories register themselves with the factory registry in the ReplicationManager. +# Registration information includes: +# the role, +# the type of object created, +# the location, +# an object reference to the factory and +# a set of parameters to be passed to the factory's create_object method. +# +# An object group creator is started and asked to create three object groups: +# a group of hobbits, a group of elves; and another group of hobbits. +# +# ***Test: the object group creator asks the ReplicationManager::FactoryRegistry +# for the set of factories that can create objects for the desired role. +# Then it uses the create_object method for each factory to create the actual object. +# +# [temporary until IOGR's are working: The object group creator writes the +# IOR's of the create objects to files -- using a file naming convention to +# distinguish members of the group. It will be enhanced to assemble these +# IORs into an IOGR and either write the IOGR to a file or register it with +# the Naming Service.] +# +# The object group creator is also told to unregister all factories that create humans. +# ***Test: It does so using the unregister_factory_by_role method. +# +# Three clients are started, one at a time. Each client is given a reference +# to an object group +# +# [temporary until IOGRs and transparent reinvocaton work: each client is +# given references to the members of the group and manages its own recovery +# (client mediated fault tolerance)] +# +# Each client sends a few requests to first member of the object group. Eventually +# this member fails and the requests are then rerouted to the second (and last) +# member of the group. +# +# When a clients job is done, it exits and asks the remaining group member to +# exit, too. +# +# The factories are run with the quit-on-idle option so when the last object +# created at that location goes away, the factory exits. +# +# ***Test: As it exits the factory unregisters itself with the ReplicationManager::FactoryRegistry. +# ***Test: A command line option determines whether it uses a single +# unregister_factory_by_location call, or separate unregister_factory calles for +# each type of object created. In this test, the shire location uses unregister_factory, +# and bree and rivendell use unregister_factory_by_location. +# +# The factory registry is also run with the quit-on-idle option so when the last +# factory unregisters itself. +# The ReplicationManager is killed because it doesn't have a quit-on-idle option. + +use lib '../../../../bin'; +#use lib '$ENV{ACE_ROOT}/bin'; +use PerlACE::Run_Test; + +######################## +#command line options +#set defaults: +my($verbose) = 0; # 1: report perl actions before executing them +my($debug_builds) = 0; # 0: use exes from Release directories +my($simulated) = 0; # 1: use "client simulated" fault tolerance + +foreach $i (@ARGV) { + if ($i eq "--debug_build") + { + $debug_builds = 1; + } + elsif ($i eq "--simulate") + { + $simulated = ! $simulated0; + } + elsif ($i eq "-v") + { + $verbose += 1; + } +} + +my($build_directory) = "/Release"; +if ( $debug_builds ) { + $build_directory = ""; +} + +if ( $verbose > 1) { + print "verbose: $verbose\n"; + print "debug_builds: $debug_builds -> $build_directory\n"; + print "simulated: $simulated\n"; +} + +my($role1) = "hobbit"; +my($role2) = "elf"; +my($role3) = "human"; + +my($location1) = "shire"; +my($location2) = "bree"; +my($location3) = "rivendell"; +my($location4) = "rohan"; + +#define temp files +my($rm_ior) = PerlACE::LocalFile ("rm.ior"); +my($factory1_ior) = PerlACE::LocalFile ("factory1.ior"); +my($factory2_ior) = PerlACE::LocalFile ("factory2.ior"); +my($factory3_ior) = PerlACE::LocalFile ("factory3.ior"); +my($replica1_ior) = PerlACE::LocalFile ("${role1}_${location1}_0.ior"); +my($replica2_ior) = PerlACE::LocalFile ("${role1}_${location2}_0.ior"); +my($replica3_ior) = PerlACE::LocalFile ("${role2}_${location2}_1.ior"); +my($replica4_ior) = PerlACE::LocalFile ("${role2}_${location3}_0.ior"); +my($replica5_ior) = PerlACE::LocalFile ("${role1}_${location1}_1.ior"); +my($replica6_ior) = PerlACE::LocalFile ("${role1}_${location2}_2.ior"); + +my($replica1_iogr) = PerlACE::LocalFile ("${role1}_0.iogr"); +my($replica2_iogr) = PerlACE::LocalFile ("${role2}_1.iogr"); +my($replica3_iogr) = PerlACE::LocalFile ("${role1}_2.iogr"); + +my($client_data) = PerlACE::LocalFile ("persistent.dat"); + +#discard junk from previous tests +if (10) { +unlink $rm_ior; +unlink $factory1_ior; +unlink $factory2_ior; +unlink $factory3_ior; +unlink $replica1_ior; +unlink $replica2_ior; +unlink $replica3_ior; +unlink $replica4_ior; +unlink $replica5_ior; +unlink $replica6_ior; +unlink $replica1_iogr; +unlink $replica2_iogr; + +unlink $client_data; +} +my($status) = 0; + +my($RM) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/FT_ReplicationManager$build_directory/FT_ReplicationManager", "-o $rm_ior"); +my($RMC) = new PerlACE::Process (".$build_directory/replmgr_controller", "-k file://$rm_ior -x"); +my($FAC1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ior -ORBInitRef ReplicationManager=file://$rm_ior -l $location1 -i $role1 -q"); +my($FAC2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -ORBInitRef ReplicationManager=file://$rm_ior -l $location2 -i $role1 -i $role2 -i $role3 -q -u"); +my($FAC3) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory3_ior -ORBInitRef ReplicationManager=file://$rm_ior -l $location3 -i $role2 -q -u"); +my($CTR); + +my($CL1); +my($CL2); +my($CL3); +if ($simulated) { + print "\nTEST: Preparing Client Mediated Fault Tolerance test.\n" if ($verbose); + $CTR = new PerlACE::Process (".$build_directory/ft_create", "-ORBInitRef ReplicationManager=file://$rm_ior -r $role1 -r $role2 -r $role1 -u $role3"); + $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); + $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica3_ior -f file://$replica4_ior -c testscript"); + $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica5_ior -f file://$replica6_ior -c testscript"); +}else{ + print "\nTEST: Preparing IOGR based test.\n" if ($verbose); + $CTR = new PerlACE::Process (".$build_directory/ft_create", "-ORBInitRef ReplicationManager=file://$rm_ior -r $role1 -r $role2 -r $role1 -u $role3 -g -i"); + $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_iogr -c testscript"); + $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica2_iogr -c testscript"); + $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica3_iogr -c testscript"); +} + +####################### +# Start ReplicationManager +if (10) { +print "\nTEST: starting ReplicationManager " . $RM->CommandLine . "\n" if ($verbose); +$RM->Spawn (); + +print "TEST: waiting for registry's IOR\n" if ($verbose); +if (PerlACE::waitforfile_timed ($rm_ior, 5) == -1) { + print STDERR "ERROR: cannot find file <$rm_ior>\n"; + $RM->Kill (); $RM->TimedWait (1); + exit 1; +} +} +################# +# Start Factories + +print "\nTEST: starting factory 1 " . $FAC1->CommandLine . "\n" if ($verbose); +$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"; + $RM->Kill (); $RM->TimedWait (1); + $FAC1->Kill (); $FAC1->TimedWait (1); + exit 1; +} + +print "\nTEST: starting factory 2 " . $FAC2->CommandLine . "\n" if ($verbose); +$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"; + $FAC1->Kill (); $FAC1->TimedWait (1); + $RM->Kill (); $RM->TimedWait (1); + $FAC2->Kill (); $FAC2->TimedWait (1); + exit 1; +} + +print "\nTEST: starting factory 3 " . $FAC3->CommandLine . "\n" if ($verbose); +$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"; + $FAC1->Kill (); $FAC1->TimedWait (1); + $FAC2->Kill (); $FAC2->TimedWait (1); + $RM->Kill (); $RM->TimedWait (1); + $FAC3->Kill (); $FAC3->TimedWait (1); + exit 1; +} + +###################### +# Create object groups + +print "\nTEST: starting object group creator " . $CTR->CommandLine . "\n" if ($verbose); +$CTR->Spawn (); +if ($simulated){ + 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"; + $status = 1; + } + elsif (PerlACE::waitforfile_timed ($replica2_ior, 5) == -1){ + print STDERR "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"; + $status = 1; + } + elsif (PerlACE::waitforfile_timed ($replica4_ior, 5) == -1){ + print STDERR "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"; + $status = 1; + } + elsif (PerlACE::waitforfile_timed ($replica6_ior, 5) == -1){ + print STDERR "ERROR: cannot find file <$replica6_ior> \n"; + $status = 1; + } +}else{ + if (PerlACE::waitforfile_timed ($replica1_iogr, 5) == -1){ + print STDERR "ERROR: cannot find file <$replica1_iogr>\n"; + $status = 1; + } + elsif (PerlACE::waitforfile_timed ($replica2_iogr, 5) == -1){ + print STDERR "ERROR: cannot find file <$replica2_iogr> \n"; + $status = 1; + } +} + +if($status != 0){ + $FAC3->Kill (); $FAC3->TimedWait (1); + $FAC2->Kill (); $FAC2->TimedWait (1); + $FAC1->Kill (); $FAC1->TimedWait (1); + $RM->Kill (); $RM->TimedWait (1); + $CTR->Kill (); $CTR->TimedWait(1); + exit 1; +} + +print "\nTEST: wait for object group creator.\n" if ($verbose); +my($config) = $CTR->WaitKill (5); +if ($config != 0) { + print STDERR "ERROR: configuration manager returned $config\n"; + $FAC3->Kill (); $FAC3->TimedWait (1); + $FAC2->Kill (); $FAC2->TimedWait (1); + $FAC1->Kill (); $FAC1->TimedWait (1); + $RM->Kill (); $RM->TimedWait (1); + exit 1; +} + + +############# +# Run clients + +print "\nTEST: starting client " . $CL1->CommandLine . "\n" if ($verbose); +$client = $CL1->SpawnWaitKill (60); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +print "\nTEST: starting client again " . $CL2->CommandLine . "\n" if ($verbose); +$client2 = $CL2->SpawnWaitKill (60); + +if ($client2 != 0) { + print STDERR "ERROR: client returned $client2\n"; + $status = 1; +} + +print "\nTEST: starting client, one more time with feeling " . $CL3->CommandLine . "\n" if ($verbose); +$client3 = $CL3->SpawnWaitKill (60); + +if ($client3 != 0) { + print STDERR "ERROR: client returned $client3\n"; + $status = 1; +} + +###################### +# Clean house and exit + +print "\nTEST: wait for factory 1.\n" if ($verbose); +$factory1 = $FAC1->WaitKill (30); +if ($factory1 != 0) { + print STDERR "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"; + $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"; + $status = 1; +} + +#if (10) { +print "\nTEST: shutting down the replication manager.\n" if ($verbose); +$controller = $RMC->SpawnWaitKill (300); +if ($controller != 0) { + print STDERR "ERROR: replication manager controller returned $controller\n"; + $status = 1; + +print "\nTEST: wait for ReplicationManager.\n" if ($verbose); +$repmgr = $RM->WaitKill (30); +if ($repmgr != 0) { + print STDERR "ERROR: ReplicationManager returned $repmgr\n"; + $status = 1; +} +} + + +print "\nTEST: releasing scratch files.\n" if ($verbose); +unlink $rm_ior; +unlink $factory1_ior; +unlink $factory2_ior; +unlink $factory3_ior; +unlink $replica1_ior; +unlink $replica2_ior; +unlink $replica3_ior; +unlink $replica4_ior; +unlink $replica5_ior; +unlink $replica6_ior; +unlink $replica1_iogr; +unlink $replica2_iogr; + +unlink $client_data; + + +exit $status; diff --git a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl index 845ecfd7ea4..d3fe654b14e 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl @@ -175,12 +175,13 @@ my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-ORBInitRef Rep my($CL1); my($CL2); my($CL3); -if (simulated) { +if ($simulated) { + print "\nTEST: Preparing Client Mediated Fault Tolerance test.\n" if ($verbose); $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica3_ior -f file://$replica4_ior -c testscript"); $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica5_ior -f file://$replica6_ior -c testscript"); }else{ - #todo figure out how to get iogr + print "\nTEST: Preparing IOGR based test.\n" if ($verbose); $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_iogr -c testscript"); $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica2_iogr -c testscript"); $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica3_iogr -c testscript"); diff --git a/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl b/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl index 716808c9035..1a5f3844faf 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl @@ -151,10 +151,11 @@ my($REPLM) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/FT_ReplicationManag my($REPLM_CTRL) = new PerlACE::Process (".$build_directory/replmgr_controller", "-ORBInitRef ReplicationManager=corbaloc::localhost:2833/ReplicationManager -x"); my($CL); -if (simulated) { +if ($simulated) { + print "\nTEST: Preparing Client Mediated Fault Tolerance test.\n" if ($verbose); $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); }else{ - #todo figure out how to get iogr + print "\nTEST: Preparing IOGR based test.\n" if ($verbose); $CL = new PerlACE::Process (".$build_directory/ft_client", "-f -f file://$replica1_iogr -c testscript"); } diff --git a/TAO/orbsvcs/tests/FT_App/run_test_rmnotifier.pl b/TAO/orbsvcs/tests/FT_App/run_test_rmnotifier.pl new file mode 100755 index 00000000000..b6b32ce30d3 --- /dev/null +++ b/TAO/orbsvcs/tests/FT_App/run_test_rmnotifier.pl @@ -0,0 +1,318 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +# Purpose: +# To test the FaultNotifier +# +# Process being tested: +# Fault_Notifier +# implements FaultNotifier interface. +# Processes used in test: +# TODO: Document adding ReplicationManager +# FT_Replica +# implements TestReplica interface. +# implements PullMonitorable. +# Fault_Detector +# implements FaultDetectorFactory interface +# implements PullMonitorable interface +# FT_Client +# client for TestReplica interface. +# client for PullMonitorable. +# StubAnalyzer +# Subscribes to Fault_Notfier +# +# Test Scenario (***Test: marks behavior being tested): +# Phase 1: +# Start two FT_Replicas +# FT_Replicas write TestReplica IORs (FR#1 and FR#2) to files +# Start the Fault_Detector +# Fault_Detector writes its IOR (FDF) to a file +# Start the Fault_Notifier +# Fault_Notifier writes its IOR (FN) to a file. +# Phase 2: +# Wait for IORs: FR#1, FR#2, FDF, and FN +# Start the StubAnalyzer giving it IORS: FR#1, FR#2 FDF, FN +# StubAnalyzer calls FDF to create a FaultDetector +# for each Replica. +# StubAnalyzer subscribes to Fault_Notifier +# StubAnalyzer writes dummy message(READY) to a file. +# Phase 3: +# Wait for READY +# Start FT_Client giving it IORS: FR#1 and FR#2. [1] +# FT_Client interacts with FR#1. +# FT_Client asks FR#1 to fault. It does so. +# FT_Client notices fault and switches to FR#2. [1] +# FD#1 notices fault and notifies Fault_Notifier +# FD#1 terminates +# ***Test: Fault_Notifier forwards notification to StubAnalyzer +# StubAnalyzer prints notification. +# FT_Client interacts with FR#2. +# FT_Client asks FR#2 to shut down. +# FT_Client shuts down. +# FD#2 notices FR2 is gone, interprets this +# as a fault, and sends notification to Fault_Notifier +# FD#2 terminates. +# ***Test: Fault_Notifier forwards notification to StubAnalyzer +# StubAnalyzer prints notification. +# Phase 4: shutting down. +# All FaultDetectors have terminated so the FaultDetectorFactory +# honors the "quit-on-idle" option on it's command line and exits. +# StubAnalyzer compares # fault notifications to # replicas. When +# they match, it "knows" that the test is over, so it shuts down. +# As it does so, it disconnects its fault consumers from the FaultNotifier. +# FaultNotifier notices the last fault consumer disconnecting and exits because +# the "quit-on-idle" option was specified on the command line. +# Phase 5: housekeeping +# Wait for all processes to terminate. +# Check termination status. +# Delete temp files. +# +# [1] Client mediated fault tolerance. These points will +# change when IOGR support is available. +use lib '../../../../bin'; +#use lib '$ENV{ACE_ROOT}/bin'; +use PerlACE::Run_Test; + +######################## +#command line options +#set defaults: +my($verbose) = 0; # 1: report perl actions before executing them +my($debug_builds) = 0; # 0: use exes from Release directories +my($simulated) = 1; # 1: use "client simulated" fault tolerance + +foreach $i (@ARGV) { + if ($i eq "--debug_build") + { + $debug_builds = 1; + } + elsif ($i eq "--no_simulate") # reverse this once we have FT ORB support + { + $simulated = 0; + } + elsif ($i eq "-v") + { + $verbose += 1; + } +} + + +my($build_directory) = "/Release"; +if ( $debug_builds ) { + $build_directory = ""; +} + +if ( $verbose > 1) { + print "verbose: $verbose\n"; + print "debug_builds: $debug_builds -> $build_directory\n"; + print "simulated: $simulated\n"; +} + +#define temp files +my ($rm_endpoint) = "-ORBEndpoint iiop://localhost:2833"; +my ($rm_initref) = "-ORBInitRef ReplicationManager=corbaloc::localhost:2833/ReplicationManager"; +my($rm_ior) = PerlACE::LocalFile ("rm.ior"); +my($factory1_ior) = PerlACE::LocalFile ("factory1.ior"); +my($factory2_ior) = PerlACE::LocalFile ("factory2.ior"); +my($replica1_ior) = PerlACE::LocalFile ("replica1.ior"); +my($replica2_ior) = PerlACE::LocalFile ("replica2.ior"); +my($detector_ior) = PerlACE::LocalFile ("detector.ior"); +my($notifier_ior) = PerlACE::LocalFile ("notifier.ior"); +my($ready_file) = PerlACE::LocalFile ("ready.file"); +my($client_data) = PerlACE::LocalFile ("persistent.dat"); + +#discard junk from previous tests +unlink $rm_ior; +unlink $factory1_ior; +unlink $factory2_ior; +unlink $replica1_ior; +unlink $replica2_ior; +unlink $detector_ior; +unlink $notifier_ior; +unlink $ready_file; +unlink $client_data; + +my($status) = 0; + +my($RM) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/FT_ReplicationManager$build_directory/FT_ReplicationManager", "-o $rm_ior $rm_endpoint"); +my($RMC) = new PerlACE::Process (".$build_directory/replmgr_controller", "$rm_initref -x"); +my($REP1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ior -f none -t $replica1_ior -l loc1 -i type1 -q"); +my($REP2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -f none -t $replica2_ior -l loc2 -i type1 -q"); +my($DET) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Detector$build_directory/Fault_Detector", "$rm_initref -o $detector_ior -q"); +my($NOT) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Notifier$build_directory/Fault_Notifier", "$rm_initref -o $notifier_ior -q"); +my($ANA) = new PerlACE::Process (".$build_directory/ft_analyzer", "-o $ready_file -n file://$notifier_ior -d file://$detector_ior -r file://$replica1_ior -r file://$replica2_ior -q"); + +my($CL); +if ($simulated) { + print "\nTEST: Preparing Client Mediated Fault Tolerance test.\n" if ($verbose); + $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); +}else{ + print "\nTEST: Preparing IOGR based test.\n" if ($verbose); + $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); +} + +####################### +# ReplicationManager + +print "\nTEST: starting ReplicationManager " . $RM->CommandLine . "\n" if ($verbose); +$RM->Spawn (); + +print "TEST: waiting for registry's IOR\n" if ($verbose); +if (PerlACE::waitforfile_timed ($rm_ior, 5) == -1) { + print STDERR "ERROR: cannot find file <$rm_ior>\n"; + $RM->Kill (); $RM->TimedWait (1); + exit 1; +} + +########## +# Notifier +print "\nTEST: starting notifier " . $NOT->CommandLine . "\n" if ($verbose); +$NOT->Spawn (); + +print "TEST: waiting for notifier's IOR\n" if ($verbose); +if (PerlACE::waitforfile_timed ($notifier_ior, 5) == -1) { + print STDERR "ERROR: cannot find file <$notifier_ior>\n"; + $RM->Kill (); $RM->TimedWait (1); + $NOT->Kill (); $NOT->TimedWait(1); + exit 1; +} + +########## +# Detector +print "\nTEST: starting detector factory " . $DET->CommandLine . "\n" if ($verbose); +$DET->Spawn (); + +print "TEST: waiting for detector's IOR\n" if ($verbose); +if (PerlACE::waitforfile_timed ($detector_ior, 20) == -1) { + print STDERR "ERROR: cannot find file <$detector_ior>\n"; + $RM->Kill (); $RM->TimedWait (1); + $NOT->Kill (); $NOT->TimedWait(1); + $DET->Kill (); $DET2->TimedWait(1); + exit 1; +} + +########### +# Replica 1 +print "\nTEST: starting replica1 " . $REP1->CommandLine . "\n" if ($verbose); +$REP1->Spawn (); + +print "TEST: waiting for replica 1's IOR\n" if ($verbose); +if (PerlACE::waitforfile_timed ($replica1_ior, 5) == -1) { + print STDERR "ERROR: cannot find file <$replica1_ior>\n"; + $RM->Kill (); $RM->TimedWait (1); + $NOT->Kill (); $NOT->TimedWait(1); + $DET->Kill (); $DET->TimedWait(1); + $REP1->Kill (); $REP1->TimedWait (1); + exit 1; +} + +########### +# Replica 2 +print "\nTEST: starting replica2 " . $REP2->CommandLine . "\n" if ($verbose); +$REP2->Spawn (); + +print "TEST: waiting for replica 2's IOR\n" if ($verbose); +if (PerlACE::waitforfile_timed ($replica2_ior, 5) == -1) { + print STDERR "ERROR: cannot find file <$replica2_ior>\n"; + $RM->Kill (); $RM->TimedWait (1); + $NOT->Kill (); $NOT->TimedWait(1); + $DET->Kill (); $DET->TimedWait(1); + $REP1->Kill (); $REP1->TimedWait (1); + $REP2->Kill (); $REP2->TimedWait (1); + exit 1; +} + +########## +# Analyzer +print "\nTEST: starting analyzer " . $ANA->CommandLine . "\n" if ($verbose); +$ANA->Spawn (); + +print "TEST: waiting for READY.FILE from analyzer\n" if ($verbose); +if (PerlACE::waitforfile_timed ($ready_file, 5) == -1) { + print STDERR "ERROR: cannot find file <$ready_file>\n"; + $RM->Kill (); $RM->TimedWait (1); + $NOT->Kill (); $NOT->TimedWait(1); + $DET->Kill (); $DET->TimedWait(1); + $REP1->Kill (); $REP1->TimedWait (1); + $REP2->Kill (); $REP2->TimedWait (1); + $DET->Kill (); $DET2->TimedWait(1); + $NOT->Kill (); $NOT->TimedWait(1); + $ANA->Kill (); $ANA->TimedWait(1); + exit 1; +} + +######## +# Client +print "\nTEST: starting client " . $CL->CommandLine . "\n" if ($verbose); +$client = $CL->SpawnWaitKill (60); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +print "\nTEST: wait for replica 1.\n" if ($verbose); +$replica1 = $REP1->WaitKill (5); +if ($replica1 != 0) { + print STDERR "ERROR: replica returned $replica1\n"; + $status = 1; +} + +print "\nTEST: wait for replica 2.\n" if ($verbose); +$replica2 = $REP2->WaitKill (5); +if ($replica2 != 0) { + print STDERR "ERROR: replica returned $replica2\n"; + $status = 1; +} + +print "\nTEST: wait for detector factory to leave.\n" if ($verbose); +$detector = $DET->WaitKill (20); +if ($detector != 0) { + print STDERR "ERROR: detector returned $detector\n"; + $status = 1; +} + +print "\nTEST: wait for analyzer to leave.\n" if ($verbose); +$analyzer = $ANA->WaitKill (20); +if ($analyzer != 0) { + print STDERR "ERROR: analyzer returned $analyzer\n"; + $status = 1; +} + +print "\nTEST: shutting down the replication manager.\n" if ($verbose); +$controller = $RMC->SpawnWaitKill (300); +if ($controller != 0) { + print STDERR "ERROR: replication manager controller returned $controller\n"; + $status = 1; +} + +print "\nTEST: wait for ReplicationManager.\n" if ($verbose); +#$RM->Kill (); +$repmgr = $RM->WaitKill (30); +if ($repmgr != 0) { + print STDERR "ERROR: ReplicationManager returned $repmgr\n"; + $status = 1; +} + +print "\nTEST: wait for notifier to leave.\n" if ($verbose); +$notifier = $NOT->WaitKill (20); +if ($notifier != 0) { + print STDERR "ERROR: notifier returned $notifier\n"; + $status = 1; +} + +print "\nTEST: releasing scratch files.\n" if ($verbose); +unlink $rm_ior; +unlink $replica1_ior; +unlink $replica2_ior; +unlink $detector_ior; +unlink $notifier_ior; +unlink $ready_file; + +#client's work file +unlink $client_data; + +exit $status; diff --git a/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl b/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl index b35cb5acd2e..29120a798e8 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl @@ -178,12 +178,13 @@ my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-ORBInitRef Rep my($CL1); my($CL2); my($CL3); -if (simulated) { +if ($simulated) { + print "\nTEST: Preparing Client Mediated Fault Tolerance test.\n" if ($verbose); $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica3_ior -f file://$replica4_ior -c testscript"); $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica5_ior -f file://$replica6_ior -c testscript"); }else{ - #todo figure out how to get iogr + print "\nTEST: Preparing IOGR based test.\n" if ($verbose); $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_iogr -c testscript"); $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica2_iogr -c testscript"); $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica3_iogr -c testscript"); |