diff options
author | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-10-14 15:57:39 +0000 |
---|---|---|
committer | wilson_d <wilson_d@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-10-14 15:57:39 +0000 |
commit | 5a6cfab6e4d6958fd1e0bb3d7661952d4dcea799 (patch) | |
tree | c2fc08a8ac9edf24eca979970f510f70342e7da5 | |
parent | 66e734cff807a727fd6539f7d2207c592534f549 (diff) | |
download | ATCD-5a6cfab6e4d6958fd1e0bb3d7661952d4dcea799.tar.gz |
ChangeLogTag: Tue Oct 14 10:22:13 2003 Dale Wilson <wilson_d@ociweb.com>
-rw-r--r-- | TAO/ChangeLog | 51 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl | 23 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/FT_Client.cpp | 203 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp | 116 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp | 251 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.h | 13 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp | 239 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/StubFaultNotifier.h | 5 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp | 308 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h | 23 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/FT_App/run_test_basic.pl | 28 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/FT_App/run_test_detector.pl | 16 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl | 6 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/FT_App/run_test_notifier.pl | 6 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/FT_App/run_test_registry.pl | 111 |
17 files changed, 634 insertions, 776 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index e36dfeda5ed..f00cf58664f 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,48 @@ +Tue Oct 14 10:22:13 2003 Dale Wilson <wilson_d@ociweb.com> + + * orbsvcs/orbsvcs/FT_ReplicationManager.idl: + remove the unneeded create_test_iogr method + add get_factory_registry method + syntax error: s/void oneway/oneway void/ shutdown + + * orbsvcs/tests/FT_App/FT_Client.cpp: + eliminate use of Tao/examples/Simple.. stuff + + common changes below + + * orbsvcs/tests/FT_App/StubFaultNotifier.h: + * orbsvcs/tests/FT_App/StubFaultNotifier.cpp: + explicit FaultNotifier type in criteria's any. + + common changes below + + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h: + * orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp: + add -k command line option: -k type_id unregisters all factories for type_id + if -f <factory registry> option is not specified, + use resolve_initial_references("ReplicationManager") to find either + a factory registry or a replication manager from which a factory registry + can be retrieved. + + common changes below + + * orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h: + * orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp: + * orbsvcs/tests/FT_App/FT_TestReplica_i.cpp: + * orbsvcs/tests/FT_App/StubFaultAnalyzer.h: + * orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp: + common changes = + change command line option that specify multiple + iors from -f a,b,c to -f a -f b -f c + eliminate read_ior_file. Expect file:// ior on command line instead. + + * orbsvcs/tests/FT_App/run_test_basic.pl: + * orbsvcs/tests/FT_App/run_test_detector.pl: + * orbsvcs/tests/FT_App/run_test_fault_consumer.pl: + * orbsvcs/tests/FT_App/run_test_notifier.pl: + * orbsvcs/tests/FT_App/run_test_registry.pl: + Change command line options to use the //file: ior syntax when necessary. + Pass the factoryregistry in as a pseudo replication manager + + These changes were made in the oci_haft branch. + Mon Oct 13 11:37:03 2003 Steve Totten <totten_s@ociweb.com> * orbsvcs/orbsvcs/FT_ReplicationManager.idl: @@ -15,6 +60,8 @@ Mon Oct 13 11:37:03 2003 Steve Totten <totten_s@ociweb.com> * orbsvcs/tests/FT_App/run_test_replication_mgr.pl: Added this unit test (still in work). + These changes were made in the oci_haft branch. + Fri Oct 10 17:19:03 2003 Steve Totten <totten_s@ociweb.com> * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp: @@ -24,6 +71,8 @@ Fri Oct 10 17:19:03 2003 Steve Totten <totten_s@ociweb.com> More clean up of Replication Manager code. Initial integration of FT_FaultConsumer into Replication Manager. + These changes were made in the oci_haft branch. + Fri Oct 10 13:58:04 2003 Steve Totten <totten_s@ociweb.com> * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp: @@ -88,7 +137,7 @@ Fri Oct 10 12:09:39 2003 Dale Wilson <wilson_d@ociweb.com> * orbsvcs/tests/FT_App/run_test_registry.pl: Test is working. - + * orbsvcs/tests/FT_App/testscript: Shorten sleep to make the test run faster diff --git a/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl b/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl index 12fa0d389f7..f70950986da 100644 --- a/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl +++ b/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl @@ -44,15 +44,26 @@ module FT FaultNotifier get_fault_notifier() raises (InterfaceNotFound); - /** - * Creates and returns a dummy IOGR for unit testing - */ - ObjectGroup create_test_iogr (); - + /** + * Find a registry for factories that create fault tolerant replicas. + * + * TAO-specific method + * + * Factories in this registry will be used by the ReplicationManager's implementation + * of GenericFactory::create_object when infrastructure controlled membership is specified. + * + * The factory registry may also be used by applications that control their own + * membership but don't wish to address the issue of finding factories for replicas. + * + * @param selection_criteria to be used to choose among alternate registries (future enhancement.) + * @returns an implementation of FactoryRegistry + */ + ::PortableGroup::FactoryRegistry get_factory_registry (in ::PortableGroup::Criteria selection_criteria); + /** * TAO-specific shutdown operation. */ - void oneway shutdown (); + oneway void shutdown (); }; }; diff --git a/TAO/orbsvcs/tests/FT_App/FT_Client.cpp b/TAO/orbsvcs/tests/FT_App/FT_Client.cpp index a41f99c9b19..c3a32c771eb 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_Client.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_Client.cpp @@ -1,14 +1,15 @@ // $Id$ #include "FT_TestReplicaC.h" -// the following include is relative to $TAO_ROOT -#include <examples/Simple/Simple_util.h> +#include <ace/Vector_T.h> +#include <ace/SString.h> +#include <ace/Get_Opt.h> #include <iostream> #include <fstream> class FTClientMain { - typedef Client<FT_TEST::TestReplica, FT_TEST::TestReplica_var> ServerVar; + typedef ACE_Vector<ACE_CString> StringVec; public: /////////////////////////// // construction/destruction @@ -30,13 +31,15 @@ private: void usage (ostream & out)const; void commandUsage (ostream & out); int pass ( - ServerVar & ft_server, // in long & counter, // inout int & more, // out ACE_CString & command, // inout int retry // in ); + + int next_replica (ACE_ENV_SINGLE_ARG_DECL); + //////////////////// // forbidden methods private: @@ -46,6 +49,9 @@ private: //////////////// // Data members private: + + CORBA::ORB_var orb_; + int argc_; char ** argv_; const char * inFileName_; @@ -60,19 +66,19 @@ private: LOUD} verbose_; - char * fargValue_; - char * fargPos_; - char * fargEnd_; + StringVec replica_iors_; + size_t replica_pos_; + const char * replica_name_; + FT_TEST::TestReplica_var replica_; }; FTClientMain::FTClientMain () : commandIn_(&std::cin) , verbose_(NORMAL) - , fargValue_(0) - , fargPos_(0) - , fargEnd_(0) + , replica_pos_(0) + , replica_name_("none") { } @@ -82,8 +88,6 @@ FTClientMain::~FTClientMain () { this->inFile_.close(); } - ACE_OS::free (this->fargValue_); - this->fargValue_ = 0; } void FTClientMain::commandUsage(ostream & out) @@ -147,51 +151,17 @@ FTClientMain::parse_args (int argc, char *argv[]) this->argv_ = argv; int result = 0; - // find the -f filename argument - // and treat it specially - this->fargValue_ = 0; - int nArg; - for(nArg = 1; this->fargValue_ == 0 && nArg < argc - 1; ++nArg) - { - if (argv[nArg][0] == '-' - && argv[nArg][1] == 'f' - && argv[nArg][2] == '\0') - { - // remember the starting, current, and ending position of farg - this->fargValue_ = ACE_OS::strdup(argv[nArg+1]); - this->fargPos_ = this->fargValue_; - this->fargEnd_ = this->fargValue_ + ACE_OS::strlen(this->fargPos_); - - // find a comma delimiter, and - // chop the string there. - char * delim = ACE_OS::strchr (this->fargValue_, ','); - while(delim != 0) - { - *delim = '\0'; - delim = ACE_OS::strchr (delim + 1, ','); - } - argv[nArg+1] = this->fargValue_; - - std::cout << "FT Client: Initial primary replica: " << this->fargPos_ << std::endl; - - // point fargPos at the next filename - this->fargPos_ = this->fargPos_ + ACE_OS::strlen(this->fargPos_); - if (this->fargPos_ != this->fargEnd_) - { - this->fargPos_ += 1; - } - } - } - // note: dfnkx are simple_util options // include them here so we can detect bad args ACE_Get_Opt get_opts (argc, argv, "c:df:g:nk:x"); int c; while (result == 0 && (c = get_opts ()) != -1) + { switch (c) - { + { case 'c': + { this->inFileName_ = get_opts.opt_arg (); this->inFile_.open(this->inFileName_); if(this->inFile_.is_open() && this->inFile_.good()) @@ -205,9 +175,14 @@ FTClientMain::parse_args (int argc, char *argv[]) result = -1; } break; + } + case 'f': + { + replica_iors_.push_back(get_opts.opt_arg ()); + break; + } case 'd': - case 'f': case 'k': case 'n': case 'x': @@ -224,8 +199,8 @@ FTClientMain::parse_args (int argc, char *argv[]) case '?': usage(std::cerr); result = 1; - } - // Indicates sucessful parsing of the command line + } + } return result; } @@ -240,7 +215,6 @@ void FTClientMain::usage(ostream & out)const } int FTClientMain::pass ( - ServerVar & ft_server, long & counter, int & more, ACE_CString & command, @@ -292,7 +266,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->set(" << operand << ");" << std::endl; } - ft_server->set(operand ACE_ENV_ARG_PARAMETER); + this->replica_->set(operand ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; counter = operand; break; @@ -303,7 +277,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->get();" << std::endl; } - long value = ft_server->counter(ACE_ENV_SINGLE_ARG_PARAMETER); + long value = this->replica_->counter(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; if (value == operand) { @@ -324,7 +298,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->counter(" << operand << ");" << std::endl; } - ft_server->counter(operand ACE_ENV_ARG_PARAMETER); + this->replica_->counter(operand ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; counter = operand; break; @@ -335,7 +309,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->increment(" << operand << ");" << std::endl; } - ft_server->increment(operand ACE_ENV_ARG_PARAMETER); + this->replica_->increment(operand ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; counter += operand; break; @@ -346,7 +320,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->increment(" << -operand << ");" << std::endl; } - ft_server->increment(-operand ACE_ENV_ARG_PARAMETER); + this->replica_->increment(-operand ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; counter -= operand; break; @@ -357,7 +331,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->counter();" << std::endl; } - long attribute = ft_server->counter(ACE_ENV_SINGLE_ARG_PARAMETER); + long attribute = this->replica_->counter(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; std::cout << "FT Client: Attribute: " << attribute << std::endl; echo = 0; @@ -369,7 +343,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->is_alive();" << std::endl; } - int alive = ft_server->is_alive(ACE_ENV_SINGLE_ARG_PARAMETER); + int alive = this->replica_->is_alive(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; std::cout << "FT Client: Is alive? " << alive << std::endl; break; @@ -380,7 +354,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->die(" << operand << ");" << std::endl; } - ft_server->die(ACE_static_cast (FT_TEST::TestReplica::Bane, operand) ACE_ENV_ARG_PARAMETER); + this->replica_->die(ACE_static_cast (FT_TEST::TestReplica::Bane, operand) ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; echo = 0; break; @@ -391,7 +365,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->get_state();" << std::endl; } - state = ft_server->get_state(ACE_ENV_SINGLE_ARG_PARAMETER); + state = this->replica_->get_state(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; stateValue = counter; break; @@ -404,7 +378,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->set_state(saved_state);" << std::endl; } - ft_server->set_state(state ACE_ENV_ARG_PARAMETER); + this->replica_->set_state(state ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; counter = stateValue; } @@ -420,7 +394,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->get_update();" << std::endl; } - update = ft_server->get_update(ACE_ENV_SINGLE_ARG_PARAMETER); + update = this->replica_->get_update(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; updateValue = counter; break; @@ -433,7 +407,7 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->set_update(saved_update);" << std::endl; } - ft_server->set_update(update ACE_ENV_ARG_PARAMETER); + this->replica_->set_update(update ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; counter = updateValue; } @@ -468,11 +442,11 @@ int FTClientMain::pass ( { std::cout << "FT Client: ->shutdown();" << std::endl; } - ft_server->shutdown( ACE_ENV_SINGLE_ARG_PARAMETER); + this->replica_->shutdown( ACE_ENV_SINGLE_ARG_PARAMETER); // @@ Note: this is here because the corba event loop seems to go to sleep // if there's nothing for it to do. // not quite sure why, yet. Dale - ft_server->is_alive(ACE_ENV_SINGLE_ARG_PARAMETER); + this->replica_->is_alive(ACE_ENV_SINGLE_ARG_PARAMETER); } ACE_CATCHANY { @@ -502,7 +476,7 @@ int FTClientMain::pass ( std::cout << "FT Client: ->get();" << std::endl; } - long value = ft_server->get(ACE_ENV_SINGLE_ARG_PARAMETER); + long value = this->replica_->get(ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; if (value == counter) { @@ -522,17 +496,43 @@ int FTClientMain::pass ( return result; } +int FTClientMain::next_replica (ACE_ENV_SINGLE_ARG_DECL) +{ + int result = 0; + if (this->replica_pos_ < this->replica_iors_.size()) + { + 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; + replica_ = FT_TEST::TestReplica::_narrow (rep_obj); + if (! CORBA::is_nil (replica_)) + { + result = 1; + } + else + { + std::cerr << "FT Client: Can't resolve IOR: " << this->replica_name_ << std::endl; + } + } + else + { + std::cerr << "***OUT_OF_REPLICAS*** " << this->replica_pos_ << std::endl; + } + return result; +} + + int FTClientMain::run () { int result = 0; - ServerVar ft_server; - // Initialize the ft_server. - result = ft_server.init ("FT_TEST",this->argc_, this->argv_); + this->orb_ = CORBA::ORB_init(this->argc_, this->argv_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - if ( result == 0) + if (next_replica ()) { - long counter = ft_server->get(ACE_ENV_SINGLE_ARG_PARAMETER); + long counter = this->replica_->get(ACE_ENV_SINGLE_ARG_PARAMETER); // retry information ACE_CString command; @@ -553,7 +553,7 @@ int FTClientMain::run () { ACE_TRY_NEW_ENV { - result = pass(ft_server, counter, more, command, retry); + result = pass (counter, more, command, retry); ACE_TRY_CHECK; } ACE_CATCH (CORBA::SystemException, sysex) @@ -563,41 +563,32 @@ int FTClientMain::run () retry = 0; int handled = 0; - if(this->fargPos_ != 0 && this->fargPos_ != this->fargEnd_) + + handled = next_replica(); + if (handled) { - handled = ! ft_server.reconnect_file(this->fargPos_); - if (handled) + std::cout << "FT Client: Recovering from fault." << std::endl; + std::cout << "FT Client: Activate " << this->replica_name_ << std::endl; + if (command.length () == 0) { - std::cout << "FT Client: Recovering from fault." << std::endl; - std::cout << "FT Client: Activate " << this->fargPos_ << std::endl; - if (command.length () == 0) - { - std::cout << "FT Client: No command to retry." << std::endl; - } - else if (command[0] == 'd') - { - std::cout << "FT Client: Not retrying \"die\" command." << std::endl; - } - else if (sysex.completed () == CORBA::COMPLETED_YES) - { - std::cout << "FT Client: Last command completed. No retry needed." << std::endl; - } - else - { - if (sysex.completed () == CORBA::COMPLETED_MAYBE) - { - std::cout << "FT Client: Last command may have completed. Retrying anyway." << std::endl; - } - retry = 1; - std::cout << "FT Client: Retrying command: " << command << std::endl; - } - - // advance fargPos to next filename - this->fargPos_ += ACE_OS::strlen(this->fargPos_); - if (this->fargPos_ != this->fargEnd_) + std::cout << "FT Client: No command to retry." << std::endl; + } + else if (command[0] == 'd') + { + std::cout << "FT Client: Not retrying \"die\" command." << std::endl; + } + else if (sysex.completed () == CORBA::COMPLETED_YES) + { + std::cout << "FT Client: Last command completed. No retry needed." << std::endl; + } + else + { + if (sysex.completed () == CORBA::COMPLETED_MAYBE) { - this->fargPos_ += 1; + std::cout << "FT Client: Last command may have completed. Retrying anyway." << std::endl; } + retry = 1; + std::cout << "FT Client: Retrying command: " << command << std::endl; } } if (! handled) @@ -641,6 +632,8 @@ main (int argc, char *argv[]) #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template Client<FT_TEST::TestReplica, FT_TEST::TestReplica_var>; + template ACE_Vector<ACE_CString>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) # pragma instantiate Client<FT_TEST::TestReplica, FT_TEST::TestReplica_var> +# pragma ACE_Vector<ACE_CString> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp index 98b0dd37978..9f35d104f4a 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.cpp @@ -51,10 +51,10 @@ static const char * type_initial_value = "INITIAL_VALUE"; FT_ReplicaFactory_i::FT_ReplicaFactory_i () : ior_output_file_(0) - , factory_registry_ior_file_(0) + , factory_registry_ior_(0) , registered_(0) , ns_name_(0) - , location_(0) + , location_("unknown") , quit_on_idle_(0) , unregister_by_location_(0) , test_output_file_(0) @@ -157,7 +157,7 @@ int FT_ReplicaFactory_i::parse_args (int argc, char * argv[]) } case 'f': { - this->factory_registry_ior_file_ = get_opts.opt_arg (); + this->factory_registry_ior_ = get_opts.opt_arg (); break; } case 'i': @@ -378,71 +378,59 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) ACE_TRY_CHECK; - if (factory_registry_ior_file_ != 0) + if (factory_registry_ior_ != 0) { - CORBA::String_var registry_ior; - if (read_ior_file(this->factory_registry_ior_file_, registry_ior)) + CORBA::Object_var reg_obj = this->orb_->string_to_object(factory_registry_ior_ + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + this->factory_registry_ = ::PortableGroup::FactoryRegistry::_narrow(reg_obj); + if (! CORBA::is_nil(factory_registry_)) { - CORBA::Object_var reg_obj = this->orb_->string_to_object(registry_ior - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - this->factory_registry_ = ::PortableGroup::FactoryRegistry::_narrow(reg_obj); - if (! CORBA::is_nil(factory_registry_)) + ::PortableGroup::GenericFactory_var this_var = ::PortableGroup::GenericFactory::_narrow(this_obj); + if (! CORBA::is_nil(this_var)) { - ::PortableGroup::GenericFactory_var this_var = ::PortableGroup::GenericFactory::_narrow(this_obj); - if (! CORBA::is_nil(this_var)) - { - size_t typeCount = types_.size(); - for (size_t nType = 0; nType < typeCount; ++nType) - { - const char * typeId = this->types_[nType].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(type_property); - info.the_criteria[0].val <<= CORBA::string_dup(typeId); - - ACE_ERROR (( LM_INFO, - "Factory: %s@%s registering with factory registry\n", - typeId, - location_ - )); - - factory_registry_->register_factory( - typeId, - info - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - this->registered_ = 1; - } - else + size_t typeCount = types_.size(); + for (size_t nType = 0; nType < typeCount; ++nType) { - ACE_ERROR (( LM_ERROR, - "Unexpected error: object reference should be a ReplicaFactory?\n" + const char * typeId = this->types_[nType].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(type_property); + info.the_criteria[0].val <<= CORBA::string_dup(typeId); + + ACE_ERROR (( LM_INFO, + "Factory: %s@%s registering with factory registry\n", + typeId, + location_ )); + + factory_registry_->register_factory( + typeId, + info + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } + this->registered_ = 1; } else { ACE_ERROR (( LM_ERROR, - "Can't resolve Factory Registry IOR %s\n", - this->factory_registry_ior_file_ + "Unexpected error: object reference should be a ReplicaFactory?\n" )); - result = -1; } } else { ACE_ERROR (( LM_ERROR, - "Can't read %s\n", - this->factory_registry_ior_file_ - )); + "Can't resolve Factory Registry IOR %s\n", + this->factory_registry_ior_ + )); result = -1; } } @@ -525,32 +513,6 @@ int FT_ReplicaFactory_i::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) return result; } -int FT_ReplicaFactory_i::read_ior_file(const char * fileName, CORBA::String_var & ior) -{ - int result = 0; - FILE *in = ACE_OS::fopen (fileName, "r"); - ACE_OS::fseek(in, 0, SEEK_END); - size_t fileSize = ACE_OS::ftell(in); - ACE_OS::fseek(in, 0, SEEK_SET); - char * buffer; - ACE_NEW_NORETURN (buffer, - char[fileSize+1]); - if (buffer != 0) - { - if( fileSize == ACE_OS::fread(buffer, 1, fileSize, in)) - { - buffer[fileSize] = '\0'; - ior = CORBA::string_dup(buffer); - ACE_TRY_CHECK; - result = 1; // success - } - delete[] buffer; - } - return result; -} - - - void FT_ReplicaFactory_i::remove_replica(CORBA::ULong id, FT_TestReplica_i * replica) { InternalGuard guard (this->internals_); diff --git a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h index e89f45a6552..d3cabb80674 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h +++ b/TAO/orbsvcs/tests/FT_App/FT_ReplicaFactory_i.h @@ -159,11 +159,6 @@ private: int write_ior (const char * outputFile, const char * ior); /** - * Read IOR from a file - */ - int read_ior_file(const char * fileName, CORBA::String_var & ior); - - /** * Clean house for factory shut down. */ void shutdown_i (); @@ -214,9 +209,9 @@ private: const char * ior_output_file_; /** - * A file from which to read the factory registry IOR + * The factory registry IOR */ - const char * factory_registry_ior_file_; + const char * factory_registry_ior_; /** * The factory registry with which to register. diff --git a/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp b/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp index 242f1753f48..816068ff57b 100644 --- a/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp +++ b/TAO/orbsvcs/tests/FT_App/FT_TestReplica_i.cpp @@ -92,10 +92,12 @@ FT_TestReplica_i::FT_TestReplica_i (FT_ReplicaFactory_i * factory, const char * , death_pending_(FT_TEST::TestReplica::NOT_YET) , verbose_(1) { +// std::cout << name_.c_str() << '@' << this->factory_->location() << '#' << this->factory_id_ << " Construct" << std::endl; } FT_TestReplica_i::~FT_TestReplica_i () { +// std::cout << name_.c_str() << '@' << this->factory_->location() << '#' << this->factory_id_ << " Destruct" << std::endl; } diff --git a/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp b/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp index ec9ba25d4a2..ddcd925f5e2 100644 --- a/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp +++ b/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.cpp @@ -10,11 +10,9 @@ #include <fstream> StubFaultAnalyzer::StubFaultAnalyzer () - : replicaIorBuffer_(0) - , readyFile_(0) - , iorDetectorFile_(0) - , iorNotifierFile_(0) - + : readyFile_(0) + , detector_ior_(0) + , notifier_ior_(0) { } @@ -35,59 +33,17 @@ int StubFaultAnalyzer::parse_args (int argc, char * argv[]) { case 'r': { - if (this->replicaIorBuffer_ == 0) - { - const char * repNames = get_opts.opt_arg (); - size_t repNameLen = ACE_OS::strlen(repNames); - - // make a working copy of the string - ACE_NEW_NORETURN(this->replicaIorBuffer_, - char[repNameLen + 1]); - if ( this->replicaIorBuffer_ != 0) - { - ACE_OS::memcpy(this->replicaIorBuffer_, repNames, repNameLen+1); - - // tokenize the string on ',' - // into iorReplicaFiles_ - char * pos = this->replicaIorBuffer_; - while (pos != 0) - { - this->iorReplicaFiles_.push_back(pos); - // find a comma delimiter, and - // chop the string there. - pos = ACE_OS::strchr (pos, ','); - if (pos != 0) - { - *pos = '\0'; - pos += 1; - } - } - } - else - { - ACE_ERROR ((LM_ERROR, - "Command line option error: -r can't allocate buffer.\n" - )); - optionError = -1; - } - } - else - { - ACE_ERROR ((LM_ERROR, - "Command line option error: -r specified more than once.\n" - )); - optionError = -1; - } + this->replicaIORs.push_back (get_opts.opt_arg ()); break; } case 'd': { - this->iorDetectorFile_ = get_opts.opt_arg (); + this->detector_ior_ = get_opts.opt_arg (); break; } case 'n': { - this->iorNotifierFile_ = get_opts.opt_arg (); + this->notifier_ior_ = get_opts.opt_arg (); break; } case 'o': @@ -107,21 +63,22 @@ int StubFaultAnalyzer::parse_args (int argc, char * argv[]) if(! optionError) { - if (0 == this->replicaIorBuffer_) + if (0 == replicaIORs.size()) { ACE_ERROR ((LM_ERROR, - "-r option is required.\n" + "at least one -r option is required.\n" )); optionError = -1; } - if (0 == this->iorDetectorFile_) + + if (0 == this->detector_ior_) { ACE_ERROR ((LM_ERROR, "-d option is required.\n" )); optionError = -1; } - if (0 == this->iorNotifierFile_) + if (0 == this->notifier_ior_) { ACE_ERROR ((LM_ERROR, "-n option is required.\n" @@ -154,39 +111,21 @@ int StubFaultAnalyzer::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) this->orb_ = orb; ////////////////////////////////////////// // resolve reference to detector factory - CORBA::String_var factoryIOR; - if (readIORFile(this->iorDetectorFile_, factoryIOR)) - { - CORBA::Object_var obj = this->orb_->string_to_object(factoryIOR); - this->factory_ = ::FT::FaultDetectorFactory::_narrow(obj); - if (CORBA::is_nil(this->factory_)) - { - std::cerr << "Can't resolve Detector Factory IOR " << this->iorDetectorFile_ << std::endl; - result = -1; - } - } - else + CORBA::Object_var detector_obj = this->orb_->string_to_object(this->detector_ior_); + this->factory_ = ::FT::FaultDetectorFactory::_narrow(detector_obj); + if (CORBA::is_nil(this->factory_)) { - std::cerr << "Can't read " << this->iorDetectorFile_ << std::endl; + std::cerr << "Can't resolve Detector Factory IOR " << this->detector_ior_ << std::endl; result = -1; } ////////////////////////////////////////// // resolve references to notifier - CORBA::String_var notifierIOR; - if (readIORFile(this->iorNotifierFile_, notifierIOR)) - { - CORBA::Object_var obj = this->orb_->string_to_object(notifierIOR); - this->notifier_ = ::FT::FaultNotifier::_narrow(obj); - if (CORBA::is_nil(this->notifier_)) - { - std::cerr << "Can't resolve Notifier IOR " << this->iorNotifierFile_ << std::endl; - result = -1; - } - } - else + CORBA::Object_var not_obj = this->orb_->string_to_object(this->notifier_ior_); + this->notifier_ = ::FT::FaultNotifier::_narrow(not_obj); + if (CORBA::is_nil(this->notifier_)) { - std::cerr << "Can't read " << this->iorNotifierFile_ << std::endl; + std::cerr << "Can't resolve Notifier IOR " << this->notifier_ior_ << std::endl; result = -1; } @@ -210,83 +149,74 @@ int StubFaultAnalyzer::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) //////////////////////////////////// // resolve references to replicas // create a fault detector for each replica - size_t replicaCount = this->iorReplicaFiles_.size(); + size_t replicaCount = this->replicaIORs.size(); for(size_t nRep = 0; result == 0 && nRep < replicaCount; ++nRep) { - const char * iorName = this->iorReplicaFiles_[nRep]; - CORBA::String_var ior; - if (readIORFile(iorName, ior)) + const char * iorName = this->replicaIORs[nRep]; + CORBA::Object_var rep_obj = this->orb_->string_to_object(iorName); + FT::PullMonitorable_var replica = FT::PullMonitorable::_narrow(rep_obj); + if (CORBA::is_nil(replica)) { - CORBA::Object_var obj = this->orb_->string_to_object(ior); - FT::PullMonitorable_var replica = FT::PullMonitorable::_narrow(obj); - if (CORBA::is_nil(replica)) + std::cerr << "Can't resolve Replica IOR " << iorName << std::endl; + result = -1; + } + else + { + this->replicas_.push_back(replica); + + CORBA::String_var type_id = CORBA::string_dup("FaultDetector"); + + TAO_PG::Properties_Encoder encoder; + + PortableGroup::Value value; + value <<= this->notifier_; + encoder.add(::FT::FT_NOTIFIER, value); + + value <<= replica; + encoder.add(::FT::FT_MONITORABLE, value); + + FT::FTDomainId domain_id = 0; + value <<= domain_id; + encoder.add(::FT::FT_DOMAIN_ID, value); + + FT::Location object_location; + object_location.length(1); + object_location[0].id = CORBA::string_dup("Test location"); + value <<= object_location; + encoder.add(::FT::FT_LOCATION, value); + + FT::TypeId object_type = 0; + value <<= object_type; + encoder.add(::FT::FT_TYPE_ID, value); + + FT::ObjectGroupId group_id = 0; + value <<= group_id; + encoder.add(::FT::FT_GROUP_ID, value); + + // allocate and populate the criteria + FT::Criteria_var criteria; + ACE_NEW_NORETURN (criteria, + FT::Criteria); + if (criteria.ptr() == 0) { - std::cerr << "Can't resolve Replica IOR " << iorName << std::endl; - result = -1; + ACE_ERROR((LM_ERROR, + "Error cannot allocate criteria.\n" + )); + result = -1; } else { - this->replicas_.push_back(replica); - - CORBA::String_var type_id = CORBA::string_dup("FaultDetector"); - - TAO_PG::Properties_Encoder encoder; - - PortableGroup::Value value; - value <<= this->notifier_; - encoder.add(::FT::FT_NOTIFIER, value); - - value <<= replica; - encoder.add(::FT::FT_MONITORABLE, value); - - FT::FTDomainId domain_id = 0; - value <<= domain_id; - encoder.add(::FT::FT_DOMAIN_ID, value); - - FT::Location object_location; - object_location.length(1); - object_location[0].id = CORBA::string_dup("Test location"); - value <<= object_location; - encoder.add(::FT::FT_LOCATION, value); - - FT::TypeId object_type = 0; - value <<= object_type; - encoder.add(::FT::FT_TYPE_ID, value); - - FT::ObjectGroupId group_id = 0; - value <<= group_id; - encoder.add(::FT::FT_GROUP_ID, value); - - // allocate and populate the criteria - FT::Criteria_var criteria; - ACE_NEW_NORETURN (criteria, - FT::Criteria); - if (criteria.ptr() == 0) - { - ACE_ERROR((LM_ERROR, - "Error cannot allocate criteria.\n" - )); - result = -1; - } - else - { - encoder.encode(criteria); - FT::GenericFactory::FactoryCreationId_var factory_creation_id; - - this->factory_->create_object ( - type_id.in(), - criteria.in(), - factory_creation_id - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + encoder.encode(criteria); + FT::GenericFactory::FactoryCreationId_var factory_creation_id; + + this->factory_->create_object ( + type_id.in(), + criteria.in(), + factory_creation_id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } } - else - { - std::cerr << "Can't read " << iorName << std::endl; - result = -1; - } } if (result == 0 && this->readyFile_ != 0) @@ -332,31 +262,6 @@ int StubFaultAnalyzer::idle(int & result) } -int StubFaultAnalyzer::readIORFile(const char * fileName, CORBA::String_var & ior) -{ - int result = 0; - FILE *in = ACE_OS::fopen (fileName, "r"); - ACE_OS::fseek(in, 0, SEEK_END); - size_t fileSize = ACE_OS::ftell(in); - ACE_OS::fseek(in, 0, SEEK_SET); - char * buffer; - ACE_NEW_NORETURN (buffer, - char[fileSize+1]); - if (buffer != 0) - { - if( fileSize == ACE_OS::fread(buffer, 1, fileSize, in)) - { - buffer[fileSize] = '\0'; - ior = CORBA::string_dup(buffer); - ACE_TRY_CHECK; - result = 1; // success - } - delete[] buffer; - } - return result; -} - - #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template instantiate ACE_Vector < const char * >; template ACE_Vector < FT::PullMonitorable_var > ; diff --git a/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.h b/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.h index 425fff60165..4ec4953b1c4 100644 --- a/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.h +++ b/TAO/orbsvcs/tests/FT_App/StubFaultAnalyzer.h @@ -73,7 +73,7 @@ private: // Data Members private: /** - * The orb + * The orb */ CORBA::ORB_var orb_; @@ -98,24 +98,23 @@ private: const char * readyFile_; /** - * A file from which the detecor's IOR should be read. + * The detecor's IOR (-d option) */ - const char * iorDetectorFile_; + const char * detector_ior_; ::FT::FaultDetectorFactory_var factory_; /** - * A file from which the notifier's IOR should be read. + * The notifier's IOR (-n option) */ - const char * iorNotifierFile_; + const char * notifier_ior_; ::FT::FaultNotifier_var notifier_; /** * A collection of files containing replica IORs */ - ACE_Vector < const char * > iorReplicaFiles_; - char * replicaIorBuffer_; + ACE_Vector < const char * > replicaIORs; ACE_Vector < FT::PullMonitorable_var > replicas_; diff --git a/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp b/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp index 803d1c5a61f..15e0d7bad5a 100644 --- a/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp +++ b/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.cpp @@ -10,8 +10,7 @@ StubFaultNotifier::StubFaultNotifier () : ior_output_file_(0) - , detector_ior_file_(0) - , replica_ior_buffer_(0) + , detector_ior_(0) , ns_name_(0) { } @@ -19,8 +18,6 @@ StubFaultNotifier::StubFaultNotifier () StubFaultNotifier::~StubFaultNotifier () { - delete [] this->replica_ior_buffer_; - this->replica_ior_buffer_ = 0; } @@ -34,10 +31,6 @@ PortableServer::ObjectId StubFaultNotifier::objectId()const return this->object_id_.in(); } - - - - int StubFaultNotifier::parse_args (int argc, char * argv[]) { int optionError = 0; @@ -49,54 +42,12 @@ int StubFaultNotifier::parse_args (int argc, char * argv[]) { case 'r': { - if (this->replica_ior_buffer_ == 0) - { - const char * repNames = get_opts.opt_arg (); - size_t repNameLen = ACE_OS::strlen(repNames); - - // make a working copy of the string - ACE_NEW_NORETURN(this->replica_ior_buffer_, - char[repNameLen + 1]); - if ( this->replica_ior_buffer_ != 0) - { - ACE_OS::memcpy(this->replica_ior_buffer_, repNames, repNameLen+1); - - // tokenize the string on ',' - // into iorReplicaFiles_ - char * pos = this->replica_ior_buffer_; - while (pos != 0) - { - this->iorReplicaFiles_.push_back(pos); - // find a comma delimiter, and - // chop the string there. - pos = ACE_OS::strchr (pos, ','); - if (pos != 0) - { - *pos = '\0'; - pos += 1; - } - } - } - else - { - ACE_ERROR ((LM_ERROR, - "Command line option error: -r can't allocate buffer.\n" - )); - optionError = -1; - } - } - else - { - ACE_ERROR ((LM_ERROR, - "Command line option error: -r specified more than once.\n" - )); - optionError = -1; - } + this->iorReplicaFiles_.push_back( get_opts.opt_arg ()); break; } case 'd': { - this->detector_ior_file_ = get_opts.opt_arg (); + this->detector_ior_ = get_opts.opt_arg (); break; } case 'n': @@ -121,14 +72,14 @@ int StubFaultNotifier::parse_args (int argc, char * argv[]) if(! optionError) { - if (0 == this->replica_ior_buffer_) + if (iorReplicaFiles_.size() == 0) { ACE_ERROR ((LM_ERROR, "-r option is required.\n" )); optionError = -1; } - if (0 == this->detector_ior_file_) + if (0 == this->detector_ior_) { ACE_ERROR ((LM_ERROR, "-d option is required.\n" @@ -141,7 +92,7 @@ int StubFaultNotifier::parse_args (int argc, char * argv[]) { ACE_ERROR ((LM_ERROR, "usage: %s" - " -r <replica.ior[,replica.ior]>" + " -r <replica.ior [-r <replica2.ior]...>" " -d <detector.ior>" " -o <this.ior>" " -n <nameService name>" @@ -179,13 +130,7 @@ int StubFaultNotifier::fini () this_name.length (1); this_name[0].id = CORBA::string_dup (this->ns_name_); - // 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; - - naming_context->rebind (this_name, this_obj.in() //CORBA::Object::_duplicate(this_obj) + naming_context->unbind (this_name ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } @@ -251,20 +196,12 @@ int StubFaultNotifier::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) ////////////////////////////////////////// // resolve references to detector factory - CORBA::String_var factory_ior; - if (read_ior_file(this->detector_ior_file_, factory_ior)) - { - CORBA::Object_var obj = this->orb_->string_to_object(factory_ior); - this->factory_ = ::FT::FaultDetectorFactory::_narrow(obj); - if (CORBA::is_nil(this->factory_)) - { - std::cerr << "Can't resolve Detector Factory IOR " << this->detector_ior_file_ << std::endl; - result = -1; - } - } - else + + CORBA::Object_var obj = this->orb_->string_to_object(detector_ior_); + this->factory_ = ::FT::FaultDetectorFactory::_narrow(obj); + if (CORBA::is_nil(this->factory_)) { - std::cerr << "Can't read " << this->detector_ior_file_ << std::endl; + std::cerr << "Can't resolve Detector Factory IOR " << this->detector_ior_ << std::endl; result = -1; } if (result == 0) @@ -275,79 +212,75 @@ int StubFaultNotifier::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) for(size_t nRep = 0; result == 0 && nRep < replicaCount; ++nRep) { const char * iorName = this->iorReplicaFiles_[nRep]; - CORBA::String_var ior; - if (read_ior_file(iorName, ior)) + CORBA::Object_var obj = this->orb_->string_to_object(iorName); + FT::PullMonitorable_var replica = FT::PullMonitorable::_narrow(obj); + if (CORBA::is_nil(replica)) { - CORBA::Object_var obj = this->orb_->string_to_object(ior); - FT::PullMonitorable_var replica = FT::PullMonitorable::_narrow(obj); - if (CORBA::is_nil(replica)) + std::cerr << "Can't resolve Replica IOR " << iorName << std::endl; + result = -1; + } + else + { + this->replicas_.push_back(replica); + + CORBA::String_var type_id = CORBA::string_dup("FaultDetector"); + + 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); + + + value <<= replica; + encoder.add(::FT::FT_MONITORABLE, value); + + FT::FTDomainId domain_id = 0; + value <<= domain_id; + encoder.add(::FT::FT_DOMAIN_ID, value); + + FT::Location object_location; + object_location.length(1); + object_location[0].id = CORBA::string_dup("Test location"); + value <<= object_location; + encoder.add(::FT::FT_LOCATION, value); + + FT::TypeId object_type = 0; + value <<= object_type; + encoder.add(::FT::FT_TYPE_ID, value); + + FT::ObjectGroupId group_id = 0; + value <<= group_id; + encoder.add(::FT::FT_GROUP_ID, value); + + // allocate and populate the criteria + FT::Criteria_var criteria; + ACE_NEW_NORETURN (criteria, + FT::Criteria); + if (criteria.ptr() == 0) { - std::cerr << "Can't resolve Replica IOR " << iorName << std::endl; - result = -1; + ACE_ERROR((LM_ERROR, + "Error cannot allocate criteria.\n" + )); + result = -1; } else { - this->replicas_.push_back(replica); - - CORBA::String_var type_id = CORBA::string_dup("FaultDetector"); - - TAO_PG::Properties_Encoder encoder; - - PortableGroup::Value value; - value <<= this_obj; - encoder.add(::FT::FT_NOTIFIER, value); - - value <<= replica; - encoder.add(::FT::FT_MONITORABLE, value); - - FT::FTDomainId domain_id = 0; - value <<= domain_id; - encoder.add(::FT::FT_DOMAIN_ID, value); - - FT::Location object_location; - object_location.length(1); - object_location[0].id = CORBA::string_dup("Test location"); - value <<= object_location; - encoder.add(::FT::FT_LOCATION, value); - - FT::TypeId object_type = 0; - value <<= object_type; - encoder.add(::FT::FT_TYPE_ID, value); - - FT::ObjectGroupId group_id = 0; - value <<= group_id; - encoder.add(::FT::FT_GROUP_ID, value); - - // allocate and populate the criteria - FT::Criteria_var criteria; - ACE_NEW_NORETURN (criteria, - FT::Criteria); - if (criteria.ptr() == 0) - { - ACE_ERROR((LM_ERROR, - "Error cannot allocate criteria.\n" - )); - result = -1; - } - else - { - encoder.encode(criteria); - FT::GenericFactory::FactoryCreationId_var factory_creation_id; - - this->factory_->create_object ( - type_id.in(), - criteria.in(), - factory_creation_id - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } + encoder.encode(criteria); + FT::GenericFactory::FactoryCreationId_var factory_creation_id; + + this->factory_->create_object ( + type_id.in(), + criteria.in(), + factory_creation_id + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; } } - else - { - std::cerr << "Can't read " << iorName << std::endl; - result = -1; - } } if (this->ior_output_file_ != 0) @@ -394,30 +327,6 @@ int StubFaultNotifier::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) return result; } -int StubFaultNotifier::read_ior_file(const char * fileName, CORBA::String_var & ior) -{ - int result = 0; - FILE *in = ACE_OS::fopen (fileName, "r"); - ACE_OS::fseek(in, 0, SEEK_END); - size_t fileSize = ACE_OS::ftell(in); - ACE_OS::fseek(in, 0, SEEK_SET); - char * buffer; - ACE_NEW_NORETURN (buffer, - char[fileSize+1]); - if (buffer != 0) - { - if( fileSize == ACE_OS::fread(buffer, 1, fileSize, in)) - { - buffer[fileSize] = '\0'; - ior = CORBA::string_dup(buffer); - ACE_TRY_CHECK; - result = 1; // success - } - delete[] buffer; - } - return result; -} - int StubFaultNotifier::write_ior_file() { int result = -1; diff --git a/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.h b/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.h index 6c8f52dc538..75999ce7fb6 100644 --- a/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.h +++ b/TAO/orbsvcs/tests/FT_App/StubFaultNotifier.h @@ -127,7 +127,6 @@ public: // Implementation private: int write_ior_file(); - int read_ior_file(const char * fileName, CORBA::String_var & ior); /////////////// // Data Members @@ -160,7 +159,7 @@ private: /** * A file from which the detecor's IOR should be read. */ - const char * detector_ior_file_; + const char * detector_ior_; ::FT::FaultDetectorFactory_var factory_; @@ -168,7 +167,7 @@ private: * A collection of files containing replica IORs */ ACE_Vector < const char * > iorReplicaFiles_; - char * replica_ior_buffer_; + ACE_Vector < FT::PullMonitorable_var > replicas_; /** 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 c19a62d8f04..f9b4908b08a 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp @@ -16,13 +16,15 @@ #include <iostream> #include <fstream> #include <orbsvcs/PortableGroup/PG_Properties_Encoder.h> -#include <orbsvcs/FT_ReplicationManagerC.h> #include <ace/Get_Opt.h> TAO::Object_Group_Creator::Object_Group_Creator () : registry_filename_(0) , registry_(0) + , replication_manager_(0) + , have_replication_manager_(0) + , iogr_seq_(0) { } @@ -35,7 +37,7 @@ TAO::Object_Group_Creator::parse_args (int argc, char *argv[]) { int result = 0; - ACE_Get_Opt get_opts (argc, argv, "t:f:"); + ACE_Get_Opt get_opts (argc, argv, "t:f:k:"); int c; while (result == 0 && (c = get_opts ()) != -1) @@ -44,7 +46,12 @@ TAO::Object_Group_Creator::parse_args (int argc, char *argv[]) { case 't': { - this->types_.push_back (get_opts.opt_arg ()); + this->create_types_.push_back (get_opts.opt_arg ()); + break; + } + case 'k': + { + this->kill_types_.push_back (get_opts.opt_arg ()); break; } case 'f': @@ -69,16 +76,9 @@ TAO::Object_Group_Creator::parse_args (int argc, char *argv[]) } } - if ( this->types_.size() == 0) - { - std::cerr << "Creator: Missing required parameter: -t <type> " << std::endl; - usage (std::cerr); - result = -1; - } - - if ( this->registry_filename_ == 0) + if ( this->create_types_.size() == 0 && this->kill_types_.size()) { - std::cerr << "Creator: Missing required parameter: -f <FactoryRegistry.ior> " << std::endl; + std::cerr << "Creator: neither create (-t) nor kill (-k) specified. Nothing to do." << std::endl; usage (std::cerr); result = -1; } @@ -98,32 +98,83 @@ void TAO::Object_Group_Creator::usage(ostream & out)const int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) { - int result = 0; + int result = 1; this->orb_ = orb; -////////////////STASH0 - - // Find the ReplicationManager. If found, assume it's our factory - CORBA::Object_var obj = orb->resolve_initial_references("ReplicationManager"); - PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in()); - - ///////////////////////////// - // resolve reference to factory - CORBA::String_var registry_ior; - if (read_ior_file(this->registry_filename_, registry_ior)) + // if a factory IOR was specified on command line + if ( this->registry_filename_ != 0) { - CORBA::Object_var registry_obj = this->orb_->string_to_object(registry_ior); - this->registry_ = PortableGroup::FactoryRegistry::_narrow(registry_obj); - if (CORBA::is_nil(this->registry_)) + ////////////////////////////////////// + // 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 { - std::cerr << "Creator: Can't resolve FactoryRegistry IOR " << this->registry_filename_ << std::endl; - result = -1; + result = 1; } + ACE_ENDTRY; } - else + else // no -f option. Try RIR(RM) { - std::cerr << "Creator: Can't read FactoryRegistry IOR " << this->registry_filename_ << std::endl; - result = -1; + /////////////////////////////// + // Find the ReplicationManager + ACE_TRY_NEW_ENV + { +std::cout << "RIR(ReplicationManager)" << std::endl; + 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); + ACE_TRY_CHECK; + if (!CORBA::is_nil (replication_manager_)) + { +std::cout << "Found a _real_ ReplicationManager. Ask it for a factory registry." << std::cout; + have_replication_manager_ = 1; + // empty criteria + ::PortableGroup::Criteria criteria; + this->registry_ = this->replication_manager_->get_factory_registry(criteria ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + if (!CORBA::is_nil (this->registry_)) + { + result = 0; // success + } + else + { + std::cerr << "Creator: ReplicationManager failed to return FactoryRegistry." << std::endl; + } + } + else + { + +std::cout << "did we get a FactoryRegistry instead?" << std::endl; + 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; + } + } + } + ACE_CATCHANY + { + std::cerr << "Creator: Exception resolving ReplicationManager, and no -f option was given." << std::endl; + result = 1; + } + ACE_ENDTRY; } return result; @@ -132,16 +183,33 @@ int TAO::Object_Group_Creator::init (CORBA::ORB_var & orb ACE_ENV_ARG_DECL) int TAO::Object_Group_Creator::run (ACE_ENV_SINGLE_ARG_DECL) { int result = 0; - size_t typeCount = this->types_.size(); + size_t typeCount = this->create_types_.size(); for ( size_t nType = 0; result == 0 && nType < typeCount; ++nType) { - const char * type = this->types_[nType].c_str(); + const char * type = this->create_types_[nType].c_str(); result = create_group (type); } + + typeCount = this->kill_types_.size(); + for ( nType = 0; result == 0 && nType < typeCount; ++nType) + { + const char * type = this->kill_types_[nType].c_str(); + result = kill_type (type); + } + + return result; +} + +int TAO::Object_Group_Creator::kill_type(const char * type ACE_ENV_ARG_DECL) +{ + int result = 0; + std::cout << std::endl << "Creator: Unregistering all factories for " << type << std::endl; + this->registry_->unregister_factory_by_type (type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; return result; } -int TAO::Object_Group_Creator::create_group(const char * type) +int TAO::Object_Group_Creator::create_group(const char * type ACE_ENV_ARG_DECL) { int result = 0; @@ -156,7 +224,23 @@ int TAO::Object_Group_Creator::create_group(const char * type) if (count > 0) { -////////////////STASH1 + /////////////////////////// + // Begin with an empty IOGR + ::PortableGroup::GenericFactory::FactoryCreationId_var creation_id; + CORBA::Object_var iogr; + if (this->have_replication_manager_) + { + PortableGroup::Criteria criteria; + iogr = this->replication_manager_->create_object( + type, + criteria, + creation_id + ACE_ENV_ARG_PARAMETER + ); + ACE_CHECK; + + } + for (CORBA::ULong nFact = 0; nFact < count; ++nFact) { ::PortableGroup::FactoryInfo info = infos[nFact]; @@ -170,22 +254,20 @@ int TAO::Object_Group_Creator::create_group(const char * type) std::cout << "Creator: Creating " << type << " at " << loc_name << std::endl; PortableGroup::GenericFactory::FactoryCreationId_var factory_creation_id; - CORBA::Object_var obj = info.the_factory->create_object ( + CORBA::Object_var created_obj = info.the_factory->create_object ( type, info.the_criteria, factory_creation_id ACE_ENV_ARG_PARAMETER); ACE_CHECK; - if ( !CORBA::is_nil(obj) ) + if ( !CORBA::is_nil(created_obj) ) { - const char * replica_ior = orb_->object_to_string (obj ACE_ENV_ARG_PARAMETER ); + const char * replica_ior = orb_->object_to_string (created_obj ACE_ENV_ARG_PARAMETER ); ACE_CHECK; -////////////////STASH2 - //////////////////////////////////// // Somewhat of a hack - // guess at factory creation id type + // guess at type of factory creation id CORBA::ULong ulong_id = 0; CORBA::Long long_id = 0; if (factory_creation_id >>= ulong_id) @@ -216,6 +298,20 @@ int TAO::Object_Group_Creator::create_group(const char * type) { std::cerr << "Creator: Error writing ior [" << replica_ior << "] to " << replica_ior_filename << std::endl; } + + if (this->have_replication_manager_) + { + iogr = this->replication_manager_->add_member (iogr, + info.the_location, + created_obj + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + if (nFact == 0) + { + iogr = this->replication_manager_->set_primary_member(iogr, info.the_location + ACE_ENV_ARG_PARAMETER); + } + } } else { @@ -224,7 +320,27 @@ int TAO::Object_Group_Creator::create_group(const char * type) } std::cout << "Creator: Successfully created group of " << type << std::endl; -////////////////STASH3 + + if( have_replication_manager_) + { + const char * replica_iogr = orb_->object_to_string (iogr ACE_ENV_ARG_PARAMETER ); + ACE_CHECK; + char replica_iogr_filename[200]; + + ACE_OS::snprintf(replica_iogr_filename, sizeof(replica_iogr_filename)-1, "%s_%lu.iogr", + type, + this->iogr_seq_); + replica_iogr_filename[sizeof(replica_iogr_filename)-1] = '\0'; + + std::cout << "Creator: Writing ior for created object to " << replica_iogr_filename << std::endl; + + if (write_ior_file(replica_iogr_filename, replica_iogr) != 0) + { + std::cerr << "Creator: Error writing ior [" << replica_iogr << "] to " << replica_iogr_filename << std::endl; + } + this->iogr_seq_ += 1; + } + } return result; @@ -238,37 +354,6 @@ int TAO::Object_Group_Creator::fini () -int TAO::Object_Group_Creator::read_ior_file(const char * fileName, CORBA::String_var & ior) -{ - int result = 0; - FILE *in = ACE_OS::fopen (fileName, "r"); - if (in != 0) - { - ACE_OS::fseek(in, 0, SEEK_END); - size_t fileSize = ACE_OS::ftell(in); - ACE_OS::fseek(in, 0, SEEK_SET); - char * buffer; - ACE_NEW_NORETURN (buffer, - char[fileSize+1]); - if (buffer != 0) - { - if( fileSize == ACE_OS::fread(buffer, 1, fileSize, in)) - { - buffer[fileSize] = '\0'; - ior = CORBA::string_dup(buffer); - ACE_TRY_CHECK; - result = 1; // success - } - delete[] buffer; - } - } - else - { - result = 1; - } - return result; -} - int TAO::Object_Group_Creator::write_ior_file(const char * outputFile, const char * ior) { int result = -1; @@ -312,7 +397,6 @@ main (int argc, char *argv[]) result = app.fini(); } } - std::cout << "***END TRY SCOPE***" << std::endl; } ACE_CATCHANY { @@ -321,86 +405,10 @@ main (int argc, char *argv[]) result = -1; } ACE_ENDTRY; - std::cout << "***EXIT***" << std::endl; - return result; } -#ifdef UNUSED_CODE_STASH -////////////////STASH0 - // Get an object reference for the ORBs IORManipulation object! - CORBA::Object_var IORM = - this->orb_->resolve_initial_references (TAO_OBJID_IORMANIPULATION, - 0 - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - this->iorm_ = TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - -////////////////STASH1 - // Create IOR list for use with merge_iors. - TAO_IOP::TAO_IOR_Manipulation::IORList iors (count + 1); - - // create a property set - TAO_PG::Properties_Encoder encoder; - PortableGroup::Value value; - - value <<= 99; - encoder.add(::FT::FT_MINIMUM_NUMBER_REPLICAS, value); - - // allocate and populate the criteria - FT::Properties_var props_in; - ACE_NEW_NORETURN (props_in, FT::Properties); - if (props_in.ptr() == 0) - { - ACE_ERROR((LM_ERROR, "Error cannot allocate properties.\n" )); - } - else - { - encoder.encode(props_in); - } - - iors.length (count + 1); - iors [0] = this->object_group_manager_.create_object_group( - this->iogr_group_id_, - "domain", - type, - props_in); - -////////////////STASH2 - iors [nFact + 1] = obj; - -////////////////STASH3 - CORBA::Object_var object_group = this->iorm_->merge_iors (iors ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - const char * iogr = orb_->object_to_string (object_group ACE_ENV_ARG_PARAMETER ); - ACE_CHECK; - - - char iogr_filename[200]; // "${type}_${iogr_id}.ior" - - ACE_OS::snprintf(iogr_filename, sizeof(iogr_filename)-1, "%s_%lu.ior", - type, - ACE_static_cast(unsigned long, iogr_group_id_)); - iogr_filename[sizeof(iogr_filename)-1] = '\0'; - - std::cout << "Creator: Writing iogr for created object to " << iogr_filename << std::endl; - - if (write_ior_file(iogr_filename, iogr) != 0) - { - std::cerr << "Creator: Error writing iogr [" << iogr << "] to " << iogr_filename << std::endl; - } - - - this->iogr_group_id_ += 1; - -#endif // UNUSED_CODE_STASH - - #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template ACE_Vector<ACE_CString>; 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 21ef83a5ab9..eb3e1ea1bc0 100644 --- a/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h +++ b/TAO/orbsvcs/tests/FT_App/TAO_Object_Group_Creator.h @@ -20,11 +20,10 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +#include <orbsvcs/FT_ReplicationManagerC.h> #include <orbsvcs/PortableGroupC.h> #include <ace/SString.h> #include <ace/Vector_T.h> -#include <tao/IORManipulation/IORC.h> -#include <orbsvcs/PortableGroup/PG_ObjectGroupManager.h> namespace TAO { @@ -56,10 +55,10 @@ namespace TAO // implementation private: void usage (ostream & out)const; - int read_ior_file(const char * fileName, CORBA::String_var & ior); int write_ior_file(const char * outputFile, const char * ior); - int create_group(const char * type_id); + int create_group(const char * type_id ACE_ENV_ARG_DECL); + int kill_type(const char * type_id ACE_ENV_ARG_DECL); //////////////////// // forbidden methods @@ -73,7 +72,21 @@ namespace TAO CORBA::ORB_var orb_; const char * registry_filename_; PortableGroup::FactoryRegistry_var registry_; - StringVec types_; + StringVec create_types_; + StringVec kill_types_; + + + ::FT::ReplicationManager_var replication_manager_; + /** + * 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_basic.pl b/TAO/orbsvcs/tests/FT_App/run_test_basic.pl index 9d512c3a59f..6fee05ba2aa 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_basic.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_basic.pl @@ -15,21 +15,24 @@ 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($data_file) = PerlACE::LocalFile ("persistent.dat"); unlink $factory1_ior; +unlink $factory2_ior; unlink $replica1_ior; unlink $replica2_ior; +unlink $data_file; my($status) = 0; my($SV1) = new PerlACE::Process ("release/ft_replica", "-o $factory1_ior -t $replica1_ior -q"); my($SV2) = new PerlACE::Process ("release/ft_replica", "-o $factory2_ior -t $replica2_ior -q"); -my($CL) = new PerlACE::Process ("release/ft_client", "-f $replica1_ior,$replica2_ior -c testscript"); -#my($CL) = new PerlACE::Process ("release/ft_client", "-f $replica1_ior -c testscript"); +my($CL) = new PerlACE::Process ("release/ft_client", "-f file://$replica1_ior -f file://$replica2_ior -c testscript"); +#my($CL) = new PerlACE::Process ("release/ft_client", "-f file://$replica1_iogr -c testscript"); -if ($debug) {print "starting replica 1\n";} +print "\nTest: Starting replica 1" . $SV1->CommandLine . "\n" if ($debug); $SV1->Spawn (); -if ($debug) {print "waiting for replica 1's IOR\n";} +print "waiting for replica 1's IOR\n" if ($debug); if (PerlACE::waitforfile_timed ($replica1_ior, 5) == -1) { print STDERR "ERROR: cannot find replica 1 file <$replica1_ior>\n"; @@ -37,10 +40,10 @@ if (PerlACE::waitforfile_timed ($replica1_ior, 5) == -1) { exit 1; } -if ($debug) {print "starting replica 2\n";} +print "\nTest: Starting replica 2" . $SV2->CommandLine . "\n" if ($debug); $SV2->Spawn (); -if ($debug) {print "waiting for replica 2's IOR\n";} +print "waiting for replica 2's IOR\n" if ($debug); if (PerlACE::waitforfile_timed ($replica2_ior, 5) == -1) { print STDERR "ERROR: cannot find replica 2 file <$replica2_ior>\n"; $SV1->Kill (); $SV1->TimedWait (1); @@ -48,7 +51,7 @@ if (PerlACE::waitforfile_timed ($replica2_ior, 5) == -1) { exit 1; } -if ($debug) {print "starting client.\n";} +print "\nTest: Starting client " . $CL->CommandLine . "\n" if ($debug); $client = $CL->SpawnWaitKill (60); @@ -57,10 +60,10 @@ if ($client != 0) { $status = 1; } -if ($debug) {print "wait for server 1.\n";} +print "wait for server 1.\n" if ($debug); $server = $SV1->WaitKill (60); -if ($debug) {print "wait for server 2.\n";} +print "wait for server 2.\n" if ($debug); $server = $SV2->WaitKill (60); if ($server != 0) { @@ -68,9 +71,12 @@ if ($server != 0) { $status = 1; } -if ($debug) {print "releasing scratch files.\n";} +print "Clean up scratch files\n" if ($debug); + +unlink $factory1_ior; +unlink $factory2_ior; unlink $replica1_ior; unlink $replica2_ior; -unlink "Persistent.dat"; +unlink $data_file; exit $status; diff --git a/TAO/orbsvcs/tests/FT_App/run_test_detector.pl b/TAO/orbsvcs/tests/FT_App/run_test_detector.pl index df00796a28b..da6cadacee4 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_detector.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_detector.pl @@ -121,16 +121,16 @@ my($status) = 0; my($REP1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ior -t $replica1_ior -l loc1 -i type1 -q"); my($REP2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -t $replica2_ior -l loc2 -i type1 -q"); 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 $detector_ior -r $replica1_ior,$replica2_ior"); +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) { - $CL = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_ior,$replica2_ior -c testscript"); + $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 - $CL = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_iogr -c testscript"); + $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); } -print "TEST: starting replica1 ". $REP1->Executable . "\n" if ($verbose); +print "TEST: starting replica1 ". $REP1->CommandLine . "\n" if ($verbose); $REP1->Spawn (); print "TEST: waiting for replica 1's IOR\n" if ($verbose); @@ -140,7 +140,7 @@ if (PerlACE::waitforfile_timed ($replica1_ior, 5) == -1) { exit 1; } -print "\nTEST: starting replica2" . $REP2->Executable . "\n" if ($verbose); +print "\nTEST: starting replica2 " . $REP2->CommandLine . "\n" if ($verbose); $REP2->Spawn (); print "TEST: waiting for replica 2's IOR\n" if ($verbose); @@ -151,7 +151,7 @@ if (PerlACE::waitforfile_timed ($replica2_ior, 5) == -1) { exit 1; } -print "\nTEST: starting detector factory" . $DET->Executable . "\n" if ($verbose); +print "\nTEST: starting detector factory " . $DET->CommandLine . "\n" if ($verbose); $DET->Spawn (); print "TEST: waiting for detector's IOR\n" if ($verbose); @@ -163,7 +163,7 @@ if (PerlACE::waitforfile_timed ($detector_ior, 5) == -1) { exit 1; } -print "\nTEST: starting notifier" . $NOT->Executable . "\n" if ($verbose); +print "\nTEST: starting notifier " . $NOT->CommandLine . "\n" if ($verbose); $NOT->Spawn (); print "TEST: waiting for notifier's IOR\n" if ($verbose); @@ -176,7 +176,7 @@ if (PerlACE::waitforfile_timed ($notifier_ior, 5) == -1) { exit 1; } -print "\nTEST: starting client." . $CL->Executable . "\n" if ($verbose); +print "\nTEST: starting client." . $CL->CommandLine . "\n" if ($verbose); $client = $CL->SpawnWaitKill (60); if ($client != 0) { 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 a75760fbbdd..2881ee583ba 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl @@ -140,14 +140,14 @@ my($REP1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ my($REP2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -t $replica2_ior -l loc2 -i type1 -q"); my($DET) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Detector$build_directory/Fault_Detector", "-o $detector_ior -q"); my($NOT) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Notifier$build_directory/Fault_Notifier", "-o $notifier_ior -v -q"); -my($CONS) = new PerlACE::Process (".$build_directory/ft_fault_consumer", "-o $ready_file -n $notifier_ior -q -d $detector_ior -r $replica1_ior,$replica2_ior"); +my($CONS) = new PerlACE::Process (".$build_directory/ft_fault_consumer", "-o $ready_file -n $notifier_ior -q -d file://$detector_ior -r file://$replica1_ior -f file://$replica2_ior"); my($CL); if (simulated) { - $CL = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_ior,$replica2_ior -c testscript"); + $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 - $CL = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_iogr -c testscript"); + $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); } print "TEST: starting replica1 " . $REP1->CommandLine . "\n" if ($verbose); diff --git a/TAO/orbsvcs/tests/FT_App/run_test_notifier.pl b/TAO/orbsvcs/tests/FT_App/run_test_notifier.pl index 99e0b42ef8e..3121b92e6b6 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_notifier.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_notifier.pl @@ -137,14 +137,14 @@ my($REP1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ my($REP2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -t $replica2_ior -l loc2 -i type1 -q"); my($DET) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Detector$build_directory/Fault_Detector", "-o $detector_ior -q"); my($NOT) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/Fault_Notifier$build_directory/Fault_Notifier", "-o $notifier_ior -v -q"); -my($ANA) = new PerlACE::Process (".$build_directory/ft_analyzer", "-o $ready_file -n $notifier_ior -q -d $detector_ior -r $replica1_ior,$replica2_ior"); +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) { - $CL = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_ior,$replica2_ior -c testscript"); + $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 - $CL = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_iogr -c testscript"); + $CL = new PerlACE::Process (".$build_directory/ft_client", "-f file://$replica1_iogr -c testscript"); } print "TEST: starting replica1 " . $REP1->CommandLine . "\n" if ($verbose); diff --git a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl index 00b4cc0cbd9..ad445a967be 100755 --- a/TAO/orbsvcs/tests/FT_App/run_test_registry.pl +++ b/TAO/orbsvcs/tests/FT_App/run_test_registry.pl @@ -9,10 +9,10 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # To test the FactoryRegistry # # Process being tested: -# FT_Registry +# FT_Registry # implements PortableGroup::FactoryRegistry interface. # Processes used in test: -# FT_Replica * 3 +# FT_Replica * 3 # implements GenericFactory interface to create TestReplicas # TestReplica implements TestReplica interface. # TestReplica implements PullMonitorable interface. @@ -24,60 +24,63 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # # Test Scenario (***Test: marks behavior being tested): # -# First the test starts a factory registry, +# First the test starts a factory registry, # 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 and elves, and -# the factory at rivendell can create elves. -# Both hobbits and elves are actually TestReplica objects. A creation parameter -# included as part of the registration information specifies which species they are. +# 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 actually TestReplica objects. A creation parameter +# included as part of the registration information specifies which species they are. # -# ***Test: The factories register themselves with the factory registry. Registration -# information includes the location, the type of object created, a object reference -# to the factory and set of parameters to be passed to the factory's create_object -# method. +# ***Test: The factories register themselves with the factory registry. Registration +# information includes the location, the type of object created, a object reference +# to the factory and 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. +# 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 registry for the set of factories -# that can create the type of object needed, then uses the create_object method -# for each factory to create the actual object. +# ***Test: the object group creator asks the registry for the set of factories +# that can create the type of object needed, then 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.] +# [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.] # -# Three clients are started, one at a time. Each client is given a reference -# to an object group +# The object group creator is also told to unregister all factories that create humans. +# ***Test: It does so using the unregister_factory_by_type method. # -# [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)] +# Three clients are started, one at a time. Each client is given a reference +# to an object group # -# 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. +# [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)] # -# When a clients job is done, it exits and asks the remaining group member to +# 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. +# 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 factory registry. -# ***Test: A command line option determines whether it uses a single +# ***Test: As it exits the factory unregisters itself with the factory registry. +# ***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, +# 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 factory registry shuts down to end the test. +# The factory registry is also run with the quit-on-idle option so when the last +# factory unregisters itself, the factory registry shuts down to end the test. use lib '../../../../bin'; #use lib '$ENV{ACE_ROOT}/bin'; @@ -118,9 +121,11 @@ if ( $verbose > 1) { my($species1) = "hobbit"; my($species2) = "elf"; +my($species3) = "human"; my($location1) = "shire"; my($location2) = "bree"; my($location3) = "rivendell"; +my($location4) = "rohan"; #define temp files my($registry_ior) = PerlACE::LocalFile ("registry.ior"); @@ -159,18 +164,21 @@ unlink $client_data; my($status) = 0; my($REG) = new PerlACE::Process (".$build_directory/ft_registry", "-o $registry_ior -q"); -my($FAC1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ior -f $registry_ior -l $location1 -i $species1 -q"); -my($FAC2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -f $registry_ior -l $location2 -i $species1 -i $species2 -q -u"); -my($FAC3) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory3_ior -f $registry_ior -l $location3 -i $species2 -q -u"); -my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-f $registry_ior -t $species1 -t $species2 -t $species1"); +my($FAC1) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory1_ior -f file://$registry_ior -l $location1 -i $species1 -q"); +my($FAC2) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory2_ior -f file://$registry_ior -l $location2 -i $species1 -i $species2 -i $species3 -q -u"); +my($FAC3) = new PerlACE::Process (".$build_directory/ft_replica", "-o $factory3_ior -f file://$registry_ior -l $location3 -i $species2 -q -u"); +#intermediate test: resolve factory IOR as file: url +#my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-f file://$registry_ior -t $species1 -t $species2 -t $species1 -k $species3"); +#ultimate test (for now): use ORBInitRef/RIR to find ReplicationManager (or factory registry DBA replication manager): +my($CTR) = new PerlACE::Process (".$build_directory/ft_create", "-ORBInitRef ReplicationManager=file://$registry_ior -t $species1 -t $species2 -t $species1 -k $species3"); my($CL1); my($CL2); my($CL3); if (simulated) { - $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_ior,$replica2_ior -c testscript"); - $CL2 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica3_ior,$replica4_ior -c testscript"); - $CL3 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica5_ior,$replica6_ior -c testscript"); + $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 $CL1 = new PerlACE::Process (".$build_directory/ft_client", "-f $replica1_iogr -c testscript"); @@ -239,27 +247,27 @@ $CTR->Spawn (); print "TEST: waiting for Replica IOR files from object group creator\n" if ($verbose); if (PerlACE::waitforfile_timed ($replica1_ior, 5) == -1){ print STDERR "ERROR: cannot find file <$replica1_ior>\n"; - $status = 1; + $status = 1; } elsif (PerlACE::waitforfile_timed ($replica2_ior, 5) == -1){ print STDERR "ERROR: cannot find file <$replica2_ior> \n"; - $status = 1; + $status = 1; } elsif (PerlACE::waitforfile_timed ($replica3_ior, 5) == -1){ print STDERR "ERROR: cannot find file <$replica3_ior> \n"; - $status = 1; + $status = 1; } elsif (PerlACE::waitforfile_timed ($replica4_ior, 5) == -1){ print STDERR "ERROR: cannot find file <$replica4_ior> \n"; - $status = 1; + $status = 1; } elsif (PerlACE::waitforfile_timed ($replica5_ior, 5) == -1){ print STDERR "ERROR: cannot find file <$replica5_ior> \n"; - $status = 1; + $status = 1; } elsif (PerlACE::waitforfile_timed ($replica6_ior, 5) == -1){ print STDERR "ERROR: cannot find file <$replica6_ior> \n"; - $status = 1; + $status = 1; } if($status != 0){ @@ -283,7 +291,6 @@ if ($config != 0) { } - ############# # Run clients |