summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Totten <tottens@users.noreply.github.com>2003-10-14 19:42:35 +0000
committerSteve Totten <tottens@users.noreply.github.com>2003-10-14 19:42:35 +0000
commit424eaf9140749a452cc88670ed5c503fa255e7fb (patch)
tree062639bcc69597b96be8df3c5b7dd73b703c07cf
parentaa638a45beaf509ccbad95e771dfc4817f18e88d (diff)
downloadATCD-424eaf9140749a452cc88670ed5c503fa255e7fb.tar.gz
ChangeLogTag: Tue Oct 14 13:52:18 2003 Steve Totten <totten_s@ociweb.com>
-rw-r--r--TAO/ChangeLog56
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp157
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h89
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.cpp29
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h83
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp599
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h54
-rw-r--r--TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp80
-rw-r--r--TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h8
-rw-r--r--TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.mpc3
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp542
-rwxr-xr-xTAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h124
-rw-r--r--TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl16
-rw-r--r--TAO/orbsvcs/tests/FT_App/FT_App.mpc5
-rw-r--r--TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp3
-rwxr-xr-xTAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp31
-rwxr-xr-xTAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl2
-rwxr-xr-xTAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl6
18 files changed, 1175 insertions, 712 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 031a17570a3..2d69846aada 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,7 +1,59 @@
+Tue Oct 14 13:52:18 2003 Steve Totten <totten_s@ociweb.com>
+
+ * orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp:
+ * orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h:
+ * orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.cpp:
+ * orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h:
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp:
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h:
+
+ Added an abstract FT_FaultAnalyzer class to provide an
+ interface for validating and analyzing fault events from the
+ FaultNotifier. Created two implementations of the fault
+ analyzer. The "default" FaultAnalyzer is a no-op. The
+ ReplicationManager uses the FT_ReplicationManagerFaultAnalyzer.
+ A Fault Analyzer is created by the "application" (e.g., the
+ Replication Manager) and provided to the FT_FaultConsumer
+ during its initialization. Then, the Fault Consumer calls
+ the Fault Analyzer to validate and analyze each fault event
+ that arrives from the Fault Notifier. Thus, the
+ responsibilities for receiving faults and analyzing faults
+ are separated, and different implementations of fault
+ analysis are possible.
+
+ * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp:
+ * orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h:
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp:
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h:
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.mpc:
+ * orbsvcs/tests/FT_App/FT_App.mpc:
+ * orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp:
+ Integrate use of FaultAnalyzer.
+ Removed readIORFile() and create_test_iogr() functions.
+
+ * orbsvcs/orbsvcs/FT_ReplicationManager.idl:
+ Minor reformatting for better readability.
+
+ * orbsvcs/tests/FT_App/FT_UnitTests.cpp:
+ Commented out use of create_test_iogr() on Replication
+ Manager.
+
+ * orbsvcs/tests/FT_App/run_test_replication_mgr.pl:
+ Use file:// syntax for FaultNotifier's IOR on Replication
+ Manager's command line.
+
+ * orbsvcs/tests/FT_App/run_test_fault_consumer.pl:
+ Put this script back to the way it was before it used the
+ file:// syntax on the FaultConsumer's command line. Still
+ need to get rid of readIORFile() there and use
+ string_to_object() properly.
+
+ These changes were made in the oci_haft branch.
+
Tue Oct 14 11:33:13 2003 Dale Wilson <wilson_d@ociweb.com>
- * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
- * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp:
+ * orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h:
Add stub implementation for get_factory_registry
* orbsvcs/tests/FT_App/TAO_Object_Group_Creator.cpp:
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp
new file mode 100755
index 00000000000..23dd7a43d98
--- /dev/null
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp
@@ -0,0 +1,157 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file FT_DefaultFaultAnalyzer.cpp
+ *
+ * $Id$
+ *
+ * This file is part of TAO's implementation of Fault Tolerant CORBA.
+ *
+ * @author Steve Totten <totten_s@ociweb.com>
+ */
+//=============================================================================
+
+#include "orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h"
+#include "orbsvcs/CosNotifyCommC.h"
+#include "orbsvcs/FT_NotifierC.h"
+#include "orbsvcs/FT_ReplicationManagerC.h"
+#include "orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h"
+#include <tao/debug.h>
+
+ACE_RCSID (FT_DefaultFaultAnalyzer,
+ FT_DefaultFaultAnalyzer,
+ "$Id$")
+
+/// Default constructor.
+TAO::FT_DefaultFaultAnalyzer::FT_DefaultFaultAnalyzer ()
+{
+}
+
+/// Destructor.
+TAO::FT_DefaultFaultAnalyzer::~FT_DefaultFaultAnalyzer ()
+{
+}
+
+// Validate the event to make sure it is one we can handle.
+// If it is not an event we can handle, this function logs the error
+// and returns -1.
+int TAO::FT_DefaultFaultAnalyzer::validate_event_type (
+ const CosNotification::StructuredEvent & event)
+{
+ int result = 0;
+
+ // CORBA 3.0.2, section 23.4.5.1 states:
+ //
+ // The fault management specification defines one event type:
+ // ObjectCrashFault. As the name suggests, this event is
+ // generated by a Fault Detector when it detects that an object
+ // has crashed.
+
+ // So, the event header's event_type.domain_name must be "FT_CORBA"
+ // and the event header's event_type.type_name must be "ObjectCrashFault".
+ CORBA::String_var domain_name = CORBA::string_dup (
+ event.header.fixed_header.event_type.domain_name);
+ CORBA::String_var type_name = CORBA::string_dup (
+ event.header.fixed_header.event_type.type_name);
+ CORBA::String_var event_name = CORBA::string_dup (
+ event.header.fixed_header.event_name);
+
+ if (result == 0)
+ {
+ //TODO: Get rid of magic strings (though they come from the spec).
+ if (ACE_OS::strcmp (domain_name.in(), "FT_CORBA") != 0 ||
+ ACE_OS::strcmp (type_name.in(), "ObjectCrashFault") != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_DefaultFaultAnalyzer::validate_event_type: "
+ "Received invalid event type.\n"
+ "EventType domain: <%s>\n"
+ "EventType type: <%s>\n"
+ "EventName: <%s>\n"),
+ domain_name.in(),
+ type_name.in(),
+ event_name.in()
+ ));
+ result = -1;
+ }
+ }
+
+ // CORBA 3.0.2, section 23.4.5.1 also states:
+ //
+ // The filterable_data part of the event body contains the
+ // identity of the crashed object as four name-value pairs: the
+ // fault tolerance domain identifier, the member’s location
+ // identifier, the repository identifier and the object group
+ // identifier. The Fault Notifier filters events based on the
+ // domain_name, the type_name, and the four identifiers. All
+ // other fields of the structured event may be set to null.
+ //
+ // The Fault Detector always sets the following fault event
+ // fields: domain_name, type_name, FTDomainId, and Location.
+ //
+ // So, at least "FTDomainId" and "Location" must be present:
+ if (result == 0)
+ {
+ if (event.filterable_data.length () >= 2)
+ {
+ // Check for FTDomainId.
+ if (ACE_OS::strcmp (
+ event.filterable_data[0].name.in(), "FTDomainId") != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_DefaultFaultAnalyzer::validate_event_type: "
+ "Received invalid structured event.\n"
+ "filterable_data[0] must be \"FTDomainId\", not \"%s\"\n"),
+ event.filterable_data[0].name.in()
+ ));
+ result = -1;
+ }
+ else if (ACE_OS::strcmp (
+ event.filterable_data[1].name.in(), "Location") != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_DefaultFaultAnalyzer::validate_event_type: "
+ "Received invalid structured event.\n"
+ "filterable_data[1] must be \"Location\", not \"%s\"\n"),
+ event.filterable_data[1].name.in()
+ ));
+ result = -1;
+ }
+ }
+ else
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_DefaultFaultAnalyzer::validate_event_type: "
+ "Received invalid structured event.\n"
+ "There must be at least two name/value pairs in "
+ "the filterable_data field, for \"FTDomainId\" and \"Location\".\n")
+ ));
+ result = -1;
+ }
+ }
+
+ return result;
+}
+
+/// Analyze a fault event.
+int TAO::FT_DefaultFaultAnalyzer::analyze_fault_event (
+ const CosNotification::StructuredEvent & event)
+{
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "In TAO::FT_DefaultFaultAnalyzer::analyze_fault_event.\n")
+ ));
+ }
+
+ // no-op
+ return 0;
+}
+
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h
new file mode 100755
index 00000000000..93248cf9e3f
--- /dev/null
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h
@@ -0,0 +1,89 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file FT_DefaultFaultAnalyzer.h
+ *
+ * $Id$
+ *
+ * This file is part of TAO's implementation of Fault Tolerant CORBA.
+ * This is the default implementation of a fault analyzer that
+ * implements the interface of the abstract base class
+ * TAO::FT_FaultAnalyzer.
+ *
+ * @author Steve Totten <totten_s@ociweb.com>
+ */
+//=============================================================================
+
+
+#ifndef FT_DEFAULT_FAULT_ANALYZER_H_
+#define FT_DEFAULT_FAULT_ANALYZER_H_
+
+#include /**/ "ace/pre.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h"
+
+// #include "orbsvcs/CosNotifyCommS.h"
+// #include "orbsvcs/FT_NotifierC.h"
+// #include "orbsvcs/FT_ReplicationManagerC.h"
+// #include "orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h"
+
+namespace TAO
+{
+
+ /**
+ * Default fault analyzer.
+ *
+ */
+ class FT_DefaultFaultAnalyzer
+ : public TAO::FT_FaultAnalyzer
+ {
+
+ public:
+ /**
+ * Default constructor.
+ */
+ FT_DefaultFaultAnalyzer ();
+
+ /**
+ * Destructor.
+ */
+ virtual ~FT_DefaultFaultAnalyzer ();
+
+ public:
+
+ /**
+ * Validate event type to make sure it is one we can handle.
+ * @param event The structured fault event, as from the Fault Notifier.
+ * @return 0 if it is a valid event type, -1 otherwise.
+ */
+ virtual int validate_event_type (
+ const CosNotification::StructuredEvent & event);
+
+ /**
+ * Analyze a fault event.
+ * @param event The structured fault event, as from the Fault Notifier.
+ * @return 0 on success, -1 on failure.
+ */
+ virtual int analyze_fault_event (
+ const CosNotification::StructuredEvent & event);
+
+ ////////////////////
+ // Forbidden methods
+ private:
+ /// Copy constructor.
+ FT_DefaultFaultAnalyzer (const FT_DefaultFaultAnalyzer & rhs);
+ /// Assignment operator.
+ FT_DefaultFaultAnalyzer & operator = (const FT_DefaultFaultAnalyzer & rhs);
+
+ };
+
+} // namespace TAO
+
+#include /**/ "ace/post.h"
+
+#endif /* FT_DEFAULT_FAULT_ANALYZER_H_ */
+
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.cpp
new file mode 100755
index 00000000000..5fb202dee58
--- /dev/null
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.cpp
@@ -0,0 +1,29 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file FT_FaultAnalyzer.cpp
+ *
+ * $Id$
+ *
+ * This file is part of TAO's implementation of Fault Tolerant CORBA.
+ *
+ * @author Steve Totten <totten_s@ociweb.com>
+ */
+//=============================================================================
+
+#include "orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h"
+
+ACE_RCSID (FT_FaultAnalyzer,
+ FT_FaultAnalyzer,
+ "$Id$")
+
+/// Default constructor.
+TAO::FT_FaultAnalyzer::FT_FaultAnalyzer ()
+{
+}
+
+/// Destructor.
+TAO::FT_FaultAnalyzer::~FT_FaultAnalyzer ()
+{
+}
+
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h
new file mode 100755
index 00000000000..1c85c9f6c7d
--- /dev/null
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h
@@ -0,0 +1,83 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file FT_FaultAnalyzer.h
+ *
+ * $Id$
+ *
+ * This file is part of TAO's implementation of Fault Tolerant CORBA.
+ *
+ * @author Steve Totten <totten_s@ociweb.com>
+ */
+//=============================================================================
+
+
+#ifndef FT_FAULT_ANALYZER_H_
+#define FT_FAULT_ANALYZER_H_
+
+#include /**/ "ace/pre.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "orbsvcs/CosNotifyCommC.h"
+
+namespace TAO
+{
+ /**
+ * Abstract base class for application-defined fault analyzers.
+ *
+ */
+ class FT_FaultAnalyzer
+ {
+
+ public:
+ /**
+ * Default constructor.
+ */
+ FT_FaultAnalyzer ();
+
+ /**
+ * Destructor.
+ */
+ virtual ~FT_FaultAnalyzer ();
+
+ public:
+
+ /**
+ * Validate event type to make sure it is one we can handle.
+ * @param event The structured fault event, as from the Fault Notifier.
+ * @return 0 if it is a valid event type, -1 otherwise.
+ */
+ virtual int validate_event_type (
+ const CosNotification::StructuredEvent & event) = 0;
+
+ /**
+ * Analyze a fault event.
+ * @param event The structured fault event, as from the Fault Notifier.
+ * @return 0 on success, -1 on failure.
+ */
+ virtual int analyze_fault_event (
+ const CosNotification::StructuredEvent & event) = 0;
+
+ ////////////////////
+ // Forbidden methods
+ private:
+ /// Copy constructor.
+ FT_FaultAnalyzer (const FT_FaultAnalyzer & rhs);
+ /// Assignment operator.
+ FT_FaultAnalyzer & operator = (const FT_FaultAnalyzer & rhs);
+
+ ///////////////
+ // Data Members
+ private:
+
+ };
+
+} // namespace TAO
+
+#include /**/ "ace/post.h"
+
+#endif /* FT_FAULT_ANALYZER_H_ */
+
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp
index 826af851984..479f857f239 100755
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.cpp
@@ -18,7 +18,7 @@
#include "orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h"
#include "orbsvcs/FT_ReplicationManagerC.h"
-#include "orbsvcs/PortableGroup/PG_Property_Utils.h"
+#include "orbsvcs/FT_ReplicationManager/FT_FaultAnalyzer.h"
#include <tao/debug.h>
ACE_RCSID (FT_FaultConsumer,
@@ -29,7 +29,7 @@ ACE_RCSID (FT_FaultConsumer,
TAO::FT_FaultConsumer::FT_FaultConsumer ()
: poa_ (PortableServer::POA::_nil ())
, fault_notifier_ (FT::FaultNotifier::_nil ())
- , replication_manager_ (FT::ReplicationManager::_nil ())
+ , fault_analyzer_ (0)
, consumer_id_ (0)
, consumer_ref_ (CosNotifyComm::StructuredPushConsumer::_nil ())
, notifications_ (0)
@@ -55,7 +55,7 @@ TAO::FT_FaultConsumer::~FT_FaultConsumer ()
int TAO::FT_FaultConsumer::init (
PortableServer::POA_ptr poa,
FT::FaultNotifier_ptr fault_notifier,
- FT::ReplicationManager_ptr replication_manager
+ TAO::FT_FaultAnalyzer * fault_analyzer
ACE_ENV_ARG_DECL)
{
@@ -71,15 +71,16 @@ int TAO::FT_FaultConsumer::init (
ACE_ASSERT (!CORBA::is_nil (poa));
ACE_ASSERT (!CORBA::is_nil (fault_notifier));
- ACE_ASSERT (!CORBA::is_nil (replication_manager));
+ ACE_ASSERT (fault_analyzer != 0);
// Duplicate the object references passed in.
this->poa_ =
PortableServer::POA::_duplicate (poa);
this->fault_notifier_ =
FT::FaultNotifier::_duplicate (fault_notifier);
- this->replication_manager_ =
- FT::ReplicationManager::_duplicate (replication_manager);
+
+ // We have no ownership responsibilities for the Fault Analyzer.
+ this->fault_analyzer_ = fault_analyzer;
//@@ Should this init() method activate the consumer in the POA, or
// should the application do that?
@@ -226,14 +227,13 @@ size_t TAO::FT_FaultConsumer::notifications () const
}
-////////////////
-// CORBA methods
+///////////////////
+// CORBA operations
// Receive and process an incoming fault event from the Fault Notifier.
// First, we validate the event to make sure it is something we can
-// handle. Then, we analyze it.
-// If it is not an event we can handle, we simply log the error and
-// drop the event.
+// handle. Then, we analyze it. If it is not an event we can handle,
+// we simply log the error and drop the event.
void TAO::FT_FaultConsumer::push_structured_event (
const CosNotification::StructuredEvent &event
ACE_ENV_ARG_DECL_WITH_DEFAULTS
@@ -259,7 +259,7 @@ void TAO::FT_FaultConsumer::push_structured_event (
// Make sure it is an event type we can handle.
if (result == 0)
{
- result = this->validate_event_type (event);
+ result = this->fault_analyzer_->validate_event_type (event);
if (result != 0)
{
ACE_ERROR ((LM_ERROR,
@@ -273,94 +273,20 @@ void TAO::FT_FaultConsumer::push_structured_event (
// Analyze the event.
if (result == 0)
{
- TAO::FT_FaultEventDescriptor fault_event_desc;
-
- // Make sure we catch and swallow any CORBA exceptions locally
- // so they do not propagate back to the Fault Notifier.
- ACE_TRY_NEW_ENV
- {
- result = this->analyze_fault_event (
- event,
- fault_event_desc
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
- if (result != 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::push_structured_event: "
- "Could not analyze fault event.\n")
- ));
- }
- }
- ACE_CATCHANY
+ result = this->fault_analyzer_->analyze_fault_event (event);
+ if (result != 0)
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ ACE_ERROR ((LM_ERROR,
ACE_TEXT (
"TAO::FT_FaultConsumer::push_structured_event: "
"Could not analyze fault event.\n")
- );
- }
- ACE_CHECK_RETURN (-1);
- ACE_ENDTRY;
-
- // Debugging support.
-#if (TAO_DEBUG_LEVEL_NEEDED == 1)
- if (TAO_debug_level > 6)
-#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT("Getting the location as a string.\n")
));
-
- // Get the location as a string.
- ACE_CString loc_as_string;
- FT::Location_var & loc = fault_event_desc.location;
-
- for (CORBA::ULong li = 0; li < loc->length(); ++li)
- {
- if (li > 0) loc_as_string += "/";
- // Assume only the "id" field of the CosNaming::Name is used.
- loc_as_string += CORBA::string_dup (loc[li].id);
- }
-
- if (fault_event_desc.all_at_location_failed == 1)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT (
- "All objects at location <%s> failed.\n"),
- loc_as_string.c_str()
- ));
- }
-
- if (fault_event_desc.all_of_type_at_location_failed == 1)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT (
- "All objects of type <%s> at location <%s> failed.\n"),
- fault_event_desc.type_id.in(),
- loc_as_string.c_str()
- ));
- }
-
- if (fault_event_desc.object_at_location_failed == 1)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT (
- "Replica of type <%s> with ObjectGroupId <%Q> "
- "at location <%s> failed.\n"),
- fault_event_desc.type_id.in(),
- fault_event_desc.object_group_id,
- loc_as_string.c_str()
- ));
- }
}
}
return;
}
-
void TAO::FT_FaultConsumer::offer_change (
const CosNotification::EventTypeSeq & added,
const CosNotification::EventTypeSeq & removed
@@ -385,498 +311,3 @@ void TAO::FT_FaultConsumer::disconnect_structured_push_consumer (
));
}
-//////////////////
-// Private methods
-
-// Validate the event to make sure it is one we can handle.
-// If it is not an event we can handle, this function logs the error
-// and returns -1.
-int TAO::FT_FaultConsumer::validate_event_type (
- const CosNotification::StructuredEvent & event)
-{
- int result = 0;
-
- // CORBA 3.0.2, section 23.4.5.1 states:
- //
- // The fault management specification defines one event type:
- // ObjectCrashFault. As the name suggests, this event is
- // generated by a Fault Detector when it detects that an object
- // has crashed.
-
- // So, the event header's event_type.domain_name must be "FT_CORBA"
- // and the event header's event_type.type_name must be "ObjectCrashFault".
- CORBA::String_var domain_name = CORBA::string_dup (
- event.header.fixed_header.event_type.domain_name);
- CORBA::String_var type_name = CORBA::string_dup (
- event.header.fixed_header.event_type.type_name);
- CORBA::String_var event_name = CORBA::string_dup (
- event.header.fixed_header.event_name);
-
- if (result == 0)
- {
- //TODO: Get rid of magic strings (though they come from the spec).
- if (ACE_OS::strcmp (domain_name.in(), "FT_CORBA") != 0 ||
- ACE_OS::strcmp (type_name.in(), "ObjectCrashFault") != 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::validate_event_type: "
- "Received invalid event type.\n"
- "EventType domain: <%s>\n"
- "EventType type: <%s>\n"
- "EventName: <%s>\n"),
- domain_name.in(),
- type_name.in(),
- event_name.in()
- ));
- result = -1;
- }
- }
-
- // CORBA 3.0.2, section 23.4.5.1 also states:
- //
- // The filterable_data part of the event body contains the
- // identity of the crashed object as four name-value pairs: the
- // fault tolerance domain identifier, the member’s location
- // identifier, the repository identifier and the object group
- // identifier. The Fault Notifier filters events based on the
- // domain_name, the type_name, and the four identifiers. All
- // other fields of the structured event may be set to null.
- //
- // The Fault Detector always sets the following fault event
- // fields: domain_name, type_name, FTDomainId, and Location.
- //
- // So, at least "FTDomainId" and "Location" must be present:
- if (result == 0)
- {
- if (event.filterable_data.length () >= 2)
- {
- // Check for FTDomainId.
- if (ACE_OS::strcmp (
- event.filterable_data[0].name.in(), "FTDomainId") != 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::validate_event_type: "
- "Received invalid structured event.\n"
- "filterable_data[0] must be \"FTDomainId\", not \"%s\"\n"),
- event.filterable_data[0].name.in()
- ));
- result = -1;
- }
- else if (ACE_OS::strcmp (
- event.filterable_data[1].name.in(), "Location") != 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::validate_event_type: "
- "Received invalid structured event.\n"
- "filterable_data[1] must be \"Location\", not \"%s\"\n"),
- event.filterable_data[1].name.in()
- ));
- result = -1;
- }
- }
- else
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::validate_event_type: "
- "Received invalid structured event.\n"
- "There must be at least two name/value pairs in "
- "the filterable_data field, for \"FTDomainId\" and \"Location\".\n")
- ));
- result = -1;
- }
- }
-
- return result;
-}
-
-/// Analyze a fault event.
-int TAO::FT_FaultConsumer::analyze_fault_event (
- const CosNotification::StructuredEvent & event,
- TAO::FT_FaultEventDescriptor & fault_event_desc
- ACE_ENV_ARG_DECL_WITH_DEFAULTS
- )
- ACE_THROW_SPEC ((CORBA::SystemException, CosEventComm::Disconnected))
-{
- int result = 0;
-
- const CosNotification::FilterableEventBody & filterable =
- event.filterable_data;
- CORBA::ULong item_count = filterable.length ();
-#if (TAO_DEBUG_LEVEL_NEEDED == 1)
- if (TAO_debug_level > 6)
-#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
- {
- for (CORBA::ULong n_prop = 0; n_prop < item_count; ++n_prop)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT("TAO::FT_FaultConsumer::analyze_fault_event: "
- "Property Name: <%s>\n"),
- filterable[n_prop].name.in()
- ));
- }
- }
-
- //
- // Populate the TAO::FT_FaultEventDescriptor structure from the
- // properties in the event.
- //
-
- // Extract the location.
- if (result == 0)
- {
- FT::Location* temp_loc;
- if ((filterable[1].value >>= temp_loc) == 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "Could not extract Location value from fault event.\n")
- ));
- result = -1;
- }
- else
- {
- // Make a deep copy of the Location.
- FT::Location* copy_loc = 0;
- ACE_NEW_RETURN (copy_loc, FT::Location (*temp_loc), -1);
- fault_event_desc.location = copy_loc;
- }
- }
-
- // CORBA 3.0.2, section 23.4.5.1 states:
- //
- // The fault detector may or may not set the TypeId and
- // ObjectGroupId fields with the following interpretations:
- // - Neither is set if all objects at the given location have failed.
- // - TypeId is set and ObjectGroupId is not set if all objects at
- // the given location with the given type have failed.
- // - Both are set if the member with the given ObjectGroupId at the
- // given location has failed.
- if (result == 0)
- {
- // All objects at location failed.
- if (item_count == 2)
- {
- fault_event_desc.all_at_location_failed = 1;
- }
-
- // All objects of type at location failed.
- if (item_count == 3)
- {
- fault_event_desc.all_of_type_at_location_failed = 1;
- fault_event_desc.type_id = this->extract_type_id (filterable[2].value);
- }
-
- // An object (replica) at a location failed.
- if (item_count == 4)
- {
- fault_event_desc.object_at_location_failed = 1;
- fault_event_desc.type_id = this->extract_type_id (filterable[2].value);
- fault_event_desc.object_group_id =
- this->extract_object_group_id (filterable[3].value);
- }
- }
-
- //TODO: Finish the implementation of analyze_fault_event() to:
- // - if the ReplicationStyle of the object group is FT::SEMI_ACTIVE,
- // and if the failed replica was the primary replica, set a new
- // primary replica
- // - if the number of replicas falls below MinimumNumberReplicas
- // property and MembershipStyle of the object group is FT::MEMB_INF_CTRL,
- // create and add a new member.
-
- //@@ Q: How do we get the ObjectGroup from the ObjectGroupId?
- //@@ A: Use TAO-specific extension to PortableGroup::ObjectGroupManager
- // interface (get_object_group_ref_from_id()).
-#if (INTEGRATED_WITH_REPLICATION_MANAGER == 1)
- if ((fault_event_desc.object_at_location_failed == 1) && (result == 0))
- {
- FT::ObjectGroup_var the_object_group =
- this->replication_manager_->get_object_group_ref_from_id (
- fault_event_desc.object_group_id
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
- if (CORBA::is_nil (the_object_group.in()))
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "Could not get ObjectGroup reference from ObjectGroupId: <%Q>.\n"),
- fault_event_desc.object_group_id
- ));
- result = -1;
- }
-
- //@@ Q: How do we get the properties of the ObjectGroup to
- // figure out the ReplicationStyle, current primary,
- // MinimumNumberReplicas, etc.?
- //@@ A: FT::PropertyManager::get_properties().
-
- // Get the properties associated with this ObjectGroup.
- FT::Properties_var properties;
- if (result == 0)
- {
- properties = this->replication_manager_->get_properties (
- the_object_group.in()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
-
- // Get the MembershipStyle property.
- FT::MembershipStyleValue membership_style;
- result = this->get_membership_style (properties.in(), membership_style);
- if (result != 0)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "Could not extract MembershipStyle from properties on "
- "ObjectGroup with id <%Q>.\n"),
- fault_event_desc.object_group_id),
- -1);
- }
- else
- {
- fault_event_desc.membership_style = membership_style;
- }
-
- // Get the ReplicationStyle property.
- FT::ReplicationStyleValue replication_style;
- result = this->get_replication_style (properties.in(), replication_style);
- if (result != 0)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "Could not extract ReplicationStyle from properties on "
- "ObjectGroup with id <%Q>.\n"),
- fault_event_desc.object_group_id),
- -1);
- }
- else
- {
- fault_event_desc.replication_style = replication_style;
- }
-
- // Get the MinimumNumberReplicas property.
- FT::MinimumNumberReplicasValue minimum_number_replicas;
- result = this->get_minimum_number_replicas (
- properties.in(), minimum_number_replicas);
- if (result != 0)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "Could not extract MinimumNumberReplicas from properties on "
- "ObjectGroup with id <%Q>.\n"),
- fault_event_desc.object_group_id),
- -1);
- }
- else
- {
- fault_event_desc.minimum_number_replicas = minimum_number_replicas;
- }
-
- // Get the InitialNumberReplicas property.
- FT::InitialNumberReplicasValue initial_number_replicas;
- result = this->get_initial_number_replicas (
- properties.in(), initial_number_replicas);
- if (result != 0)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "Could not extract InitialNumberReplicas from properties on "
- "ObjectGroup with id <%Q>.\n"),
- fault_event_desc.object_group_id),
- -1);
- }
- else
- {
- fault_event_desc.initial_number_replicas = initial_number_replicas;
- }
-
- }
- }
-#endif /* (INTEGRATED_WITH_REPLICATION_MANAGER == 1) */
-
- return result;
-}
-
-// Extract a string type_id from CORBA::Any.
-// Caller owns the returned string.
-char*
-TAO::FT_FaultConsumer::extract_type_id (const CORBA::Any& val)
-{
- const char* type_id_value;
- if ((val >>= type_id_value) == 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::extract_type_id: "
- "Could not extract TypeId value from any.\n")
- ));
- return 0;
- }
-
- return CORBA::string_dup (type_id_value);
-}
-
-// Extract the ObjectGroupId from CORBA::Any.
-FT::ObjectGroupId
-TAO::FT_FaultConsumer::extract_object_group_id (const CORBA::Any& val)
-{
- FT::ObjectGroupId id = (FT::ObjectGroupId)0;
- if ((val >>= id) == 0)
- {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::extract_object_group_id: "
- "Could not extract ObjectGroupId value from any.\n")
- ));
- }
-
- return id;
-}
-
-//
-//TODO: Use TAO_PG::find() to get property values from properties
-// instead of all these specific "get" functions.
-//
-
-// Get the MembershipStyle property.
-int TAO::FT_FaultConsumer::get_membership_style (
- const FT::Properties & properties,
- FT::MembershipStyleValue & membership_style)
-{
- FT::Name prop_name (1);
- prop_name.length (1);
- prop_name[0].id = CORBA::string_dup (FT::FT_MEMBERSHIP_STYLE);
- int result = 0;
-
- FT::Value value;
- if (TAO_PG::get_property_value (prop_name, properties, value)
- && ((value >>= membership_style) == 1))
- {
-#if (TAO_DEBUG_LEVEL_NEEDED == 1)
- if (TAO_debug_level > 6)
-#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "MembershipStyle is <%d>:\n"),
- membership_style
- ));
- }
- }
- else
- {
- result = -1;
- }
-
- return result;
-}
-
-int TAO::FT_FaultConsumer::get_replication_style (
- const FT::Properties & properties,
- FT::ReplicationStyleValue & replication_style)
-{
- FT::Name prop_name (1);
- prop_name.length (1);
- prop_name[0].id = CORBA::string_dup (FT::FT_REPLICATION_STYLE);
- int result = 0;
-
- FT::Value value;
- if (TAO_PG::get_property_value (prop_name, properties, value)
- && ((value >>= replication_style) == 1))
- {
-#if (TAO_DEBUG_LEVEL_NEEDED == 1)
- if (TAO_debug_level > 6)
-#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "ReplicationStyle is <%d>:\n"),
- replication_style
- ));
- }
- }
- else
- {
- result = -1;
- }
-
- return result;
-}
-
-int TAO::FT_FaultConsumer::get_minimum_number_replicas (
- const FT::Properties & properties,
- FT::MinimumNumberReplicasValue & minimum_number_replicas)
-{
- FT::Name prop_name (1);
- prop_name.length (1);
- prop_name[0].id = CORBA::string_dup (FT::FT_MINIMUM_NUMBER_REPLICAS);
- int result = 0;
-
- FT::Value value;
- if (TAO_PG::get_property_value (prop_name, properties, value)
- && ((value >>= minimum_number_replicas) == 1))
- {
-#if (TAO_DEBUG_LEVEL_NEEDED == 1)
- if (TAO_debug_level > 6)
-#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "MinimumNumberReplicas is <%d>:\n"),
- minimum_number_replicas
- ));
- }
- }
- else
- {
- result = -1;
- }
-
- return result;
-}
-
-int TAO::FT_FaultConsumer::get_initial_number_replicas (
- const FT::Properties & properties,
- FT::InitialNumberReplicasValue & initial_number_replicas)
-{
- FT::Name prop_name (1);
- prop_name.length (1);
- prop_name[0].id = CORBA::string_dup (FT::FT_INITIAL_NUMBER_REPLICAS);
- int result = 0;
-
- FT::Value value;
- if (TAO_PG::get_property_value (prop_name, properties, value)
- && ((value >>= initial_number_replicas) == 1))
- {
-#if (TAO_DEBUG_LEVEL_NEEDED == 1)
- if (TAO_debug_level > 6)
-#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT (
- "TAO::FT_FaultConsumer::analyze_fault_event: "
- "InitialNumberReplicas is <%d>:\n"),
- initial_number_replicas
- ));
- }
- }
- else
- {
- result = -1;
- }
-
- return result;
-}
-
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h
index b00702b18ea..fcfce525123 100755
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h
@@ -23,11 +23,14 @@
#include "orbsvcs/CosNotifyCommS.h"
#include "orbsvcs/FT_NotifierC.h"
-#include "orbsvcs/FT_ReplicationManagerC.h"
-#include "orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h"
namespace TAO
{
+
+ ///////////////////////
+ // Forward declarations
+ class FT_FaultAnalyzer;
+
/**
* Implement the CosNotifyComm::StructuredPushConsumer interface.
*
@@ -65,7 +68,7 @@ namespace TAO
int init (
PortableServer::POA_ptr poa,
FT::FaultNotifier_ptr fault_notifier,
- FT::ReplicationManager_ptr replication_manager
+ TAO::FT_FaultAnalyzer * fault_analyzer
ACE_ENV_ARG_DECL);
/**
@@ -88,47 +91,6 @@ namespace TAO
public:
- /////////////////////////
- // Implementation methods
- private:
-
- /**
- * Validate event type to make sure it is one we can handle.
- */
- int validate_event_type (
- const CosNotification::StructuredEvent & event);
-
- /**
- * Analyze a fault event.
- */
- int analyze_fault_event (
- const CosNotification::StructuredEvent & event,
- TAO::FT_FaultEventDescriptor & fault_event_desc
- ACE_ENV_ARG_DECL_WITH_DEFAULTS)
- ACE_THROW_SPEC ((CORBA::SystemException, CosEventComm::Disconnected));
-
- /// Helper functions for fault analysis.
- char* extract_type_id (const CORBA::Any& val);
- FT::ObjectGroupId extract_object_group_id (const CORBA::Any& val);
-
- int get_membership_style (
- const FT::Properties & properties,
- FT::MembershipStyleValue & membership_style);
-
- int get_replication_style (
- const FT::Properties & properties,
- FT::ReplicationStyleValue & replication_style);
-
- int get_minimum_number_replicas (
- const FT::Properties & properties,
- FT::MinimumNumberReplicasValue & minimum_number_replicas);
-
- int get_initial_number_replicas (
- const FT::Properties & properties,
- FT::InitialNumberReplicasValue & initial_number_replicas);
-
- public:
-
/**
* @name POA_CosNotifyComm::StructuredPushConsumer Methods
*
@@ -180,8 +142,8 @@ namespace TAO
/// The FaultNotifier's object reference.
FT::FaultNotifier_var fault_notifier_;
- /// The ReplicationManager's object reference.
- FT::ReplicationManager_var replication_manager_;
+ /// Application-specific Fault Analyzer.
+ TAO::FT_FaultAnalyzer * fault_analyzer_;
/// ConsumerId assigned by the notifier.
FT::FaultNotifier::ConsumerId consumer_id_;
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
index 1eb0d72643f..8f9a0b5c42e 100644
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.cpp
@@ -16,17 +16,14 @@
#include "FT_Property_Validator.h"
#include "ace/Get_Opt.h"
+#include "tao/Messaging/Messaging.h"
+#include "tao/debug.h"
#include "orbsvcs/PortableGroup/PG_Properties_Decoder.h"
#include "orbsvcs/PortableGroup/PG_Properties_Encoder.h"
-
#include "orbsvcs/PortableGroup/PG_Property_Utils.h"
#include "orbsvcs/PortableGroup/PG_conf.h"
-
-#include "tao/Messaging/Messaging.h"
-#include "tao/debug.h"
-
#include "orbsvcs/FaultTolerance/FT_IOGR_Property.h"
-
+#include "orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h"
ACE_RCSID (FT_ReplicationManager,
FT_ReplicationManager,
@@ -45,9 +42,8 @@ TAO::FT_ReplicationManager::FT_ReplicationManager ()
, property_manager_ (this->object_group_manager_)
, generic_factory_ (this->object_group_manager_, this->property_manager_)
, fault_notifier_(FT::FaultNotifier::_nil())
- , fault_notifier_ior_file_(0)
+ , fault_notifier_ior_(0)
, fault_consumer_()
- , test_iogr_(CORBA::Object::_nil())
{
//@@Note: this->init() is not called here (in the constructor)
// since it may throw an exception. Throwing an exception in
@@ -83,7 +79,7 @@ int TAO::FT_ReplicationManager::parse_args (int argc, char * argv[])
break;
case 'f':
- this->fault_notifier_ior_file_ = get_opts.opt_arg ();
+ this->fault_notifier_ior_ = get_opts.opt_arg ();
break;
case '?':
@@ -179,30 +175,18 @@ int TAO::FT_ReplicationManager::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL)
ACE_CHECK_RETURN (-1);
// If we were given an initial IOR string for a Fault Notifier on the
- // command line, convert it to an IOR.
- if (this->fault_notifier_ior_file_ != 0)
+ // command line, convert it to an IOR, then register the fault
+ // notifier.
+ if (this->fault_notifier_ior_ != 0)
{
- CORBA::String_var notifierIOR;
- if (this->readIORFile (this->fault_notifier_ior_file_, notifierIOR))
- {
- CORBA::Object_var notifier_obj = this->orb_->string_to_object (
- notifierIOR.in() ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
- FT::FaultNotifier_var notifier = FT::FaultNotifier::_narrow (
- notifier_obj.in() ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
- this->register_fault_notifier_i (notifier.in() ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
- }
- else
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT (
- "TAO::FT_ReplicationManager::init: "
- "Could not read %s.\n"),
- this->fault_notifier_ior_file_),
- -1);
- }
+ CORBA::Object_var notifier_obj = this->orb_->string_to_object (
+ this->fault_notifier_ior_ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+ FT::FaultNotifier_var notifier = FT::FaultNotifier::_narrow (
+ notifier_obj.in() ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+ this->register_fault_notifier_i (notifier.in() ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
}
// Activate the RootPOA.
@@ -415,12 +399,30 @@ TAO::FT_ReplicationManager::register_fault_notifier_i (
));
}
- result = this->fault_consumer_.init (
- this->poa_.in(),
- this->fault_notifier_.in(),
- this->replication_manager_ref_.in()
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ // Create a fault analyzer.
+ TAO::FT_FaultAnalyzer * analyzer = 0;
+ ACE_NEW_NORETURN (
+ analyzer,
+ TAO::FT_ReplicationManagerFaultAnalyzer (this));
+ if (analyzer == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManager::register_fault_notifier_i: "
+ "Error creating FaultAnalyzer.\n"
+ )
+ ));
+ result = -1;
+ }
+ if (result == 0)
+ {
+ result = this->fault_consumer_.init (
+ this->poa_.in(),
+ this->fault_notifier_.in(),
+ analyzer
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
}
ACE_CATCHANY
{
@@ -904,6 +906,7 @@ TAO::FT_ReplicationManager::create_test_iogr (ACE_ENV_SINGLE_ARG_DECL)
}
#endif
+#if 0
int TAO::FT_ReplicationManager::readIORFile (
const char * filename,
CORBA::String_var & ior)
@@ -929,4 +932,5 @@ int TAO::FT_ReplicationManager::readIORFile (
}
return result;
}
+#endif
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
index fe921137607..c58f901ca56 100644
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h
@@ -114,9 +114,6 @@ namespace TAO
const PortableGroup::Criteria & the_criteria,
CORBA::UShort & initial_number_replicas) const;
- /// Read and IOR from a file.
- int readIORFile (const char * filename, CORBA::String_var & ior);
-
/// Registers the Fault Notifier with the Replication Manager.
void register_fault_notifier_i (
FT::FaultNotifier_ptr fault_notifier
@@ -477,14 +474,11 @@ namespace TAO
/// The fault notifier.
FT::FaultNotifier_var fault_notifier_;
- const char * fault_notifier_ior_file_;
+ const char * fault_notifier_ior_;
/// The fault consumer.
TAO::FT_FaultConsumer fault_consumer_;
- /// A dummy test IOGR used for unit testing (and its group id)
- CORBA::Object_var test_iogr_;
- FT::ObjectGroupId test_iogr_group_id_;
};
} // namespace TAO
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.mpc b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.mpc
index 46a35843521..1a191561866 100644
--- a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.mpc
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManager.mpc
@@ -6,6 +6,9 @@ project : taoserver, orbsvcsexe, fault_tolerance, iormanip, ftorb {
FT_Property_Validator.cpp
FT_FaultConsumer.cpp
FT_FaultEventDescriptor.cpp
+ FT_FaultAnalyzer.cpp
+ FT_DefaultFaultAnalyzer.cpp
+ FT_ReplicationManagerFaultAnalyzer.cpp
}
}
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp
new file mode 100755
index 00000000000..a1cd7f7ea4e
--- /dev/null
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.cpp
@@ -0,0 +1,542 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file FT_ReplicationManagerFaultAnalyzer.cpp
+ *
+ * $Id$
+ *
+ * This file is part of TAO's implementation of Fault Tolerant CORBA.
+ *
+ * @author Steve Totten <totten_s@ociweb.com>
+ */
+//=============================================================================
+
+#include "orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h"
+#include "orbsvcs/CosNotifyCommC.h"
+#include "orbsvcs/FT_NotifierC.h"
+#include "orbsvcs/FT_ReplicationManager/FT_ReplicationManager.h"
+#include "orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h"
+#include "orbsvcs/PortableGroup/PG_Property_Utils.h"
+#include <tao/debug.h>
+
+#define INTEGRATED_WITH_REPLICATION_MANAGER 1
+
+ACE_RCSID (FT_ReplicationManagerFaultAnalyzer,
+ FT_ReplicationManagerFaultAnalyzer,
+ "$Id$")
+
+/// Constructor.
+TAO::FT_ReplicationManagerFaultAnalyzer::FT_ReplicationManagerFaultAnalyzer (
+ const TAO::FT_ReplicationManager * replication_manager)
+ : replication_manager_ (
+ ACE_const_cast (TAO::FT_ReplicationManager *, replication_manager))
+{
+}
+
+/// Destructor.
+TAO::FT_ReplicationManagerFaultAnalyzer::~FT_ReplicationManagerFaultAnalyzer ()
+{
+}
+
+// Validate the event to make sure it is one we can handle.
+// If it is not an event we can handle, this function logs the error
+// and returns -1.
+int TAO::FT_ReplicationManagerFaultAnalyzer::validate_event_type (
+ const CosNotification::StructuredEvent & event)
+{
+ // Delegate to base class.
+ //@@ Visual C++ 6.0 won't compile this if I include the namespace name
+ // on the base class.
+ // return TAO::FT_DefaultFaultAnalyzer::validate_event_type (event);
+ return FT_DefaultFaultAnalyzer::validate_event_type (event);
+}
+
+/// Analyze a fault event.
+int TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event (
+ const CosNotification::StructuredEvent & event)
+{
+ int result = 0;
+
+ const CosNotification::FilterableEventBody & filterable =
+ event.filterable_data;
+ CORBA::ULong item_count = filterable.length ();
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ for (CORBA::ULong n_prop = 0; n_prop < item_count; ++n_prop)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT(
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "Property Name: <%s>\n"),
+ filterable[n_prop].name.in()
+ ));
+ }
+ }
+
+ // Populate a TAO::FT_FaultEventDescriptor structure from the
+ // properties in the event.
+ TAO::FT_FaultEventDescriptor fault_event_desc;
+
+ // Extract the location.
+ if (result == 0)
+ {
+ FT::Location* temp_loc;
+ if ((filterable[1].value >>= temp_loc) == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "Could not extract Location value from fault event.\n")
+ ));
+ result = -1;
+ }
+ else
+ {
+ // Make a deep copy of the Location.
+ FT::Location* copy_loc = 0;
+ ACE_NEW_RETURN (copy_loc, FT::Location (*temp_loc), -1);
+ fault_event_desc.location = copy_loc;
+ }
+ }
+
+ // CORBA 3.0.2, section 23.4.5.1 states:
+ //
+ // The fault detector may or may not set the TypeId and
+ // ObjectGroupId fields with the following interpretations:
+ // - Neither is set if all objects at the given location have failed.
+ // - TypeId is set and ObjectGroupId is not set if all objects at
+ // the given location with the given type have failed.
+ // - Both are set if the member with the given ObjectGroupId at the
+ // given location has failed.
+ if (result == 0)
+ {
+ // All objects at location failed.
+ if (item_count == 2)
+ {
+ fault_event_desc.all_at_location_failed = 1;
+ }
+
+ // All objects of type at location failed.
+ if (item_count == 3)
+ {
+ fault_event_desc.all_of_type_at_location_failed = 1;
+ fault_event_desc.type_id = this->extract_type_id (filterable[2].value);
+ }
+
+ // An object (replica) at a location failed.
+ if (item_count == 4)
+ {
+ fault_event_desc.object_at_location_failed = 1;
+ fault_event_desc.type_id = this->extract_type_id (filterable[2].value);
+ fault_event_desc.object_group_id =
+ this->extract_object_group_id (filterable[3].value);
+ }
+ }
+
+ //TODO: Finish the implementation of analyze_fault_event() to:
+ // - if the ReplicationStyle of the object group is FT::SEMI_ACTIVE,
+ // and if the failed replica was the primary replica, set a new
+ // primary replica
+ // - if the number of replicas falls below MinimumNumberReplicas
+ // property and MembershipStyle of the object group is FT::MEMB_INF_CTRL,
+ // create and add a new member.
+
+ //@@ Q: How do we get the ObjectGroup from the ObjectGroupId?
+ //@@ A: Use TAO-specific extension to PortableGroup::ObjectGroupManager
+ // interface (get_object_group_ref_from_id()).
+#if (INTEGRATED_WITH_REPLICATION_MANAGER == 1)
+ if ((fault_event_desc.object_at_location_failed == 1) && (result == 0))
+ {
+ FT::ObjectGroup_var the_object_group = FT::ObjectGroup::_nil();
+ ACE_TRY_NEW_ENV
+ {
+ the_object_group =
+ this->replication_manager_->get_object_group_ref_from_id (
+ fault_event_desc.object_group_id
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCH (PortableGroup::ObjectGroupNotFound, ex)
+ {
+ ACE_PRINT_EXCEPTION (ex,
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: ");
+ }
+ ACE_ENDTRY;
+
+ if (CORBA::is_nil (the_object_group.in()))
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "Could not get ObjectGroup reference from ObjectGroupId: <%Q>.\n"),
+ fault_event_desc.object_group_id
+ ));
+ result = -1;
+ }
+
+ //@@ Q: How do we get the properties of the ObjectGroup to
+ // figure out the ReplicationStyle, current primary,
+ // MinimumNumberReplicas, etc.?
+ //@@ A: FT::PropertyManager::get_properties().
+
+ // Get the properties associated with this ObjectGroup.
+ FT::Properties_var properties;
+ if (result == 0)
+ {
+ properties = this->replication_manager_->get_properties (
+ the_object_group.in()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (-1);
+
+ // Get the MembershipStyle property.
+ FT::MembershipStyleValue membership_style;
+ result = this->get_membership_style (properties.in(), membership_style);
+ if (result != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "Could not extract MembershipStyle from properties on "
+ "ObjectGroup with id <%Q>.\n"),
+ fault_event_desc.object_group_id),
+ -1);
+ }
+ else
+ {
+ fault_event_desc.membership_style = membership_style;
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::validate_event_type: "
+ "MembershipStyleValue = <%d>"),
+ fault_event_desc.membership_style
+ ));
+ }
+ }
+
+ // Get the ReplicationStyle property.
+ FT::ReplicationStyleValue replication_style;
+ result = this->get_replication_style (properties.in(), replication_style);
+ if (result != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "Could not extract ReplicationStyle from properties on "
+ "ObjectGroup with id <%Q>.\n"),
+ fault_event_desc.object_group_id),
+ -1);
+ }
+ else
+ {
+ fault_event_desc.replication_style = replication_style;
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::validate_event_type: "
+ "ReplicationStyleValue = <%d>"),
+ fault_event_desc.replication_style
+ ));
+ }
+ }
+
+ // Get the MinimumNumberReplicas property.
+ FT::MinimumNumberReplicasValue minimum_number_replicas;
+ result = this->get_minimum_number_replicas (
+ properties.in(), minimum_number_replicas);
+ if (result != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "Could not extract MinimumNumberReplicas from properties on "
+ "ObjectGroup with id <%Q>.\n"),
+ fault_event_desc.object_group_id),
+ -1);
+ }
+ else
+ {
+ fault_event_desc.minimum_number_replicas = minimum_number_replicas;
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::validate_event_type: "
+ "MinimumNumberReplicas = <%d>"),
+ fault_event_desc.minimum_number_replicas
+ ));
+ }
+ }
+
+ // Get the InitialNumberReplicas property.
+ FT::InitialNumberReplicasValue initial_number_replicas;
+ result = this->get_initial_number_replicas (
+ properties.in(), initial_number_replicas);
+ if (result != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "Could not extract InitialNumberReplicas from properties on "
+ "ObjectGroup with id <%Q>.\n"),
+ fault_event_desc.object_group_id),
+ -1);
+ }
+ else
+ {
+ fault_event_desc.initial_number_replicas = initial_number_replicas;
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::validate_event_type: "
+ "InitialNumberReplicas = <%d>"),
+ fault_event_desc.initial_number_replicas
+ ));
+ }
+ }
+ }
+ }
+#endif /* (INTEGRATED_WITH_REPLICATION_MANAGER == 1) */
+
+ // Debugging support.
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Getting the location as a string.\n")
+ ));
+
+ // Get the location as a string.
+ ACE_CString loc_as_string;
+ FT::Location_var & loc = fault_event_desc.location;
+
+ for (CORBA::ULong li = 0; li < loc->length(); ++li)
+ {
+ if (li > 0) loc_as_string += "/";
+ // Assume only the "id" field of the CosNaming::Name is used.
+ loc_as_string += CORBA::string_dup (loc[li].id);
+ }
+
+ if (fault_event_desc.all_at_location_failed == 1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "All objects at location <%s> failed.\n"),
+ loc_as_string.c_str()
+ ));
+ }
+
+ if (fault_event_desc.all_of_type_at_location_failed == 1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "All objects of type <%s> at location <%s> failed.\n"),
+ fault_event_desc.type_id.in(),
+ loc_as_string.c_str()
+ ));
+ }
+
+ if (fault_event_desc.object_at_location_failed == 1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "Replica of type <%s> with ObjectGroupId <%Q> "
+ "at location <%s> failed.\n"),
+ fault_event_desc.type_id.in(),
+ fault_event_desc.object_group_id,
+ loc_as_string.c_str()
+ ));
+ }
+ }
+
+ return result;
+}
+
+// Extract a string type_id from CORBA::Any.
+// Caller owns the returned string.
+char*
+TAO::FT_ReplicationManagerFaultAnalyzer::extract_type_id (const CORBA::Any& val)
+{
+ const char* type_id_value;
+ if ((val >>= type_id_value) == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::extract_type_id: "
+ "Could not extract TypeId value from any.\n")
+ ));
+ return 0;
+ }
+
+ return CORBA::string_dup (type_id_value);
+}
+
+// Extract the ObjectGroupId from CORBA::Any.
+FT::ObjectGroupId
+TAO::FT_ReplicationManagerFaultAnalyzer::extract_object_group_id (const CORBA::Any& val)
+{
+ FT::ObjectGroupId id = (FT::ObjectGroupId)0;
+ if ((val >>= id) == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::extract_object_group_id: "
+ "Could not extract ObjectGroupId value from any.\n")
+ ));
+ }
+
+ return id;
+}
+
+//
+//TODO: Use TAO_PG::find() to get property values from properties
+// instead of all these specific "get" functions.
+//
+
+// Get the MembershipStyle property.
+int TAO::FT_ReplicationManagerFaultAnalyzer::get_membership_style (
+ const FT::Properties & properties,
+ FT::MembershipStyleValue & membership_style)
+{
+ FT::Name prop_name (1);
+ prop_name.length (1);
+ prop_name[0].id = CORBA::string_dup (FT::FT_MEMBERSHIP_STYLE);
+ int result = 0;
+
+ FT::Value value;
+ if (TAO_PG::get_property_value (prop_name, properties, value)
+ && ((value >>= membership_style) == 1))
+ {
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "MembershipStyle is <%d>:\n"),
+ membership_style
+ ));
+ }
+ }
+ else
+ {
+ result = -1;
+ }
+
+ return result;
+}
+
+int TAO::FT_ReplicationManagerFaultAnalyzer::get_replication_style (
+ const FT::Properties & properties,
+ FT::ReplicationStyleValue & replication_style)
+{
+ FT::Name prop_name (1);
+ prop_name.length (1);
+ prop_name[0].id = CORBA::string_dup (FT::FT_REPLICATION_STYLE);
+ int result = 0;
+
+ FT::Value value;
+ if (TAO_PG::get_property_value (prop_name, properties, value)
+ && ((value >>= replication_style) == 1))
+ {
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "ReplicationStyle is <%d>:\n"),
+ replication_style
+ ));
+ }
+ }
+ else
+ {
+ result = -1;
+ }
+
+ return result;
+}
+
+int TAO::FT_ReplicationManagerFaultAnalyzer::get_minimum_number_replicas (
+ const FT::Properties & properties,
+ FT::MinimumNumberReplicasValue & minimum_number_replicas)
+{
+ FT::Name prop_name (1);
+ prop_name.length (1);
+ prop_name[0].id = CORBA::string_dup (FT::FT_MINIMUM_NUMBER_REPLICAS);
+ int result = 0;
+
+ FT::Value value;
+ if (TAO_PG::get_property_value (prop_name, properties, value)
+ && ((value >>= minimum_number_replicas) == 1))
+ {
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "MinimumNumberReplicas is <%d>:\n"),
+ minimum_number_replicas
+ ));
+ }
+ }
+ else
+ {
+ result = -1;
+ }
+
+ return result;
+}
+
+int TAO::FT_ReplicationManagerFaultAnalyzer::get_initial_number_replicas (
+ const FT::Properties & properties,
+ FT::InitialNumberReplicasValue & initial_number_replicas)
+{
+ FT::Name prop_name (1);
+ prop_name.length (1);
+ prop_name[0].id = CORBA::string_dup (FT::FT_INITIAL_NUMBER_REPLICAS);
+ int result = 0;
+
+ FT::Value value;
+ if (TAO_PG::get_property_value (prop_name, properties, value)
+ && ((value >>= initial_number_replicas) == 1))
+ {
+#if (TAO_DEBUG_LEVEL_NEEDED == 1)
+ if (TAO_debug_level > 6)
+#endif /* (TAO_DEBUG_LEVEL_NEEDED == 1) */
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT (
+ "TAO::FT_ReplicationManagerFaultAnalyzer::analyze_fault_event: "
+ "InitialNumberReplicas is <%d>:\n"),
+ initial_number_replicas
+ ));
+ }
+ }
+ else
+ {
+ result = -1;
+ }
+
+ return result;
+}
+
diff --git a/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h
new file mode 100755
index 00000000000..5b31d600e38
--- /dev/null
+++ b/TAO/orbsvcs/FT_ReplicationManager/FT_ReplicationManagerFaultAnalyzer.h
@@ -0,0 +1,124 @@
+/* -*- C++ -*- */
+//=============================================================================
+/**
+ * @file FT_ReplicationManagerFaultAnalyzer.h
+ *
+ * $Id$
+ *
+ * This file is part of TAO's implementation of Fault Tolerant CORBA.
+ * This is the Replication Manager's implementation of a fault analyzer.
+ *
+ * @author Steve Totten <totten_s@ociweb.com>
+ */
+//=============================================================================
+
+
+#ifndef FT_REPLICATION_MANAGER_FAULT_ANALYZER_H_
+#define FT_REPLICATION_MANAGER_FAULT_ANALYZER_H_
+
+#include /**/ "ace/pre.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h"
+#include "orbsvcs/FT_CORBAC.h"
+
+namespace TAO
+{
+
+ ///////////////////////
+ // Forward declarations
+ class FT_ReplicationManager;
+
+ /**
+ * Replication Manager's fault analyzer.
+ *
+ */
+ class FT_ReplicationManagerFaultAnalyzer
+ : public TAO::FT_DefaultFaultAnalyzer
+ {
+
+ public:
+ /**
+ * Constructor.
+ * @param replication_manager Pointer to TAO::FT_ReplicationManager.
+ */
+ FT_ReplicationManagerFaultAnalyzer (
+ const TAO::FT_ReplicationManager * replication_manager);
+
+ /**
+ * Destructor.
+ */
+ virtual ~FT_ReplicationManagerFaultAnalyzer ();
+
+ public:
+
+ /**
+ * Validate event type to make sure it is one we can handle.
+ * @param event The structured fault event, as from the Fault Notifier.
+ * @return 0 if it is a valid event type, -1 otherwise.
+ */
+ virtual int validate_event_type (
+ const CosNotification::StructuredEvent & event);
+
+ /**
+ * Analyze a fault event.
+ * @param event The structured fault event, as from the Fault Notifier.
+ * @return 0 on success, -1 on failure.
+ */
+ virtual int analyze_fault_event (
+ const CosNotification::StructuredEvent & event);
+
+ ////////////////////
+ // Forbidden methods
+ private:
+ /// Default constructor.
+ FT_ReplicationManagerFaultAnalyzer ();
+
+ /// Copy constructor.
+ FT_ReplicationManagerFaultAnalyzer (
+ const FT_ReplicationManagerFaultAnalyzer & rhs);
+
+ /// Assignment operator.
+ FT_ReplicationManagerFaultAnalyzer & operator = (
+ const FT_ReplicationManagerFaultAnalyzer & rhs);
+
+ /////////////////////////
+ // Implementation methods
+ protected:
+
+ /// Helper functions for fault analysis.
+ char* extract_type_id (const CORBA::Any& val);
+ FT::ObjectGroupId extract_object_group_id (const CORBA::Any& val);
+
+ int get_membership_style (
+ const FT::Properties & properties,
+ FT::MembershipStyleValue & membership_style);
+
+ int get_replication_style (
+ const FT::Properties & properties,
+ FT::ReplicationStyleValue & replication_style);
+
+ int get_minimum_number_replicas (
+ const FT::Properties & properties,
+ FT::MinimumNumberReplicasValue & minimum_number_replicas);
+
+ int get_initial_number_replicas (
+ const FT::Properties & properties,
+ FT::InitialNumberReplicasValue & initial_number_replicas);
+
+ ///////////////
+ // Data Members
+ private:
+ FT_ReplicationManager * replication_manager_;
+
+ };
+
+} // namespace TAO
+
+#include /**/ "ace/post.h"
+
+#endif /* FT_REPLICATION_MANAGER_FAULT_ANALYZER_H_ */
+
diff --git a/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl b/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl
index f70950986da..b6cb3572d39 100644
--- a/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl
+++ b/TAO/orbsvcs/orbsvcs/FT_ReplicationManager.idl
@@ -29,7 +29,8 @@ module FT
// Specification of ReplicationManager Interface
interface ReplicationManager : PropertyManager,
FTObjectGroupManager,
- GenericFactory {
+ GenericFactory
+ {
/**
* Registers the Fault Notifier with the Replication Manager.
@@ -47,13 +48,16 @@ module FT
/**
* Find a registry for factories that create fault tolerant replicas.
*
- * TAO-specific method
+ * TAO-specific operation
*
- * Factories in this registry will be used by the ReplicationManager's implementation
- * of GenericFactory::create_object when infrastructure controlled membership is specified.
+ * 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.
+ * 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
diff --git a/TAO/orbsvcs/tests/FT_App/FT_App.mpc b/TAO/orbsvcs/tests/FT_App/FT_App.mpc
index 15aba7e7be3..8cd26b7b3fd 100644
--- a/TAO/orbsvcs/tests/FT_App/FT_App.mpc
+++ b/TAO/orbsvcs/tests/FT_App/FT_App.mpc
@@ -87,7 +87,8 @@ project(*FaultConsumer): taoserver, fault_tolerance, orbsvcsexe {
FTApp_FaultConsumer_Main.cpp
ReplicationManagerFaultConsumerAdapter.cpp
../../FT_ReplicationManager/FT_FaultConsumer.cpp
- ../../FT_ReplicationManager/FT_FaultEventDescriptor.cpp
+ ../../FT_ReplicationManager/FT_FaultAnalyzer.cpp
+ ../../FT_ReplicationManager/FT_DefaultFaultAnalyzer.cpp
}
// explicitly omit IDL files
@@ -129,4 +130,4 @@ project(*Creator): taoclient, fault_tolerance, orbsvcsexe {
// pretend the pl file is documentation for now
run_test_registry.pl
}
-} \ No newline at end of file
+}
diff --git a/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp b/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp
index eae1178f70d..ef16bd8efd1 100644
--- a/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp
+++ b/TAO/orbsvcs/tests/FT_App/FT_UnitTests.cpp
@@ -876,7 +876,8 @@ int FT_UnitTests::readIORFile(const char * fileName, CORBA::String_var & ior)
{
ACE_TRY
{
- test_iogr_ = rm_->create_test_iogr();
+ // create_test_iogr() has been removed from ReplicationManager.
+ // test_iogr_ = rm_->create_test_iogr();
}
ACE_CATCHANY
{
diff --git a/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp b/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp
index 17deef7f1a4..acebc05c5af 100755
--- a/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp
+++ b/TAO/orbsvcs/tests/FT_App/ReplicationManagerFaultConsumerAdapter.cpp
@@ -3,10 +3,9 @@
// $Id$
#include "ReplicationManagerFaultConsumerAdapter.h"
-
-#include <ace/Get_Opt.h>
-#include <tao/PortableServer/ORB_Manager.h>
-#include <orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h>
+#include "ace/Get_Opt.h"
+#include "orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h"
+#include "orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h"
#include <iostream>
#include <fstream>
@@ -271,27 +270,13 @@ int ReplicationManagerFaultConsumerAdapter::init (
poa_obj.in() ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
- // Fake out the ReplicationManager IOR.
- CORBA::Object_var obj = this->orb_->string_to_object (
- "corbaloc::localhost:1900/ReplicationManager"
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
- FT::ReplicationManager_var repl_mgr =
- FT::ReplicationManager::_unchecked_narrow (
- obj.in() ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (-1);
- 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);
- }
+ // Create a fault analyzer.
+ TAO::FT_FaultAnalyzer * analyzer = 0;
+ ACE_NEW_RETURN (analyzer, TAO::FT_DefaultFaultAnalyzer (), -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.
+ // Fault Notifier we pass it.
ACE_DEBUG ((
LM_DEBUG,
ACE_TEXT ("ReplicationManagerFaultConsumerAdapter::init: ")
@@ -301,7 +286,7 @@ int ReplicationManagerFaultConsumerAdapter::init (
result = this->p_fault_consumer_->init (
poa.in(),
this->notifier_.in(),
- repl_mgr.in()
+ analyzer
ACE_ENV_ARG_PARAMETER);
ACE_CHECK_RETURN (-1);
if (result != 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 2881ee583ba..5a3dd149d51 100755
--- a/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl
+++ b/TAO/orbsvcs/tests/FT_App/run_test_fault_consumer.pl
@@ -140,7 +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 -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 file://$detector_ior -r file://$replica1_ior -f file://$replica2_ior");
+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($CL);
if (simulated) {
diff --git a/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl b/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl
index 976b89c067d..e70944c75fd 100755
--- a/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl
+++ b/TAO/orbsvcs/tests/FT_App/run_test_replication_mgr.pl
@@ -133,6 +133,7 @@ unlink $replica1_ior;
unlink $replica2_ior;
unlink $detector_ior;
unlink $notifier_ior;
+unlink $replmgr_ior;
unlink $ready_file;
unlink $client_data;
@@ -142,8 +143,8 @@ 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($REPLM) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/FT_ReplicationManager$build_directory/FT_ReplicationManager", "-o $replmgr_ior -f $notifier_ior");
+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($REPLM) = new PerlACE::Process ("$ENV{'TAO_ROOT'}/orbsvcs/FT_ReplicationManager$build_directory/FT_ReplicationManager", "-o $replmgr_ior -f file://$notifier_ior");
my($CL);
if (simulated) {
@@ -276,6 +277,7 @@ unlink $replica1_ior;
unlink $replica2_ior;
unlink $detector_ior;
unlink $notifier_ior;
+unlink $replmgr_ior;
unlink $ready_file;
#client's work file