2 //=============================================================================
4 * @file FT_DefaultFaultAnalyzer.cpp
6 * This file is part of TAO's implementation of Fault Tolerant CORBA.
8 * @author Steve Totten <totten_s@ociweb.com>
10 //=============================================================================
12 #include "orbsvcs/Log_Macros.h"
13 #include "FT_DefaultFaultAnalyzer.h"
14 #include "orbsvcs/CosNotifyCommC.h"
15 #include "orbsvcs/FT_NotifierC.h"
16 #include "orbsvcs/FT_FaultDetectorFactoryC.h"
17 #include "orbsvcs/FT_ReplicationManagerC.h"
18 #include "orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h"
19 #include "tao/debug.h"
20 #include "ace/OS_NS_string.h"
22 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
24 /// Default constructor.
25 TAO::FT_DefaultFaultAnalyzer::FT_DefaultFaultAnalyzer ()
30 TAO::FT_DefaultFaultAnalyzer::~FT_DefaultFaultAnalyzer ()
34 // Validate the event to make sure it is one we can handle.
35 // If it is not an event we can handle, this function logs the error
37 int TAO::FT_DefaultFaultAnalyzer::validate_event_type (
38 const CosNotification::StructuredEvent
& event
)
42 // CORBA 3.0.2, section 23.4.5.1 states:
44 // The fault management specification defines one event type:
45 // ObjectCrashFault. As the name suggests, this event is
46 // generated by a Fault Detector when it detects that an object
49 // So, the event header's event_type.domain_name must be "FT_CORBA"
50 // and the event header's event_type.type_name must be "ObjectCrashFault".
51 // @@ why make string dups just to do a strcmp?
52 CORBA::String_var domain_name
= CORBA::string_dup (
53 event
.header
.fixed_header
.event_type
.domain_name
);
54 CORBA::String_var type_name
= CORBA::string_dup (
55 event
.header
.fixed_header
.event_type
.type_name
);
56 CORBA::String_var event_name
= CORBA::string_dup (
57 event
.header
.fixed_header
.event_name
);
61 if (ACE_OS::strcmp (domain_name
.in(), FT::FT_EVENT_TYPE_DOMAIN
) != 0 ||
62 ACE_OS::strcmp (type_name
.in(), FT::FT_EVENT_TYPE_NAME
) != 0)
64 if (TAO_debug_level
> 6)
66 ORBSVCS_ERROR ((LM_ERROR
,
67 ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
68 ACE_TEXT ("Received invalid event type.\n")
69 ACE_TEXT ("EventType domain: <%s>\n")
70 ACE_TEXT ("EventType type: <%s>\n")
71 ACE_TEXT ("EventName: <%s>\n"),
81 // CORBA 3.0.2, section 23.4.5.1 also states:
83 // The filterable_data part of the event body contains the
84 // identity of the crashed object as four name-value pairs: the
85 // fault tolerance domain identifier, the member's location
86 // identifier, the repository identifier and the object group
87 // identifier. The Fault Notifier filters events based on the
88 // domain_name, the type_name, and the four identifiers. All
89 // other fields of the structured event may be set to null.
91 // The Fault Detector always sets the following fault event
92 // fields: domain_name, type_name, FTDomainId, and Location.
94 // So, at least "FTDomainId" and "Location" must be present:
97 if (event
.filterable_data
.length () >= 2)
99 // Check for FTDomainId.
101 event
.filterable_data
[0].name
.in(), FT::FT_DOMAIN_ID
) != 0)
103 if (TAO_debug_level
> 6)
105 ORBSVCS_ERROR ((LM_ERROR
,
106 ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
107 ACE_TEXT ("Received invalid structured event.\n")
108 ACE_TEXT ("filterable_data[0] must be \"FTDomainId\", not \"%s\"\n"),
109 event
.filterable_data
[0].name
.in()
114 else if (ACE_OS::strcmp (
115 event
.filterable_data
[1].name
.in(), FT::FT_LOCATION
) != 0)
117 if (TAO_debug_level
> 6)
119 ORBSVCS_ERROR ((LM_ERROR
,
120 ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
121 ACE_TEXT ("Received invalid structured event.\n")
122 ACE_TEXT ("filterable_data[1] must be \"Location\", not \"%s\"\n"),
123 event
.filterable_data
[1].name
.in()
131 if (TAO_debug_level
> 6)
133 ORBSVCS_ERROR ((LM_ERROR
,
134 ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
135 ACE_TEXT ("Received invalid structured event.\n")
136 ACE_TEXT ("There must be at least two name/value pairs in ")
137 ACE_TEXT ("the filterable_data field, for \"FTDomainId\" and \"Location\".\n")
147 /// Analyze a fault event.
148 int TAO::FT_DefaultFaultAnalyzer::analyze_fault_event (
149 const CosNotification::StructuredEvent
& event
)
151 ACE_UNUSED_ARG (event
);
152 if (TAO_debug_level
> 6)
154 ORBSVCS_DEBUG ((LM_DEBUG
,
156 "In TAO::FT_DefaultFaultAnalyzer::analyze_fault_event.\n")
163 TAO_END_VERSIONED_NAMESPACE_DECL