summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Totten <tottens@users.noreply.github.com>2003-10-02 20:10:03 +0000
committerSteve Totten <tottens@users.noreply.github.com>2003-10-02 20:10:03 +0000
commit7a736214fe01e0116e9a996e5f0a980680221f0a (patch)
treeab2d57600a2e24615dfb02f0146690bf858e7915
parentda5730e81ed9baebd6e8e6f42c688d56552a03d6 (diff)
downloadATCD-7a736214fe01e0116e9a996e5f0a980680221f0a.tar.gz
ChangeLogTag: Thu Oct 2 14:21:13 2003 Steve Totten <totten_s@ociweb.com>
-rw-r--r--TAO/ChangeLog47
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp25
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h22
-rw-r--r--TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h2
-rw-r--r--TAO/orbsvcs/tests/FT_App/FT_App.mpc1
-rwxr-xr-xTAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp475
-rwxr-xr-xTAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.h154
-rwxr-xr-xTAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl44
8 files changed, 726 insertions, 44 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index efa542bc102..1945db1862c 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,12 +1,45 @@
+Thu Oct 2 14:21:13 2003 Steve Totten <totten_s@ociweb.com>
+
+ * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp:
+ * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h:
+ Added accessors for the consumer's object reference and the
+ number of notifications it has received. This is partially
+ to support testing and may be removed later (though they are
+ low impact).
+
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h:
+ Cosmetic code changes to match ACE guidelines.
+
+ * orbsvcs/tests/FT_App/FTApp_FaultConsumer_Main.cpp:
+ * orbsvcs/tests/FT_App/FT_App.mpc:
+ * orbsvcs/tests/FT_App/run_test_fault_consumer.pl:
+
+ Modifications to the test to make it work like other unit
+ tests in this directory:
+ - The Main is now very short and uses TAO::Utils::ServantMain<>.
+ - Wrapped the FT_ReplicationManager's FT_FaultConsumer in an
+ "adapter" class (ReplicationManagerFaultConsumerAdapter)
+ which is test-framework savvy (so the consumer class doesn't
+ have to be).
+ - Modified the test script to be like the others.
+
+ * orbsvcs/tests/FT_App/lReplicationManagerFaultConsumerAdapter.cpp:
+ * orbsvcs/tests/FT_App/lReplicationManagerFaultConsumerAdapter.h:
+
+ Added these two files as part of the changes described above.
+
+ These changes were made in the oci_haft branch.
+
Thu Oct 2 11:23:02 2003 Curt Hibbs <hibbs_c@ociweb.com>
- * TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
- * TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
- * TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager_Main.cpp
- * TAO/orbsvcs/tests/FT_App/FT_Client_Unit.cpp
- * TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp
- * TAO/orbsvcs/tests/FT_App/FT_UnitTests.h
- Minor style and name changes to make the code following the ACE guidelines.
+ * TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp:
+ * TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h:
+ * TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager_Main.cpp:
+ * TAO/orbsvcs/tests/FT_App/FT_Client_Unit.cpp:
+ * TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp:
+ * TAO/orbsvcs/tests/FT_App/FT_UnitTests.h:
+ Minor style and name changes to make the code following the
+ ACE guidelines.
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 6617228c802..40f54dadb21 100755
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp
@@ -16,8 +16,6 @@
*/
//=============================================================================
-#include "ace/pre.h"
-
#include "orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h"
#include "orbsvcs/FT_ReplicationManagerC.h"
@@ -31,6 +29,7 @@ TAO::FT_FaultConsumer::FT_FaultConsumer ()
, fault_notifier_ (FT::FaultNotifier::_nil ())
, replication_manager_ (FT::ReplicationManager::_nil ())
, consumer_id_ (0)
+ , consumer_ref_ (CosNotifyComm::StructuredPushConsumer::_nil ())
, notifications_ (0)
{
}
@@ -85,16 +84,14 @@ int TAO::FT_FaultConsumer::init (
ACE_CHECK_RETURN (-1);
// Narrow it to CosNotifyComm::StructuredPushConsumer.
- CosNotifyComm::StructuredPushConsumer_var consumer =
- CosNotifyComm::StructuredPushConsumer::_nil ();
- consumer = CosNotifyComm::StructuredPushConsumer::_narrow (
+ this->consumer_ref_ = CosNotifyComm::StructuredPushConsumer::_narrow (
obj.in() ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
// Subscribe to the FaultNotifier.
CosNotifyFilter::Filter_var filter = CosNotifyFilter::Filter::_nil ();
this->consumer_id_ = fault_notifier_->connect_structured_fault_consumer (
- consumer.in(), filter ACE_ENV_ARG_PARAMETER);
+ this->consumer_ref_.in(), filter ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
// Success.
@@ -123,10 +120,24 @@ int TAO::FT_FaultConsumer::fini (ACE_ENV_SINGLE_ARG_DECL)
this->poa_->deactivate_object (oid.in() ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
+ this->consumer_ref_ = CosNotifyComm::StructuredPushConsumer::_nil ();
+
// Success.
return 0;
}
+CosNotifyComm::StructuredPushConsumer_ptr
+TAO::FT_FaultConsumer::consumer_ref ()
+{
+ return CosNotifyComm::StructuredPushConsumer::_duplicate (
+ this->consumer_ref_);
+}
+
+size_t TAO::FT_FaultConsumer::notifications () const
+{
+ return this->notifications_;
+}
+
////////////////
// CORBA methods
@@ -194,5 +205,3 @@ void TAO::FT_FaultConsumer::disconnect_structured_push_consumer (
));
}
-#include "ace/post.h"
-
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h
index c32af21d042..559808a69d0 100755
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h
@@ -74,6 +74,17 @@ namespace TAO
*/
int fini (ACE_ENV_SINGLE_ARG_DECL);
+ /**
+ * Accessor for a duplicate of this consumer's object reference.
+ */
+ CosNotifyComm::StructuredPushConsumer_ptr consumer_ref ();
+
+ //@@ For testing purposes only, will be removed later.
+ /**
+ * Accessor for the number of notifications we have received.
+ */
+ size_t notifications () const;
+
public:
/////////////////////////
@@ -125,11 +136,9 @@ namespace TAO
// Forbidden methods
private:
/// Copy constructor.
- FT_FaultConsumer (
- const FT_FaultConsumer & rhs);
+ FT_FaultConsumer (const FT_FaultConsumer & rhs);
/// Assignment operator.
- FT_FaultConsumer & operator = (
- const FT_FaultConsumer & rhs);
+ FT_FaultConsumer & operator = (const FT_FaultConsumer & rhs);
///////////////
// Data Members
@@ -147,6 +156,9 @@ namespace TAO
/// ConsumerId assigned by the notifier.
FT::FaultNotifier::ConsumerId consumer_id_;
+ /// Our consumer object reference.
+ CosNotifyComm::StructuredPushConsumer_var consumer_ref_;
+
///TODO: Remove this later, it is just for testing.
// Keep track of how many notifications we have received.
size_t notifications_;
@@ -155,7 +167,7 @@ namespace TAO
} // namespace TAO
-#include "ace/post.h"
+#include /**/ "ace/post.h"
#endif /* FT_FAULT_CONSUMER_H_ */
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
index 7489119d68a..e182e861053 100644
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
@@ -447,7 +447,7 @@ namespace TAO
} // namespace TAO
-#include "ace/post.h"
+#include /**/ "ace/post.h"
#endif /* FT_REPLICATION_MANAGER_H_ */
diff --git a/TAO/orbsvcs/tests/FT_App/FT_App.mpc b/TAO/orbsvcs/tests/FT_App/FT_App.mpc
index a19cc3b4bed..d4758c64e26 100644
--- a/TAO/orbsvcs/tests/FT_App/FT_App.mpc
+++ b/TAO/orbsvcs/tests/FT_App/FT_App.mpc
@@ -91,6 +91,7 @@ project(*FaultConsumer): taoserver, fault_tolerance, orbsvcsexe {
Source_Files {
FTApp_FaultConsumer_Main.cpp
+ ReplicationManagerFaultConsumerAdapter.cpp
../../FT_ReplicationManager/FT_FaultConsumer.cpp
}
diff --git a/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp b/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp
new file mode 100755
index 00000000000..36833b2066e
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp
@@ -0,0 +1,475 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "ReplicationManagerFaultConsumerAdapter.h"
+
+#include <ace/Get_Opt.h>
+#include <tao/PortableServer/ORB_Manager.h>
+#include <orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h>
+#include <iostream>
+#include <fstream>
+
+ReplicationManagerFaultConsumerAdapter::ReplicationManagerFaultConsumerAdapter()
+ : orb_(CORBA::ORB::_nil())
+ , quit_(0)
+ , readyFile_(0)
+ , iorDetectorFile_(0)
+ , factory_(FT::FaultDetectorFactory::_nil())
+ , replicaIorBuffer_(0)
+ , iorNotifierFile_(0)
+ , notifier_(FT::FaultNotifier::_nil())
+ , p_fault_consumer_(0)
+ , consumer_servant_(0)
+{
+}
+
+
+ReplicationManagerFaultConsumerAdapter::~ReplicationManagerFaultConsumerAdapter()
+{
+}
+
+size_t ReplicationManagerFaultConsumerAdapter::notifications () const
+{
+ // Delegate to the FT_FaultConsumer.
+ return this->p_fault_consumer_->notifications ();
+}
+
+
+int ReplicationManagerFaultConsumerAdapter::parse_args (int argc, char * argv[])
+{
+ int optionError = 0;
+ ACE_Get_Opt get_opts (argc, argv, "o:r:d:n:");
+ int c;
+ while ((c = get_opts ()) != -1)
+ {
+ switch (c)
+ {
+ 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;
+ }
+ break;
+ }
+ case 'd':
+ {
+ this->iorDetectorFile_ = get_opts.opt_arg ();
+ break;
+ }
+ case 'n':
+ {
+ this->iorNotifierFile_ = get_opts.opt_arg ();
+ break;
+ }
+ case 'o':
+ {
+ this->readyFile_ = get_opts.opt_arg ();
+ break;
+ }
+
+ default:
+ // fall thru
+ case '?':
+ {
+ break;
+ }
+ }
+ }
+
+ if(! optionError)
+ {
+ if (0 == this->replicaIorBuffer_)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "-r option is required.\n"
+ ));
+ optionError = -1;
+ }
+ if (0 == this->iorDetectorFile_)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "-d option is required.\n"
+ ));
+ optionError = -1;
+ }
+ }
+
+ if(optionError)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "usage: %s"
+ " -r <replica.ior[,replica.ior]>"
+ " -d <detector.ior>"
+ " -o <this.ior>"
+ " -n <nameService name>"
+ "\n",
+ argv [0]
+ ));
+ }
+ return optionError;
+}
+
+/**
+ * Register this object.
+ */
+int ReplicationManagerFaultConsumerAdapter::init (
+ TAO_ORB_Manager & orbManager
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+{
+ ACE_DEBUG ((
+ LM_DEBUG,
+ ACE_TEXT ("Entered ReplicationManagerFaultConsumerAdapter::init.\n")
+ ));
+
+ int result = 0;
+ this->orb_ = orbManager.orb();
+
+ //////////////////////////////////////////
+ // resolve reference to detector factory
+ CORBA::String_var factoryIOR;
+ ACE_DEBUG ((
+ LM_DEBUG,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Getting ready to read iorDetectorFile.\n")
+ ));
+
+ if (this->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_.in()))
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("FaultDetectorFactory IOR is nil: %s\n"),
+ this->iorDetectorFile_),
+ -1);
+ }
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Can't read %s\n"),
+ this->iorDetectorFile_),
+ -1);
+ }
+
+ //////////////////////////////////////////
+ // resolve references to notifier
+ ACE_DEBUG ((
+ LM_DEBUG,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Getting ready to read Notifier IOR file.\n")
+ ));
+
+ CORBA::String_var notifierIOR;
+ if (this->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_.in()))
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("FaultNotifier IOR is nil: %s\n"),
+ this->iorNotifierFile_),
+ -1);
+ }
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Can't read %s\n"),
+ this->iorNotifierFile_),
+ -1);
+ }
+
+ // Create the real FaultConsumer.
+ //
+ // Note: We have to hang onto the servant class pointer so we can
+ // invoke member functions on it, but we also give ownership of it
+ // to a PortableServer::ServantBase_var.
+ ACE_DEBUG ((
+ LM_DEBUG,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Getting ready to create the real FaultConsumer.\n")
+ ));
+
+ ACE_NEW_RETURN (this->p_fault_consumer_, TAO::FT_FaultConsumer (), -1);
+ if (this->p_fault_consumer_ != 0)
+ {
+ this->consumer_servant_ = this->p_fault_consumer_;
+ }
+
+ //////////////////////////
+ // Get ready to initialize the consumer. We need to provide it
+ // with the following:
+ // - The POA in which it is to be activated.
+ // - FT::FaultNotifier IOR.
+ // - FT::ReplicationManager IOR (fake it for now).
+
+ // Get the RootPOA from the ORBManager.
+ PortableServer::POA_var poa = orbManager.root_poa();
+
+ // Fake out the ReplicationManager IOR.
+ CORBA::Object_var obj = this->orb_->string_to_object (
+ "corbaloc::localhost:1900/ReplicationManager"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ FT::ReplicationManager_var repl_mgr =
+ FT::ReplicationManager::_unchecked_narrow (
+ obj.in() ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (CORBA::is_nil (repl_mgr.in())) {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Unable to narrow the fake ReplicationManager IOR.\n")),
+ -1);
+ }
+
+ // Initialize the FaultConsumer.
+ // It will activate itself in the POA we pass it and connect to the
+ // Fault Notifier we pass it. It uses the Replication Manager we
+ // pass it for dealing with fault reports.
+ ACE_DEBUG ((
+ LM_DEBUG,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Getting ready to initialize the real FaultConsumer.\n")
+ ));
+
+ result = this->p_fault_consumer_->init (
+ poa.in(),
+ this->notifier_.in(),
+ repl_mgr.in()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ if (result != 0)
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Unable to initialize the real FaultConsumer.\n")),
+ result);
+ }
+
+ this->identity_ = "ReplicationManagerFaultConsumerAdapter";
+
+ /////////////////////////
+ // Set up fault detectors
+ if (result == 0)
+ {
+ ////////////////////////////////////
+ // resolve references to replicas
+ // create a fault detector for each replica
+ size_t replicaCount = this->iorReplicaFiles_.size();
+ for(size_t nRep = 0; result == 0 && nRep < replicaCount; ++nRep)
+ {
+ const char * iorName = this->iorReplicaFiles_[nRep];
+ CORBA::String_var ior;
+ if (this->readIORFile(iorName, ior))
+ {
+ CORBA::Object_var obj = this->orb_->string_to_object(ior);
+ FT::PullMonitorable_var replica = FT::PullMonitorable::_narrow(obj);
+ if (CORBA::is_nil(replica))
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Can't resolve Replica IOR: %s\n"),
+ iorName),
+ -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 <<= 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_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Error cannot allocate criteria.\n")),
+ -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;
+ }
+ }
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
+ ACE_TEXT ("Can't read %s\n"),
+ iorName),
+ -1);
+ }
+ }
+
+ // Signal that we are ready to go.
+ if (result == 0 && this->readyFile_ != 0)
+ {
+ std::ofstream ready (this->readyFile_, ios::out);
+ ready << "ready" << std::endl;
+ ready.close();
+ }
+ }
+
+ return result;
+}
+
+/**
+ * Return a string to identify this object for logging/console message purposes.
+ */
+const char * ReplicationManagerFaultConsumerAdapter::identity () const
+{
+ return this->identity_.c_str();
+}
+
+/**
+ * Clean house for process shut down.
+ */
+int ReplicationManagerFaultConsumerAdapter::fini (ACE_ENV_SINGLE_ARG_DECL)
+{
+ // Delegate to the FT_FaultConsumer.
+ return this->p_fault_consumer_->fini (ACE_ENV_SINGLE_ARG_PARAMETER);
+}
+
+
+int ReplicationManagerFaultConsumerAdapter::idle(int & result)
+{
+ ACE_UNUSED_ARG(result);
+ int quit = 0;
+
+ if (this->replicas_.size() == this->p_fault_consumer_->notifications())
+ {
+ quit = 1;
+ }
+ return quit;
+}
+
+int ReplicationManagerFaultConsumerAdapter::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 > ;
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+# 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/ReplicationManagerFaultConsumerAdapter.h b/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.h
new file mode 100755
index 00000000000..a551a49032e
--- /dev/null
+++ b/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.h
@@ -0,0 +1,154 @@
+// -*- C++ -*-
+//
+// $Id$
+#ifndef REPLICATION_MANAGER_FAULT_CONSUMER_ADAPTER_H
+#define REPLICATION_MANAGER_FAULT_CONSUMER_ADAPTER_H
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include <orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h>
+#include <orbsvcs/FT_NotifierC.h>
+#include <orbsvcs/FT_FaultDetectorFactoryC.h>
+#include <ace/Vector_T.h>
+
+//////////////////////
+// Forward references
+class TAO_ORB_Manager;
+
+/////////////////////
+// Class declarations
+
+/**
+ * An adapter to the Replication Manager's fault consumer
+ * for use in unit testing Fault Notifier and Fault Consumer.
+ */
+class ReplicationManagerFaultConsumerAdapter
+{
+public:
+ /**
+ * Default constructor.
+ */
+ ReplicationManagerFaultConsumerAdapter ();
+
+ /**
+ * virtual destructor.
+ */
+ virtual ~ReplicationManagerFaultConsumerAdapter ();
+
+ /**
+ * Parse command line arguments.
+ */
+ int parse_args (int argc, char * argv[]);
+
+ /**
+ * Initialize this object
+ */
+ int init (TAO_ORB_Manager & orbManager ACE_ENV_ARG_DECL_WITH_DEFAULTS);
+
+ /**
+ * Return a string to identify this object for logging/console message purposes.
+ */
+ const char * identity () const;
+
+ /**
+ * idle time activity.
+ * @param result [out] status code to return from process
+ * @returns 0 to continue; nonzero to quit
+ */
+ int idle(int &result);
+
+ /**
+ * Clean house for process shut down.
+ */
+ int fini (ACE_ENV_SINGLE_ARG_DECL);
+
+
+ size_t notifications() const;
+
+ /////////////////
+ // Implementation
+private:
+ int readIORFile(const char * fileName, CORBA::String_var & ior);
+
+ ////////////////////
+ // Forbidden methods
+private:
+ ReplicationManagerFaultConsumerAdapter (
+ const ReplicationManagerFaultConsumerAdapter & rhs);
+ ReplicationManagerFaultConsumerAdapter & operator =
+ (const ReplicationManagerFaultConsumerAdapter & rhs);
+
+ /////////////////////////
+ // Implementation methods
+private:
+
+ ///////////////
+ // Data Members
+private:
+ /**
+ * The orb
+ */
+ CORBA::ORB_var orb_;
+
+ /**
+ * A human-readable string to distinguish this from other FaultConsumers.
+ */
+ ACE_CString identity_;
+
+ /**
+ * boolean: request quit
+ */
+ int quit_;
+
+ /**
+ * a file to write to to signal "ready"
+ */
+ const char * readyFile_;
+
+ /**
+ * A file from which the detecor's IOR should be read.
+ */
+ const char * iorDetectorFile_;
+
+ /**
+ * The FaultDetectorFactory object reference.
+ */
+ ::FT::FaultDetectorFactory_var factory_;
+
+ /**
+ * A collection of files containing replica IORs
+ */
+ ACE_Vector < const char * > iorReplicaFiles_;
+ char * replicaIorBuffer_;
+
+ /**
+ * A collection of replica IORs
+ */
+ ACE_Vector < FT::PullMonitorable_var > replicas_;
+
+ /**
+ * A file from which the notifier's IOR should be read.
+ */
+ const char * iorNotifierFile_;
+
+ /**
+ * the fault notifier
+ */
+ ::FT::FaultNotifier_var notifier_;
+
+ /**
+ * consumer id assigned by the notifier
+ */
+ ::FT::FaultNotifier::ConsumerId consumerId_;
+
+ /**
+ * the real fault consumer
+ */
+ TAO::FT_FaultConsumer* p_fault_consumer_;
+ PortableServer::ServantBase_var consumer_servant_;
+
+};
+
+
+#endif /* REPLICATION_MANAGER_FAULT_CONSUMER_ADAPTER_H */
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 1229bfed924..9447955cb05 100755
--- a/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl
+++ b/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl
@@ -121,7 +121,7 @@ my($replica1_ior) = PerlACE::LocalFile ("replica1.ior");
my($replica2_ior) = PerlACE::LocalFile ("replica2.ior");
my($detector_ior) = PerlACE::LocalFile ("detector.ior");
my($notifier_ior) = PerlACE::LocalFile ("notifier.ior");
-# my($ready_file) = PerlACE::LocalFile ("ready.file");
+my($ready_file) = PerlACE::LocalFile ("ready.file");
my($client_data) = PerlACE::LocalFile ("persistent.dat");
#discard junk from previous tests
@@ -131,7 +131,7 @@ unlink $replica1_ior;
unlink $replica2_ior;
unlink $detector_ior;
unlink $notifier_ior;
-# unlink $ready_file;
+unlink $ready_file;
unlink $client_data;
my($status) = 0;
@@ -140,8 +140,7 @@ 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 -r 2 -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_fault_consumer");
+my($ANA) = new PerlACE::Process (".$build_directory/ft_fault_consumer", "-o $ready_file -n $notifier_ior -q -d $detector_ior -r $replica1_ior,$replica2_ior");
my($CL);
if (simulated) {
@@ -180,7 +179,7 @@ if (PerlACE::waitforfile_timed ($detector_ior, 5) == -1) {
print STDERR "ERROR: cannot find file <$detector_ior>\n";
$REP1->Kill (); $REP1->TimedWait (1);
$REP2->Kill (); $REP2->TimedWait (1);
- $DET->Kill (); $DET2->TimedWait(1);
+ $DET->Kill (); $DET->TimedWait(1);
exit 1;
}
@@ -192,25 +191,24 @@ if (PerlACE::waitforfile_timed ($notifier_ior, 5) == -1) {
print STDERR "ERROR: cannot find file <$notifier_ior>\n";
$REP1->Kill (); $REP1->TimedWait (1);
$REP2->Kill (); $REP2->TimedWait (1);
- $DET->Kill (); $DET2->TimedWait(1);
- $ANA->Kill (); $ANA->TimedWait(1);
+ $DET->Kill (); $DET->TimedWait(1);
+ $NOT->Kill (); $NOT->TimedWait(1);
exit 1;
}
-print "\nTEST: starting analyzer " . $ANA->CommandLine . "\n" if ($verbose);
+print "\nTEST: starting fault consumer " . $ANA->CommandLine . "\n" if ($verbose);
$ANA->Spawn ();
-sleep (3);
-
-# print "TEST: waiting for READY.FILE from analyzer\n" if ($verbose);
-# if (PerlACE::waitforfile_timed ($ready_file, 5) == -1) {
-# print STDERR "ERROR: cannot find file <$ready_file>\n";
-# $REP1->Kill (); $REP1->TimedWait (1);
-# $REP2->Kill (); $REP2->TimedWait (1);
-# $DET->Kill (); $DET2->TimedWait(1);
-# $NOT->Kill (); $NOT->TimedWait(1);
-# $ANA->Kill (); $ANA->TimedWait(1);
-# exit 1;
-# }
+
+print "TEST: waiting for READY.FILE from fault consumer\n" if ($verbose);
+if (PerlACE::waitforfile_timed ($ready_file, 5) == -1) {
+ print STDERR "ERROR: cannot find file <$ready_file>\n";
+ $REP1->Kill (); $REP1->TimedWait (1);
+ $REP2->Kill (); $REP2->TimedWait (1);
+ $DET->Kill (); $DET->TimedWait(1);
+ $NOT->Kill (); $NOT->TimedWait(1);
+ $ANA->Kill (); $ANA->TimedWait(1);
+ exit 1;
+}
print "\nTEST: starting client " . $CL->CommandLine . "\n" if ($verbose);
$client = $CL->SpawnWaitKill (60);
@@ -248,10 +246,10 @@ if ($notifier != 0) {
$status = 1;
}
-print "\nTEST: wait for analyzer to leave.\n" if ($verbose);
+print "\nTEST: wait for fault consumer to leave.\n" if ($verbose);
$analyzer = $ANA->WaitKill (60);
if ($analyzer != 0) {
- print STDERR "ERROR: analyzer returned $analyzer\n";
+ print STDERR "ERROR: fault consumer returned $analyzer\n";
$status = 1;
}
@@ -260,7 +258,7 @@ unlink $replica1_ior;
unlink $replica2_ior;
unlink $detector_ior;
unlink $notifier_ior;
-# unlink $ready_file;
+unlink $ready_file;
#client's work file
unlink $client_data;