From 52a596e86ef0fafe76783f2ac975606b6ca3f583 Mon Sep 17 00:00:00 2001 From: wilson_d Date: Mon, 3 Nov 2003 16:57:41 +0000 Subject: ChangeLogTag: Mon Nov 3 10:17:06 2003 Dale Wilson --- TAO/ChangeLog | 77 +++++- .../FT_ReplicationManager/FT_FaultConsumer.cpp | 2 +- .../FT_ReplicationManager.cpp | 70 ++++-- .../Fault_Detector/FT_FaultDetectorFactory_i.cpp | 18 +- TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp | 19 +- TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp | 36 +-- .../FT_ServerRequest_Interceptor.cpp | 9 +- TAO/orbsvcs/orbsvcs/PortableGroup.idl | 2 +- .../orbsvcs/PortableGroup/PG_FactoryRegistry.cpp | 16 +- .../PortableGroup/PG_ObjectGroupManager.cpp | 4 +- .../orbsvcs/PortableGroup/PG_Object_Group.cpp | 72 ++++-- .../orbsvcs/PortableGroup/PG_Object_Group.h | 72 ++++-- TAO/orbsvcs/tests/FT_App/FT_Client.cpp | 35 ++- TAO/orbsvcs/tests/FT_App/FT_Client_Unit.cpp | 4 +- TAO/orbsvcs/tests/FT_App/FT_Creator.cpp | 125 ++++++++-- TAO/orbsvcs/tests/FT_App/FT_Creator.h | 23 +- TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp | 32 +-- TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h | 1 - TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp | 33 ++- TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.h | 7 +- TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp | 2 +- TAO/orbsvcs/tests/FT_App/StubBatchConsumer.cpp | 8 +- TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp | 2 +- TAO/orbsvcs/tests/FT_App/StubFaultConsumer.cpp | 9 +- TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp | 19 +- .../tests/FT_App/TAO_Object_Group_Creator.cpp | 264 ++++++++++++++------- .../tests/FT_App/TAO_Object_Group_Creator.h | 27 ++- TAO/orbsvcs/tests/FT_App/run_test_iogr.pl | 6 +- TAO/orbsvcs/tests/FT_App/run_test_registry.pl | 6 +- TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl | 21 +- TAO/tao/Object.cpp | 5 +- 31 files changed, 699 insertions(+), 327 deletions(-) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 38a8049f8f5..bdbfde06c10 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,58 @@ +Mon Nov 3 10:17:06 2003 Dale Wilson + + * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp: + Add support to update group members' IOGRS. + + * orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp: + * orbsvcs/orbsvcs/PortableGroup.idl: + * orbsvcs/tests/FT_App/FT_TestReplica_i.h: + * orbsvcs/tests/FT_App/FT_TestReplica_i.cpp: + Change method signature of tao_update_object_group. + + * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.h: + * orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp: + Minor formatting change in object group id conversion to string. + + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h: + * orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp: + Track Location of member in member structure. + Distribute new IOGR to group members. + Use 2-argument version of tao_update_object_group_method + Temporary: dump IOGRs to files during IOGR distribution. + + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h: + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp: + Create fault detector for new group member. + + * orbsvcs/tests/FT_App/run_test_iogr.pl: + * orbsvcs/tests/FT_App/run_test_registry.pl: + * orbsvcs/tests/FT_App/run_test_rmregistry.pl: + Use file:// IOR syntax to pass IOGR to client. + + + * orbsvcs/tests/FT_App/FT_UnitTests.cpp: + * orbsvcs/tests/FT_App/StubBatchConsumer.cpp: + * orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp: + * orbsvcs/tests/FT_App/StubFaultConsumer.cpp: + * orbsvcs/tests/FT_App/StubFaultNotifier.cpp: + * orbsvcs/tests/FT_App/FT_Client.cpp: + * orbsvcs/tests/FT_App/FT_Client_Unit.cpp: + * orbsvcs/tests/FT_App/FT_Creator.h: + * orbsvcs/tests/FT_App/FT_Creator.cpp: + * orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h: + * orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp: + * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp: + * orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp: + * orbsvcs/Fault_Detector/Fault_Detector_i.cpp: + * orbsvcs/Fault_Notifier/FT_Notifier_i.cpp: + * orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp: + Use ACE_CHECK macros correctly, now that I (think I) understand them. + + * tao/Object.cpp: + Add additional diagnostic information to error message. + + These changes were made in the oci_haft branch. + Fri Oct 31 11:38:07 2003 Steve Totten * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h: @@ -10,18 +65,20 @@ Fri Oct 31 11:38:07 2003 Steve Totten id of a failed object group so we can unregister factories by location and type. + These changes were made in the oci_haft branch. + Fri Oct 31 10:14:22 2003 Balachandran Natarajan - * orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp: + * orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp: + + Added a comment for Dale + + * orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.cpp: - Added a comment for Dale - - * orbsvcs/orbsvcs/FaultTolerance/FT_ClientRequest_Interceptor.cpp: - - Fix in the main trunk trunk never got moved to the branch. + Fix in the main trunk trunk never got moved to the branch. - These changes are in oci_haft_branch. They haven't been compiled - yet. + These changes are in oci_haft_branch. They haven't been compiled + yet. Thu Oct 30 10:08:11 2003 Dale Wilson @@ -34,8 +91,8 @@ Wed Oct 29 18:20:12 2003 Balachandran Natarajan * orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp: - Made a simple mistake while trying to look at the number of - arguments. + Made a simple mistake while trying to look at the number of + arguments. These changes were made in the oci_haft branch. diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp index 479f857f239..f8b28047972 100755 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp @@ -186,7 +186,7 @@ int TAO::FT_FaultConsumer::fini (ACE_ENV_SINGLE_ARG_DECL) ); } ACE_ENDTRY; - ACE_CHECK; + ACE_CHECK_RETURN(1); #if (TAO_DEBUG_LEVEL_NEEDED == 1) if (TAO_debug_level > 1) diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp index dcb3a32016f..1dbea34fbb5 100644 --- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp +++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp @@ -624,22 +624,62 @@ TAO::FT_ReplicationManager::set_primary_member ( object_group, the_location ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (CORBA::Object::_nil()); if (CORBA::is_nil (member) ) { ACE_THROW (PortableGroup::MemberNotFound ()); - ACE_CHECK; + ACE_CHECK_RETURN (CORBA::Object::_nil()); } - FT::TagFTGroupTaggedComponent ft_tag_component; - TAO_FT_IOGR_Property prop (ft_tag_component); + + FT::TagFTGroupTaggedComponent tag_component; + TAO_FT_IOGR_Property prop (tag_component); + + //remove primary + if (iorm_->is_primary_set (&prop, object_group ACE_ENV_ARG_PARAMETER)) + { + ACE_CHECK_RETURN (CORBA::Object::_nil()); + (void)iorm_->remove_primary_tag (&prop, object_group ACE_ENV_ARG_PARAMETER); + } + if (! iorm_->set_primary (&prop, member, object_group ACE_ENV_ARG_PARAMETER)) { ACE_ERROR ((LM_ERROR, "ReplicationManager::set_primary_member: Can't set primary in IOGR .\n" )); + ACE_THROW( FT::PrimaryNotSet()); } - ACE_CHECK; + ACE_CHECK_RETURN (CORBA::Object::_nil()); + + + if (! TAO::PG_Utils::get_tagged_component (object_group, tag_component)) + { + ACE_THROW (PortableGroup::ObjectGroupNotFound()); + } + + tag_component.object_group_ref_version += 1; + ACE_DEBUG ((LM_DEBUG, + "set_primary_member: Setting IOGR version to %u\n", ACE_static_cast(unsigned, tag_component.object_group_ref_version) + )); + + // Set the property + TAO::PG_Utils::set_tagged_component (object_group, tag_component ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + /////////////////////// + // Now we do it again using + // our own object group collection + TAO::PG_Object_Group * group; + if (this->object_group_map_.find_group (object_group, group)) + { +// group->set_primary (member ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + // Set the new group reference + // and distribute it to all members + group->set_reference (object_group, tag_component.object_group_ref_version, 1); + } + + return object_group->_duplicate (object_group); } @@ -700,31 +740,31 @@ TAO::FT_ReplicationManager::add_member ( the_location, member ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); iors [1] = member; // Now merge the list into one new IOGR PortableGroup::ObjectGroup_var merged = iorm_->merge_iors (iors ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); if (first_member) { // remove the original profile. It's a dummy entry supplied by create_object. PortableGroup::ObjectGroup_var cleaned = iorm_->remove_profiles (merged, object_group); - ACE_CHECK; + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); if (! iorm_->set_primary (&prop, member, cleaned.in () ACE_ENV_ARG_PARAMETER)) { ACE_ERROR ((LM_ERROR, "Can't set primary in IOGR after adding first replica.\n" )); } - ACE_CHECK; + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); merged = cleaned; } - ACE_CHECK; + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); tag_component.object_group_ref_version += 1; ACE_DEBUG ((LM_DEBUG, @@ -734,7 +774,7 @@ TAO::FT_ReplicationManager::add_member ( // Set the property TAO::PG_Utils::set_tagged_component (merged, tag_component); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); + ACE_CHECK_RETURN (PortableGroup::ObjectGroup::_nil()); /////////////////////// // Now we do it again using @@ -746,7 +786,7 @@ TAO::FT_ReplicationManager::add_member ( ACE_CHECK_RETURN (CORBA::Object::_nil ()); // Set the new group reference // and distribute it to all members - group->set_reference (merged, 1); + group->set_reference (merged, tag_component.object_group_ref_version, 1); } return merged._retn(); @@ -871,7 +911,7 @@ TAO::FT_ReplicationManager::create_object ( //////////////////////////////// // then create the corresponding // entry in our object group map - + PortableGroup::ObjectGroupId oid; if (! ((*factory_creation_id) >>= oid )) { @@ -885,10 +925,10 @@ TAO::FT_ReplicationManager::create_object ( TAO::PG_Object_Group * objectGroup; ACE_NEW_THROW_EX ( objectGroup, - TAO::PG_Object_Group (oid, type_id, the_criteria), + TAO::PG_Object_Group (this->orb_, oid, type_id, the_criteria), CORBA::NO_MEMORY()); ACE_CHECK_RETURN (CORBA::Object::_nil ()); - + this->object_group_map_.insert_group(oid, objectGroup); return obj._retn(); diff --git a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp index 1dfb540239e..bf816b2db86 100644 --- a/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp +++ b/TAO/orbsvcs/Fault_Detector/FT_FaultDetectorFactory_i.cpp @@ -221,26 +221,26 @@ int TAO::FT_FaultDetectorFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // Register with the POA. this->objectId_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // find my IOR CORBA::Object_var this_obj = this->poa_->id_to_reference (objectId_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); this->ior_ = this->orb_->object_to_string (this_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); this->identity_ = "FaultDetectorFactory"; @@ -328,7 +328,7 @@ int TAO::FT_FaultDetectorFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (CORBA::is_nil(naming_obj.in ())){ ACE_ERROR_RETURN ((LM_ERROR, @@ -338,14 +338,14 @@ int TAO::FT_FaultDetectorFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) this->naming_context_ = ::CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); this->this_name_.length (1); this->this_name_[0].id = CORBA::string_dup (this->ns_name_); this->naming_context_->rebind (this->this_name_, this_obj.in() //CORBA::Object::_duplicate(this_obj) ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); } return result; @@ -371,7 +371,7 @@ int TAO::FT_FaultDetectorFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) FT::FAULT_DETECTOR_ROLE_NAME, this->location_ ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1); this->registered_ = 0; } return 0; diff --git a/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp b/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp index 34c941b9edd..6acf648597d 100644 --- a/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp +++ b/TAO/orbsvcs/Fault_Detector/Fault_Detector_i.cpp @@ -156,15 +156,22 @@ void TAO::Fault_Detector_i::notify() } ACE_TRY_NEW_ENV { -ACE_ERROR ((LM_ERROR, -"call Fault Detector push Structured Event.\n" -)); + if (TAO_debug_level > 5) + { + ACE_ERROR ((LM_ERROR, + "call Fault Detector push Structured Event.\n" + )); + } this->notifier_->push_structured_fault(vEvent.in() ACE_ENV_ARG_PARAMETER); -ACE_ERROR ((LM_ERROR, -"return from Fault Detector push Structured Event.\n" -)); ACE_TRY_CHECK; + if (TAO_debug_level > 5) + { + + ACE_ERROR ((LM_ERROR, + "return from Fault Detector push Structured Event.\n" + )); + } } ACE_CATCHANY { diff --git a/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp b/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp index 598b32772f4..131463ead68 100644 --- a/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp +++ b/TAO/orbsvcs/Fault_Notifier/FT_Notifier_i.cpp @@ -207,7 +207,7 @@ int TAO::FT_FaultNotifier_i::fini (ACE_ENV_SINGLE_ARG_DECL) ACE_CATCHANY { ACE_DEBUG ((LM_DEBUG, - "FaultNotifier Can't unregistered from ReplicationManager.\n" + "FaultNotifier Can't unregister from ReplicationManager.\n" )); // complain, but otherwise ignore this error // RM may be down. @@ -251,26 +251,26 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); // find my IOR CORBA::Object_var this_obj = this->poa_->id_to_reference (object_id_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); this->ior_ = this->orb_->object_to_string (this_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); //////////////////////////////////////////////// @@ -278,7 +278,7 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) CosNotifyChannelAdmin::EventChannelFactory_var notify_factory = TAO_Notify_EventChannelFactory_i::create (poa_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); CosNotification::QoSProperties initial_qos; CosNotification::AdminProperties initial_admin; this->notify_channel_ = @@ -286,16 +286,16 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) initial_admin, channel_id_ ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); this->filter_factory_ = this->notify_channel_->default_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); /////////////////////////// // Producer registration this->supplier_admin_ = this->notify_channel_->default_supplier_admin (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); ::CosNotifyChannelAdmin::ProxyID proxyId = 0; @@ -306,12 +306,12 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) ::CosNotifyChannelAdmin::STRUCTURED_EVENT, proxyId ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); structured_proxy_push_consumer_ = ::CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(consumer ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); if (CORBA::is_nil (this->structured_proxy_push_consumer_)) { ACE_ERROR_RETURN ((LM_ERROR, @@ -325,7 +325,7 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) this->structured_proxy_push_consumer_->connect_structured_push_supplier (stubPushSupplier.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); //////////////////// // Sequence producer @@ -353,13 +353,13 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) this->sequence_proxy_push_consumer_->connect_sequence_push_supplier (stubSeqPushSupplier.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); /////////////////////////// // Consumer registration // find the channel administrator for consumers this->consumer_admin_ = this->notify_channel_->default_consumer_admin (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); if (CORBA::is_nil (this->consumer_admin_)) { ACE_ERROR ((LM_ERROR, @@ -439,7 +439,7 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (CORBA::is_nil(naming_obj.in ())){ ACE_ERROR_RETURN ((LM_ERROR, @@ -449,7 +449,7 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) this->naming_context_ = CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (CORBA::is_nil(this->naming_context_)) { ACE_ERROR_RETURN ((LM_ERROR, @@ -461,7 +461,7 @@ int TAO::FT_FaultNotifier_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL ) this->naming_context_->rebind (this->this_name_, this_obj.in() //CORBA::Object::_duplicate(this_obj) ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); } } diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp index 565472ff528..a46d10d98ac 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_ServerRequest_Interceptor.cpp @@ -149,9 +149,9 @@ namespace TAO if (fgvsc.object_group_ref_version > this->object_group_ref_version_) { - // @@ Dale, could you please make this a warning. Add TAO_debug_level - // around this. - // Further pass in a operation name to this method and make a check here. + // @@ Dale, could you please make this a warning. Add TAO_debug_level + // around this. + // Further pass in a operation name to this method and make a check here. ACE_ERROR ((LM_ERROR, "TAO-FT (%P|%t) - Wrong version information " "within the interceptor [%u | %u] \n", @@ -221,8 +221,7 @@ namespace TAO ri->arguments (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - if (param->length () > 1 || - param->length () == 0) + if (param->length () != 2) ACE_THROW (CORBA::TRANSIENT ()); diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup.idl b/TAO/orbsvcs/orbsvcs/PortableGroup.idl index ed0088d1345..40546e2eb23 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup.idl +++ b/TAO/orbsvcs/orbsvcs/PortableGroup.idl @@ -300,7 +300,7 @@ module PortableGroup * Pseudo used method to update IOGR in Object Group Members * TAO specific. The CORBA spec. doesn't address the issue. */ - void tao_update_object_group (in PortableGroup::ObjectGroup iogr); + void tao_update_object_group (in string iogr, in PortableGroup::ObjectGroupRefVersion version); }; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp index 093ca2af618..8ae7dd18ecc 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_FactoryRegistry.cpp @@ -175,26 +175,26 @@ int TAO::PG_FactoryRegistry::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); // find my identity as a corba object this->this_obj_ = this->poa_->id_to_reference (object_id_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); // and create a ior string this->ior_ = this->orb_->object_to_string (this->this_obj_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); if (this->ior_output_file_ != 0) @@ -211,7 +211,7 @@ int TAO::PG_FactoryRegistry::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); if (CORBA::is_nil(naming_obj.in ())){ ACE_ERROR_RETURN ((LM_ERROR, @@ -221,14 +221,14 @@ int TAO::PG_FactoryRegistry::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) this->naming_context_ = CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); this->this_name_.length (1); this->this_name_[0].id = CORBA::string_dup (this->ns_name_); this->naming_context_->rebind (this->this_name_, this->this_obj_.in() //CORBA::Object::_duplicate(this_obj) ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN(-1); } return result; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp index c5ede6165f6..021fbeba75f 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_ObjectGroupManager.cpp @@ -522,8 +522,8 @@ void TAO_PG_ObjectGroupManager::allocate_ogid (PortableGroup::ObjectGroupId & og 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, + char oid_str[11]; + ACE_OS::snprintf (oid_str, sizeof(oid_str), "%lu", ACE_static_cast (ACE_UINT32,ogid)); oid_str[sizeof(oid_str) - 1] = '\0'; diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp index f8381023de7..e336501de8e 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.cpp @@ -12,23 +12,28 @@ /** * The single POA used to manage object groups */ -//static +//static PortableServer::POA_var TAO::PG_Object_Group::poa_; -TAO::PG_Object_Group::MemberInfo::MemberInfo (CORBA::Object_var member) - : member_(member) +TAO::PG_Object_Group::MemberInfo::MemberInfo ( + CORBA::Object_ptr member, + const PortableGroup::Location & location) + : member_ (CORBA::Object::_duplicate (member)) + , location_ (location) , factory_(PortableGroup::GenericFactory::_nil()) { } TAO::PG_Object_Group::MemberInfo::MemberInfo ( - CORBA::Object_var member, - PortableGroup::GenericFactory_var factory, + CORBA::Object_ptr member, + const PortableGroup::Location & location, + PortableGroup::GenericFactory_ptr factory, PortableGroup::GenericFactory::FactoryCreationId factory_id) - : member_(member) - , factory_(factory) - , factory_id_(factory_id) + : member_ (CORBA::Object::_duplicate (member)) + , factory_ (PortableGroup::GenericFactory::_duplicate (factory)) + , factory_id_ (factory_id) + , location_ (location) { } @@ -49,6 +54,7 @@ TAO::PG_Object_Group::MemberInfo::~MemberInfo () } } +/* TAO::PG_Object_Group::PG_Object_Group () : role_ ("") , type_id_ ("") @@ -58,13 +64,15 @@ TAO::PG_Object_Group::PG_Object_Group () , properties_ (0) { } - +*/ TAO::PG_Object_Group::PG_Object_Group ( + CORBA::ORB_ptr orb, PortableGroup::ObjectGroupId oid, const char * type_id, PortableGroup::Criteria the_criteria) - : role_ (type_id) + : orb_ (CORBA::ORB::_duplicate (orb)) + , role_ (type_id) , type_id_ (CORBA::string_dup(type_id)) , group_id_(oid) , reference_ (0) @@ -75,7 +83,7 @@ TAO::PG_Object_Group::PG_Object_Group ( TAO::PG_Object_Group::~PG_Object_Group () { - for (MemberMap_Iterator it = this->members_.begin(); + for (MemberMap_Iterator it = this->members_.begin(); it != this->members_.end(); this->members_.begin()) { @@ -85,11 +93,32 @@ TAO::PG_Object_Group::~PG_Object_Group () } } -void TAO::PG_Object_Group::set_reference (PortableGroup::ObjectGroup_ptr reference, int distribute) + +void dump_ior (const char * base, unsigned long version, const char * iogr) +{ + char filename[1000]; + sprintf(filename, "%s_%lu.iogr", base, version ); + + FILE * iorfile = fopen(filename, "w"); + fwrite (iogr, 1, strlen(iogr), iorfile); + fclose (iorfile); +} + + +void TAO::PG_Object_Group::set_reference ( + PortableGroup::ObjectGroup_ptr reference, + PortableGroup::ObjectGroupRefVersion version, + int distribute + ACE_ENV_ARG_DECL) { this->reference_ = PortableGroup::ObjectGroup::_duplicate (reference); + this->version_ = version; + this->IOGR_ = this->orb_->object_to_string (reference ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (distribute) { + size_t n_rep = 0; // for dump_ior below for ( MemberMap_Iterator it = members_.begin(); it != members_.end(); ++it) @@ -100,7 +129,16 @@ void TAO::PG_Object_Group::set_reference (PortableGroup::ObjectGroup_ptr referen { ACE_TRY_NEW_ENV { - uog->tao_update_object_group (PortableGroup::ObjectGroup::_duplicate (this->reference_)); + ACE_DEBUG ((LM_DEBUG, + "PG_Object_Group pushing IOGR to member: %s@%s.\n", + this->role_.c_str(), + ACE_static_cast(const char *, info->location_[0].id) + )); + dump_ior ("group", this->version_, this->IOGR_); + CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in() ACE_ENV_ARG_PARAMETER); + dump_ior ("replica", n_rep++, replica_ior); + + uog->tao_update_object_group (this->IOGR_, this->version_); } ACE_CATCHANY { @@ -207,7 +245,7 @@ void TAO::PG_Object_Group::add_member ( PortableGroup::ObjectNotAdded)) { MemberInfo * info = 0; - ACE_NEW_THROW_EX (info, MemberInfo(member), + ACE_NEW_THROW_EX (info, MemberInfo(member, the_location), CORBA::NO_MEMORY()); if (members_.bind (the_location, info) != 0) @@ -262,7 +300,6 @@ CORBA::Object_ptr TAO::PG_Object_Group::get_member_ref ( } #endif -#ifdef NOT_IMPLEMENTED void TAO::PG_Object_Group::set_properties_dynamically ( const PortableGroup::Properties & overrides ACE_ENV_ARG_DECL) @@ -270,9 +307,10 @@ void TAO::PG_Object_Group::set_properties_dynamically ( PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)) { - int todo; + this->properties_ = overrides; + int todo_parse_properties_for_special_value; + int todo_override_rather_than_replace_question; } -#endif void TAO::PG_Object_Group::get_properties (PortableGroup::Properties_var & result) const { diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h index 6439f95212c..36675657c15 100644 --- a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Object_Group.h @@ -53,44 +53,55 @@ namespace TAO // Information about an object group member struct MemberInfo { - /// Reference to the object. + /// Reference to the member. CORBA::Object_var member_; + /// The factory that was used to create this object /// nil if application created. PortableGroup::GenericFactory_var factory_; + /// FactoryCreationId assigned to the member. Empty if application created PortableGroup::GenericFactory::FactoryCreationId factory_id_; + + /// Location where this member exists + PortableGroup::Location location_; + + /////////////// + // Methods + /// Construct an application-supplied member. - MemberInfo (CORBA::Object_var member); + MemberInfo (CORBA::Object_ptr member, const PortableGroup::Location & location); + /// Construct a infrastructure-created member. MemberInfo ( - CORBA::Object_var member, - PortableGroup::GenericFactory_var factory, + CORBA::Object_ptr member, + const PortableGroup::Location & location, + PortableGroup::GenericFactory_ptr factory, PortableGroup::GenericFactory::FactoryCreationId factory_id); + + /// Destructor ~MemberInfo(); }; typedef TAO_SYNCH_MUTEX MemberMapMutex; typedef ACE_Hash_Map_Manager_Ex < - PortableGroup::Location, + PortableGroup::Location, MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MemberMapMutex> MemberMap; typedef ACE_Hash_Map_Entry MemberMap_Entry; typedef ACE_Hash_Map_Iterator_Ex < - PortableGroup::Location, - MemberInfo *, + PortableGroup::Location, + MemberInfo *, TAO_PG_Location_Hash, TAO_PG_Location_Equal_To, MemberMapMutex> MemberMap_Iterator; - - public: - /// Constructor - PG_Object_Group (); + public: /// Constructor PG_Object_Group ( + CORBA::ORB_ptr orb, PortableGroup::ObjectGroupId oid, const char * type_id, PortableGroup::Criteria the_criteria); @@ -98,23 +109,28 @@ namespace TAO /// Destructor ~PG_Object_Group (); - ///////////////// // public methods public: - + /// Set object group id void set_oid (PortableGroup::ObjectGroupId oid); + /// Set type ID + void set_typeid (PortableGroup::TypeId type_id); - void set_properties (PortableGroup::Criteria the_criteria); - /** - * - * @ param reference the new IOGR for this group. - * @ distribute bool if true, distribute IOGR to all members - */ - void set_reference (PortableGroup::ObjectGroup_ptr reference, int distribute); + /// Set a reference to the group (IOGR) + /// @param reference the new IOGR for this group. + /// @param version of this IOGR + /// @param distribute bool if true, distribute IOGR to all members + void set_reference ( + PortableGroup::ObjectGroup_ptr reference, + PortableGroup::ObjectGroupRefVersion version, + int distribute + ACE_ENV_ARG_DECL); + + /// return a duplicated reference to this group (IOGR) PortableGroup::ObjectGroup_ptr reference()const; void set_membership_style (PortableGroup::MembershipStyleValue style); @@ -127,6 +143,7 @@ namespace TAO PortableGroup::MinimumNumberReplicasValue minimum_number_replicas ()const; void set_group_specific_factories (const PortableGroup::FactoryInfos & infos); + /** * Note the caller receives a copy of the factoryinfos in the result argument. * inefficient, but thread safe. @@ -134,7 +151,7 @@ namespace TAO void group_specific_factories (PortableGroup::FactoryInfos & result) const; // Note: primary location is a concept from FT CORBA. - // It doesn't hurt other PortableGroup-based services to + // It doesn't hurt other PortableGroup-based services to // have these two metods and the underlying member. void set_primary_location (PortableGroup::Location & primary_location_); const PortableGroup::Location & primary_location() const; @@ -202,7 +219,6 @@ namespace TAO PortableGroup::MemberNotFound)); #endif -#ifdef NOT_IMPLEMENTED void set_properties_dynamically ( const PortableGroup::Properties & overrides ACE_ENV_ARG_DECL) @@ -210,8 +226,6 @@ namespace TAO PortableGroup::InvalidProperty, PortableGroup::UnsupportedProperty)); -#endif - ///////////////////////// // Implementation methods private: @@ -219,9 +233,10 @@ namespace TAO ///////////////////////// // Forbidden methods private: + PG_Object_Group (); PG_Object_Group (const PG_Object_Group & rhs); PG_Object_Group & operator = (const PG_Object_Group & rhs); - + ///////////////// // Static Methods @@ -254,6 +269,8 @@ namespace TAO ACE_SYNCH_MUTEX internals_; typedef ACE_Guard InternalGuard; + CORBA::ORB_var orb_; + ACE_CString role_; PortableGroup::TypeId type_id_; PortableGroup::ObjectGroupId group_id_; @@ -262,6 +279,11 @@ namespace TAO */ PortableGroup::ObjectGroup_var reference_; + CORBA::String_var IOGR_; + PortableGroup::ObjectGroupRefVersion version_; + + + /** * The CORBA object id assigned to this object group */ diff --git a/TAO/orbsvcs/tests/FT_App/FT_Client.cpp b/TAO/orbsvcs/tests/FT_App/FT_Client.cpp index c2ccd5a4470..fff967ed32e 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_Client.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_Client.cpp @@ -252,7 +252,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->set(" << operand << ");" << std::endl; } this->replica_->set(operand ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); counter = operand; break; } @@ -263,7 +263,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->get();" << std::endl; } long value = this->replica_->counter(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (value == operand) { std::cout << "FT Client: Good: Read " << value << " expecting " << operand << std::endl; @@ -284,7 +284,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->counter(" << operand << ");" << std::endl; } this->replica_->counter(operand ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); counter = operand; break; } @@ -295,7 +295,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->increment(" << operand << ");" << std::endl; } this->replica_->increment(operand ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); counter += operand; break; } @@ -306,7 +306,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->increment(" << -operand << ");" << std::endl; } this->replica_->increment(-operand ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); counter -= operand; break; } @@ -317,7 +317,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->counter();" << std::endl; } long attribute = this->replica_->counter(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); std::cout << "FT Client: Attribute: " << attribute << std::endl; echo = 0; break; @@ -329,7 +329,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->is_alive();" << std::endl; } int alive = this->replica_->is_alive(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); std::cout << "FT Client: Is alive? " << alive << std::endl; break; } @@ -340,7 +340,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->die(" << operand << ");" << std::endl; } this->replica_->die(ACE_static_cast (FT_TEST::TestReplica::Bane, operand) ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); echo = 0; break; } @@ -351,7 +351,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->get_state();" << std::endl; } state = this->replica_->get_state(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); stateValue = counter; break; } @@ -364,7 +364,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->set_state(saved_state);" << std::endl; } this->replica_->set_state(state ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); counter = stateValue; } else @@ -380,7 +380,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->get_update();" << std::endl; } update = this->replica_->get_update(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); updateValue = counter; break; } @@ -393,7 +393,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->set_update(saved_update);" << std::endl; } this->replica_->set_update(update ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); counter = updateValue; } else @@ -462,7 +462,7 @@ int FTClientMain::pass ( } long value = this->replica_->get(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (value == counter) { if (this->verbose_ >= NORMAL) @@ -489,7 +489,7 @@ int FTClientMain::next_replica (ACE_ENV_SINGLE_ARG_DECL) this->replica_name_ = this->replica_iors_[this->replica_pos_].c_str(); this->replica_pos_ += 1; CORBA::Object_var rep_obj = this->orb_->string_to_object (this->replica_name_ ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (0) replica_ = FT_TEST::TestReplica::_narrow (rep_obj); if (! CORBA::is_nil (replica_)) { @@ -513,17 +513,16 @@ int FTClientMain::run () int result = 0; this->orb_ = CORBA::ORB_init(this->argc_, this->argv_ ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1) if (next_replica ()) { - long counter = this->replica_->get(ACE_ENV_SINGLE_ARG_PARAMETER); - // retry information ACE_CString command; int retry = 0; + long counter = this->replica_->get(ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); - ACE_TRY_CHECK; if (this->verbose_ >= NORMAL) { std::cout << "FT Client: Initial counter " << counter << std::endl; diff --git a/TAO/orbsvcs/tests/FT_App/FT_Client_Unit.cpp b/TAO/orbsvcs/tests/FT_App/FT_Client_Unit.cpp index f0bd5ffc9d8..23c8c3136b0 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_Client_Unit.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_Client_Unit.cpp @@ -265,7 +265,7 @@ int FTClientUnitMain::run () argv_, 0 ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); FT_UnitTests unitTests(orb_); @@ -285,7 +285,7 @@ int FTClientUnitMain::run () { ACE_TRY_NEW_ENV { - result = do_commands(unitTests, more, command); + result = do_commands(unitTests, more, command); ACE_TRY_CHECK; } ACE_CATCH (CORBA::SystemException, sysex) diff --git a/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp b/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp index 05f1abfdee4..f0cf1e09e48 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_Creator.cpp @@ -21,13 +21,15 @@ 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) + : registry_ior_ (0) + , registry_ (0) + , replication_manager_ (0) + , have_replication_manager_ (0) + , write_iors_ (0) + , write_iogr_ (0) + , iogr_seq_ (0) + , ns_register_ (1) + , prefix_ ("") { } @@ -40,7 +42,7 @@ FTAPP::FT_Creator::parse_args (int argc, char *argv[]) { int result = 0; - ACE_Get_Opt get_opts (argc, argv, "r:f:u:gi"); + ACE_Get_Opt get_opts (argc, argv, "r:ignf:u:p:"); int c; while (result == 0 && (c = get_opts ()) != -1) @@ -65,13 +67,25 @@ FTAPP::FT_Creator::parse_args (int argc, char *argv[]) case 'g': { - make_iogr_ = !make_iogr_; + this->write_iogr_ = !this->write_iogr_; break; } case 'i': { - write_iors_ = ! write_iors_; + this->write_iors_ = ! this->write_iors_; + break; + } + + case 'n': + { + this->ns_register_ = !this->ns_register_; + break; + } + + case 'p': + { + this->prefix_ = get_opts.opt_arg(); break; } @@ -91,9 +105,9 @@ FTAPP::FT_Creator::parse_args (int argc, char *argv[]) } } - if ( this->create_roles_.size() == 0 && this->unregister_roles_.size()) + if ( this->create_roles_.size() == 0 && this->unregister_roles_.size() == 0) { - std::cerr << "Creator: neither create (-t) nor kill (-k) specified. Nothing to do." << std::endl; + std::cerr << "Creator: neither create (-t) nor kill (-u) specified. Nothing to do." << std::endl; usage (std::cerr); result = -1; } @@ -103,13 +117,15 @@ FTAPP::FT_Creator::parse_args (int argc, char *argv[]) void FTAPP::FT_Creator::usage(ostream & out)const { - out << "usage" - << " -r " - << " -f (if not specified, ReplicationManager is used.)" - << " -u " - << " -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; + out << "usage\n" + << " -r \n" + << " -f (if not specified, ReplicationManager is used.)\n" + << " -u \n" + << " -i (toggle write ior for each object (default false))\n" + << " -p \n" + << " -g (toggle write iogr to file (default false))\n" + << " -n (toggle register iogr with name service (default true))\n" + ; } @@ -123,11 +139,28 @@ int FTAPP::FT_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) if ( this->registry_ior_ != 0) { result = this->creator_.set_factory_registry(this->registry_ior_ ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1); } result = this->creator_.init (orb ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1); + + if (this->ns_register_) + { + CORBA::Object_var naming_obj = + this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + if (CORBA::is_nil(naming_obj.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "%T %n (%P|%t) Unable to find the Naming Service\n"), + 1); + } + this->naming_context_= + CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + } return result; } @@ -140,7 +173,55 @@ int FTAPP::FT_Creator::run (ACE_ENV_SINGLE_ARG_DECL) { 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_); + PortableGroup::ObjectGroup_var group = this->creator_.create_group ( + role, + this->write_iors_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + if (this->write_iogr_) + { + CORBA::String_var iogr = this->orb_->object_to_string (group ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + + char iogr_filename[1000]; + ACE_OS::snprintf (iogr_filename, sizeof(iogr_filename)-1, "%s%s_%d.iogr", + this->prefix_, + role, + this->iogr_seq_); + FILE * iogr_file = fopen (iogr_filename, "w"); + if (iogr_file != 0) + { + char const * siogr = ACE_static_cast (const char *, iogr); + fwrite (siogr, 1, strlen(siogr), iogr_file); + fclose (iogr_file); + } + else + { + std::cerr << "Can't open iogr output file " << iogr_filename << std::endl; + result = 1; + } + } + + if(this->ns_register_) + { + char iogr_name[1000]; + ACE_OS::snprintf (iogr_name, sizeof(iogr_name)-1, "%s_%s_%d", + this->prefix_, + role, + this->iogr_seq_); + + CosNaming::Name this_name (1); + this_name.length (1); + this_name[0].id = CORBA::string_dup (iogr_name); + + this->naming_context_->rebind (this_name, group.in() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (1); + } + + iogr_seq_ += 1; + } typeCount = this->unregister_roles_.size(); diff --git a/TAO/orbsvcs/tests/FT_App/FT_Creator.h b/TAO/orbsvcs/tests/FT_App/FT_Creator.h index 188ca583a11..4b80f0279a6 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_Creator.h +++ b/TAO/orbsvcs/tests/FT_App/FT_Creator.h @@ -71,27 +71,40 @@ namespace FTAPP StringVec unregister_roles_; - ::FT::ReplicationManager_var replication_manager_; + CosNaming::NamingContext_var naming_context_; + + ::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 + * bool: true if we should write individual IOR files */ - int make_iogr_; + int write_iors_; /** - * bool: true if we should write individual IOR files + * bool: true if we should write IOGR to a file */ - int write_iors_; + int write_iogr_; + + /** + * bool: true if we should write IOGR to a Name Service + */ + int ns_register_; /** * sequence number applied to created IOGRs */ unsigned long iogr_seq_; + /** + * prefix for names + */ + const char * prefix_; + + }; } // namespace TAO diff --git a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp index b3579e1d52c..4f683548b0e 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp @@ -303,24 +303,24 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); CORBA::Object_var this_obj = this->poa_->id_to_reference (object_id_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); this->ior_ = this->orb_->object_to_string (this_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (this->factory_registry_ior_ != 0) { @@ -328,7 +328,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) { CORBA::Object_var reg_obj = this->orb_->string_to_object(factory_registry_ior_ ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); this->factory_registry_ = ::PortableGroup::FactoryRegistry::_narrow(reg_obj); if (CORBA::is_nil(this->factory_registry_)) { @@ -412,7 +412,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) FT_TEST::_tc_TestReplica->id(), info ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); } this->registered_ = 1; } @@ -461,7 +461,7 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (CORBA::is_nil(naming_obj.in ())){ ACE_ERROR_RETURN ((LM_ERROR, @@ -471,14 +471,14 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) this->naming_context_ = CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); this->this_name_.length (1); this->this_name_[0].id = CORBA::string_dup (this->ns_name_); this->naming_context_->rebind (this->this_name_, this_obj.in() // CORBA::Object::_duplicate(this_obj) ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); } // if we're testing. Create a replica at startup time @@ -489,11 +489,11 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) FT_TestReplica_i * replica = create_replica ("test"); PortableServer::POA_var poa = replica->_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); ::CORBA::Object_var replica_obj = poa->servant_to_reference(replica ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); ::CORBA::String_var replicaIOR = this->orb_->object_to_string(replica_obj ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); write_ior (this->test_output_file_, replicaIOR); } @@ -511,7 +511,7 @@ int FT_ReplicaFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) { this->naming_context_->unbind (this_name_ ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1); this->ns_name_ = 0; } @@ -533,7 +533,7 @@ int FT_ReplicaFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) this->factory_registry_->unregister_factory_by_location ( location ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1); } else { @@ -554,7 +554,7 @@ int FT_ReplicaFactory_i::fini (ACE_ENV_SINGLE_ARG_DECL) roleName, location ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1); } } } diff --git a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h index c4959d5eb61..5fc2c6cb132 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h +++ b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h @@ -266,7 +266,6 @@ private: */ int quit_on_idle_; - /** * bool: use a single call to unregister. */ diff --git a/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp b/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp index c9b462892c4..4d678f5bfd9 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp @@ -67,19 +67,23 @@ namespace // Macros to simplify suicide. #define KEVORKIAN(value, method) \ - if (this->death_pending_ == (FT_TEST::TestReplica::value)){ \ + if (this->death_pending_ == (FT_TEST::TestReplica::value)){ \ suicide (#value " in method " #method); \ - CORBA::OBJECT_NOT_EXIST ex; \ - ACE_THROW(ex); \ + ACE_THROW (CORBA::NO_RESPONSE ( \ + CORBA::SystemException::_tao_minor_code ( \ + TAO_DEFAULT_MINOR_CODE, \ + EFAULT), \ + CORBA::COMPLETED_NO)); \ } else ; #define KEVORKIAN_DURING(method) \ - if (this->death_pending_ == FT_TEST::TestReplica::BEFORE_STATE_CHANGE \ - || this->death_pending_ == FT_TEST::TestReplica::BEFORE_REPLICATION \ - || this->death_pending_ == FT_TEST::TestReplica::BEFORE_REPLY ){ \ + if (this->death_pending_ == FT_TEST::TestReplica::BEFORE_REPLY ){\ suicide ("read-only method " #method); \ - CORBA::OBJECT_NOT_EXIST ex; \ - ACE_THROW(ex); \ + ACE_THROW (CORBA::NO_RESPONSE ( \ + CORBA::SystemException::_tao_minor_code ( \ + TAO_DEFAULT_MINOR_CODE, \ + EFAULT), \ + CORBA::COMPLETED_NO)); \ } else ; @@ -187,16 +191,16 @@ int FT_TestReplica_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); return 0; } @@ -288,8 +292,11 @@ void FT_TestReplica_i::set_state (const FT::State & s) #endif // FT_TEST_LACKS_STATE } -void FT_TestReplica_i::tao_update_object_group ( PortableGroup::ObjectGroup_ptr iogr - ACE_ENV_ARG_DECL) +void FT_TestReplica_i::tao_update_object_group ( + const char * iogr, + PortableGroup::ObjectGroupRefVersion version + ACE_ENV_ARG_DECL + ) ACE_THROW_SPEC ((CORBA::SystemException)) { ACE_THROW (CORBA::NO_IMPLEMENT()); diff --git a/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.h b/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.h index 1efbbf511c1..84ddcdb7869 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.h +++ b/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.h @@ -141,8 +141,11 @@ private: //////////////// // Implement TAO_UpdateObjectGroup - virtual void tao_update_object_group ( PortableGroup::ObjectGroup_ptr iogr - ACE_ENV_ARG_DECL) + virtual void tao_update_object_group ( + const char * iogr, + PortableGroup::ObjectGroupRefVersion version + ACE_ENV_ARG_DECL + ) ACE_THROW_SPEC ((CORBA::SystemException)); ///////////////// diff --git a/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp b/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp index ef16bd8efd1..438656abe79 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp @@ -863,7 +863,7 @@ int FT_UnitTests::readIORFile(const char * fileName, CORBA::String_var & ior) { buffer[fileSize] = '\0'; ior = CORBA::string_dup(buffer); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (0); result = 1; // success } delete[] buffer; diff --git a/TAO/orbsvcs/tests/FT_App/StubBatchConsumer.cpp b/TAO/orbsvcs/tests/FT_App/StubBatchConsumer.cpp index 106676a6a22..eeedd823696 100644 --- a/TAO/orbsvcs/tests/FT_App/StubBatchConsumer.cpp +++ b/TAO/orbsvcs/tests/FT_App/StubBatchConsumer.cpp @@ -74,22 +74,22 @@ int StubBatchConsumer::init (CORBA::ORB_var & orb, ::FT::FaultNotifier_var & not PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // find my identity as an object CORBA::Object_var this_obj = this->poa_->id_to_reference (object_id_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); CosNotifyFilter::Filter_var filter = CosNotifyFilter::Filter::_nil(); diff --git a/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp b/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp index c831f693403..8477ac3d7fa 100644 --- a/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp +++ b/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp @@ -217,7 +217,7 @@ int StubFaultAnalyzer::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) criteria.in(), factory_creation_id ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); } } } diff --git a/TAO/orbsvcs/tests/FT_App/StubFaultConsumer.cpp b/TAO/orbsvcs/tests/FT_App/StubFaultConsumer.cpp index 566b82d97bb..d7398809756 100644 --- a/TAO/orbsvcs/tests/FT_App/StubFaultConsumer.cpp +++ b/TAO/orbsvcs/tests/FT_App/StubFaultConsumer.cpp @@ -189,22 +189,22 @@ int StubFaultConsumer::init (CORBA::ORB_var & orb, PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // find my identity as an object CORBA::Object_var this_obj = this->poa_->id_to_reference (object_id_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); CosNotifyFilter::Filter_var filter = CosNotifyFilter::Filter::_nil(); @@ -311,4 +311,3 @@ void StubFaultConsumer::disconnect_structured_push_consumer(ACE_ENV_SINGLE_ARG_D #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) //# pragma instantiate ACE_Vector < const char * > #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - diff --git a/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp b/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp index 15e0d7bad5a..d4004fa3248 100644 --- a/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp +++ b/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp @@ -178,21 +178,21 @@ int StubFaultNotifier::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) PortableServer::POAManager_var poa_manager = this->poa_->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // Register with the POA. this->object_id_ = this->poa_->activate_object (this ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); // find my identity as a corba object CORBA::Object_var this_obj = this->poa_->id_to_reference (object_id_.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); ////////////////////////////////////////// // resolve references to detector factory @@ -278,7 +278,7 @@ int StubFaultNotifier::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) criteria.in(), factory_creation_id ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); } } } @@ -303,7 +303,7 @@ int StubFaultNotifier::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService" ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); if (CORBA::is_nil(naming_obj.in ())){ ACE_ERROR_RETURN ((LM_ERROR, @@ -313,15 +313,15 @@ int StubFaultNotifier::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) CosNaming::NamingContext_var naming_context = CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); CosNaming::Name this_name (1); this_name.length (1); this_name[0].id = CORBA::string_dup (this->ns_name_); - naming_context->rebind (this_name, this_obj.in() //CORBA::Object::_duplicate(this_obj) + naming_context->rebind (this_name, this_obj.in() ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_CHECK_RETURN (-1); } } return result; @@ -482,4 +482,3 @@ int StubFaultNotifier::idle(int & result) # pragma instantiate ACE_Vector < const char * > # pragma instantiate ACE_Vector < FT::PullMonitorable_var > #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - 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 2393614cae1..f8af3f0f943 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include @@ -24,7 +26,7 @@ TAO::Object_Group_Creator::Object_Group_Creator () : registry_(0) , replication_manager_(0) , have_replication_manager_(0) - , iogr_seq_(0) + , detector_infos_ (0) { } @@ -87,22 +89,36 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) ACE_TRY_CHECK; if (!CORBA::is_nil (this->registry_)) { - result = 0; // success + this->detector_infos_ = this->registry_->list_factories_by_role (FT::FAULT_DETECTOR_ROLE_NAME, this->detector_type_id_.out() + ACE_ENV_ARG_PARAMETER) + ACE_TRY_CHECK; + CORBA::ULong count = this->detector_infos_->length(); + ACE_DEBUG ((LM_DEBUG, + "%T %n (%P|%t)Object_Group_Creator: found %u factories for FaultDetectors\n", + ACE_static_cast (unsigned, count) + )); + result = 0; } else { - std::cerr << "Creator: ReplicationManager failed to return FactoryRegistry." << std::endl; + ACE_ERROR ((LM_ERROR, + "%T %n (%P|%t) Object_Group_Creator: ReplicationManager failed to return FactoryRegistry.\n" + )); + ACE_THROW (CORBA::NO_IMPLEMENT()); } } else { - std::cerr << "Creator: Can't resolve ReplicationManager, and no factory registry option was given." << std::endl; + ACE_ERROR ((LM_ERROR, + "%T %n (%P|%t) Object_Group_Creator: resolve_initial_references for ReplicationManager failed.\n" + )); + ACE_THROW (CORBA::OBJECT_NOT_EXIST()); } } ACE_CATCHANY { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Creator: Exception resolving ReplicationManager, and no -f option was given.\n"); + "Creator: Exception resolving ReplicationManager,\n"); result = 1; } @@ -115,32 +131,124 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) int TAO::Object_Group_Creator::unregister_role(const char * role ACE_ENV_ARG_DECL) { int result = 0; - std::cout << std::endl << "Creator: Unregistering all factories for " << role << std::endl; + ACE_ERROR ((LM_INFO, + "%T %n (%P|%t) Object_Group_Creator: Unregistering all factories for %s\n", + role + )); this->registry_->unregister_factory_by_role (role ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (-1); + return result; +} + + + +int TAO::Object_Group_Creator::create_detector_for_replica ( + CORBA::Object_ptr replica, + const char * role, + const char * type_id, + PortableGroup::ObjectGroupId group_id, + const PortableGroup::Location & location + ACE_ENV_ARG_DECL) +{ + int result = 0; + + CORBA::ULong detector_count = this->detector_infos_->length(); + for (CORBA::ULong n_detector = 0; result == 0 && n_detector < detector_count; ++n_detector) + { + PortableGroup::FactoryInfo & info = (*this->detector_infos_)[n_detector]; + if ( info.the_location == location || n_detector + 1 == detector_count) + { + TAO_PG::Properties_Encoder encoder; + + PortableGroup::Value value; + +/* + ////////////////// + // FaultDetectorFactory gets picky about FaultNotifier's object type. + // coddle it. + ::FT::FaultNotifier_var notifier = ::FT::FaultNotifier::_narrow(this_obj); + value <<= notifier; + encoder.add(::FT::FT_NOTIFIER, value); +*/ + + FT::PullMonitorable_ptr monitorable = FT::PullMonitorable::_narrow (replica); + value <<= monitorable; + encoder.add (::FT::FT_MONITORABLE, value); + + FT::FTDomainId domain_id = 0; + value <<= domain_id; + encoder.add (::FT::FT_DOMAIN_ID, value); + + value <<= location; + encoder.add (::FT::FT_LOCATION, value); + + value <<= type_id; + encoder.add (::FT::FT_TYPE_ID, value); + + value <<= group_id; + encoder.add (::FT::FT_GROUP_ID, value); + + value <<= CORBA::string_dup (role); + encoder.add (PortableGroup::role_criterion, value); + + // allocate and populate the criteria + FT::Criteria_var criteria; + ACE_NEW_NORETURN (criteria, + FT::Criteria); + if (criteria.ptr() == 0) + { + ACE_ERROR((LM_ERROR, + "%T %n (%P|%t)Object_Group_Creater: Error cannot allocate criteria.\n" + )); + result = -1; + } + else + { + encoder.encode(criteria); + FT::GenericFactory::FactoryCreationId_var factory_creation_id; + + info.the_factory->create_object ( + type_id, + criteria.in(), + factory_creation_id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + result = 1; + } + } + } return result; } -int TAO::Object_Group_Creator::create_group(const char * role, int write_iors, int write_iogr ACE_ENV_ARG_DECL) +CORBA::Object_ptr TAO::Object_Group_Creator::create_group( + const char * role, + int write_iors + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException )) { int result = 0; + CORBA::Object_var group; + PortableGroup::ObjectGroupId group_id = 0; CORBA::String_var type_id; ::PortableGroup::FactoryInfos_var infos = this->registry_->list_factories_by_role (role, type_id ACE_ENV_ARG_PARAMETER) - ACE_CHECK; + ACE_CHECK_RETURN (CORBA::Object::_nil()); CORBA::ULong count = infos->length(); - std::cout << "Creator: found " << count << " factories for " - << role << "(" << ACE_static_cast(const char *, type_id) << ")"<< std::endl; + ACE_ERROR ((LM_INFO, + "%T %n (%P|%t): Object_Group_Creator: found %u factories for %s : %s\n", + ACE_static_cast (unsigned, count), + role, + ACE_static_cast(const char *, type_id) + )); if (count > 0) { /////////////////////////// // Begin with an empty IOGR ::PortableGroup::GenericFactory::FactoryCreationId_var creation_id; - CORBA::Object_var group; - if (write_iogr && this->have_replication_manager_) + if (this->have_replication_manager_) { PortableGroup::Criteria criteria(1); criteria.length(1); @@ -154,43 +262,25 @@ int TAO::Object_Group_Creator::create_group(const char * role, int write_iors, i creation_id ACE_ENV_ARG_PARAMETER ); - ACE_CHECK; + ACE_CHECK_RETURN (CORBA::Object::_nil()); + + //@@ this is a bit of a hack + creation_id >>= group_id; } + const PortableGroup::Location * first_location = 0; + for (CORBA::ULong nFact = 0; nFact < count; ++nFact) { + ::PortableGroup::FactoryInfo & info = infos[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; - Location the_location; - Criteria the_criteria; - }; - */ const char * loc_name = info.the_location[0].id; - std::cout << "Creator: Creating " << role << " at " << loc_name << std::endl; + ACE_ERROR ((LM_INFO, + "%T %n (%P|%t) Object_Group_Creator: Creating %s@%s\n", + role, + loc_name + )); PortableGroup::GenericFactory::FactoryCreationId_var factory_creation_id; CORBA::Object_var created_obj = info.the_factory->create_object ( @@ -198,11 +288,24 @@ int TAO::Object_Group_Creator::create_group(const char * role, int write_iors, i info.the_criteria, factory_creation_id ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + ACE_CHECK_RETURN (CORBA::Object::_nil()); if ( !CORBA::is_nil(created_obj) ) { + if (nFact == 0) + { + first_location = & info.the_location; + } + create_detector_for_replica ( + created_obj, + role, + type_id.in(), + group_id, + info.the_location + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil()); + const char * replica_ior = orb_->object_to_string (created_obj ACE_ENV_ARG_PARAMETER ); - ACE_CHECK; + ACE_CHECK_RETURN (CORBA::Object::_nil()); if (write_iors) @@ -222,7 +325,9 @@ int TAO::Object_Group_Creator::create_group(const char * role, int write_iors, i } else { - std::cerr << "Can't decypher factory creation id." << std::endl; + ACE_ERROR ((LM_ERROR, + "%T %n (%P|%t) Object_Group_Creator: Can't decypher factory creation id.\n" + )); // Guessed wrong. Just use default value } @@ -234,61 +339,50 @@ int TAO::Object_Group_Creator::create_group(const char * role, int write_iors, i ACE_static_cast(unsigned long, ulong_id)); replica_ior_filename[sizeof(replica_ior_filename)-1] = '\0'; - std::cout << "Creator: Writing ior for created object to " << replica_ior_filename << std::endl; + ACE_ERROR ((LM_INFO, + "%T %n (%P|%t) Object_Group_Creator: Writing ior for created object to %s\n", + replica_ior_filename + )); if (write_ior_file(replica_ior_filename, replica_ior) != 0) { - std::cerr << "Creator: Error writing ior [" << replica_ior << "] to " << replica_ior_filename << std::endl; + ACE_ERROR ((LM_ERROR, + "%T %n (%P|%t) Object_Group_Creator: Error writing ior [%s] to %s\n", + replica_ior, + replica_ior_filename + )); } } - if (write_iogr && this->have_replication_manager_) - { - 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) - { - group = this->replication_manager_->set_primary_member(group, info.the_location - ACE_ENV_ARG_PARAMETER); - } -#endif// DEBUG_DISABLE - } + group = this->replication_manager_->add_member (group, + info.the_location, + created_obj + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil()); } else { - std::cerr << "Creator: create_object returned nil????" << std::endl; + ACE_ERROR ((LM_ERROR, + "%T %n (%P|%t) Object_Group_Creator: create_object returned nil????\n" + )); } } - std::cout << "Creator: Successfully created group of " << role << std::endl; - - if(write_iogr && have_replication_manager_) + if (first_location != 0) { - const char * group_iogr = orb_->object_to_string (group ACE_ENV_ARG_PARAMETER ); - ACE_CHECK; - char group_ior_filename[200]; - - ACE_OS::snprintf(group_ior_filename, sizeof(group_ior_filename)-1, "%s_%lu.iogr", - role, - this->iogr_seq_); - group_ior_filename[sizeof(group_ior_filename)-1] = '\0'; - - std::cout << "Creator: Writing ior for created object group to " << group_ior_filename << std::endl; - - if (write_ior_file(group_ior_filename, group_iogr) != 0) - { - std::cerr << "Creator: Error writing ior [" << group_iogr << "] to " << group_ior_filename << std::endl; - } - this->iogr_seq_ += 1; + group = this->replication_manager_->set_primary_member (group.in(), * first_location ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil()); } + ACE_ERROR ((LM_INFO, + "%T %n (%P|%t) Object_Group_Creator: Successfully created group of %s\n", + role + )); + const char * group_iogr = orb_->object_to_string (group ACE_ENV_ARG_PARAMETER ); + ACE_CHECK_RETURN (CORBA::Object::_nil()); } - return result; + return group._retn(); } @@ -310,7 +404,7 @@ int TAO::Object_Group_Creator::write_ior_file(const char * outputFile, const cha else { ACE_ERROR ((LM_ERROR, - "Open failed for %s\n", outputFile + "%T %n (%P|%t) Object_Group_Creator: Open failed for %s\n", outputFile )); } return result; 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 dcd18de0d47..0a0bfc89f10 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h @@ -48,7 +48,12 @@ namespace TAO ///////////////// // functionality - int create_group(const char * role, int write_iors, int write_iogr ACE_ENV_ARG_DECL); + CORBA::Object_ptr create_group( + const char * role, + int write_iors + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + int unregister_role(const char * role ACE_ENV_ARG_DECL); //////////// @@ -60,6 +65,14 @@ namespace TAO private: int write_ior_file(const char * outputFile, const char * ior); + int create_detector_for_replica ( + CORBA::Object_ptr replica, + const char * role, + const char * type_id, + PortableGroup::ObjectGroupId group_id, + const PortableGroup::Location & location + ACE_ENV_ARG_DECL); + //////////////////// // forbidden methods private: @@ -72,18 +85,16 @@ namespace TAO CORBA::ORB_var orb_; PortableGroup::FactoryRegistry_var registry_; - ::FT::ReplicationManager_var replication_manager_; + ::FT::ReplicationManager_var replication_manager_; + + ::PortableGroup::FactoryInfos_var detector_infos_; + CORBA::String_var detector_type_id_; + /** * bool: true if we have a real replication manager */ int have_replication_manager_; - - /** - * sequence number applied to created IOGRs - */ - unsigned long iogr_seq_; - }; } // namespace TAO diff --git a/TAO/orbsvcs/tests/FT_App/run_test_iogr.pl b/TAO/orbsvcs/tests/FT_App/run_test_iogr.pl index d8749d5b201..62608d4ae74 100644 --- a/TAO/orbsvcs/tests/FT_App/run_test_iogr.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_iogr.pl @@ -188,9 +188,9 @@ if ($simulated) { }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"); + $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); + $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica2_iogr -c testscript"); + $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica3_iogr -c testscript"); } ####################### diff --git a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl index d3fe654b14e..d54dce3e5ac 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl @@ -182,9 +182,9 @@ if ($simulated) { $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); - $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"); + $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); + $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica2_iogr -c testscript"); + $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica3_iogr -c testscript"); } ####################### diff --git a/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl b/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl index 29120a798e8..f3022171159 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_rmregistry.pl @@ -132,6 +132,9 @@ my($location2) = "bree"; my($location3) = "rivendell"; my($location4) = "rohan"; +my ($rm_endpoint) = "-ORBEndpoint iiop://localhost:2833"; +my ($rm_initref) = "-ORBInitRef ReplicationManager=corbaloc::localhost:2833/ReplicationManager"; + #define temp files my($rm_ior) = PerlACE::LocalFile ("rm.ior"); my($factory1_ior) = PerlACE::LocalFile ("factory1.ior"); @@ -168,12 +171,12 @@ 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) = new PerlACE::Process (".$build_directory/ft_create", "-ORBInitRef ReplicationManager=file://$rm_ior -r $role1 -r $role2 -r $role1 -u $role3"); +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($FAC1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ior $rm_initref -l $location1 -i $role1 -q"); +my($FAC2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior $rm_initref -l $location2 -i $role1 -i $role2 -i $role3 -q -u"); +my($FAC3) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory3_ior $rm_initref -l $location3 -i $role2 -q -u"); +my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "$rm_initref -r $role1 -r $role2 -r $role1 -u $role3"); my($CL1); my($CL2); @@ -185,9 +188,9 @@ if ($simulated) { $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); - $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"); + $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); + $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica2_iogr -c testscript"); + $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica3_iogr -c testscript"); } ####################### diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp index 30c2b1351b5..6ca0caf0e63 100644 --- a/TAO/tao/Object.cpp +++ b/TAO/tao/Object.cpp @@ -924,7 +924,6 @@ operator>> (TAO_InputCDR& cdr, CORBA::Object*& x) if (pfile != 0) mp.give_profile (pfile); } - // Make sure we got some profiles! if (mp.profile_count () != profile_count) { @@ -934,7 +933,9 @@ operator>> (TAO_InputCDR& cdr, CORBA::Object*& x) ACE_LIB_TEXT ("TAO (%P|%t) ERROR: Could not create all ") ACE_LIB_TEXT ("profiles while extracting object\n") ACE_LIB_TEXT ("TAO (%P|%t) ERROR: reference from the ") - ACE_LIB_TEXT ("CDR stream.\n")), + ACE_LIB_TEXT ("CDR stream.[%u | %u]\n"), + ACE_static_cast (unsigned, mp.profile_count()), + ACE_static_cast (unsigned, profile_count) ), 0); } -- cgit v1.2.1