1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/* -*- 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/Log_Macros.h"
#include "FT_DefaultFaultAnalyzer.h"
#include "orbsvcs/CosNotifyCommC.h"
#include "orbsvcs/FT_NotifierC.h"
#include "orbsvcs/FT_FaultDetectorFactoryC.h"
#include "orbsvcs/FT_ReplicationManagerC.h"
#include "orbsvcs/FT_ReplicationManager/FT_FaultEventDescriptor.h"
#include "tao/debug.h"
#include "ace/OS_NS_string.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
/// 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".
// @@ why make string dups just to do a strcmp?
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)
{
if (ACE_OS::strcmp (domain_name.in(), FT::FT_EVENT_TYPE_DOMAIN) != 0 ||
ACE_OS::strcmp (type_name.in(), FT::FT_EVENT_TYPE_NAME) != 0)
{
if (TAO_debug_level > 6)
{
ORBSVCS_ERROR ((LM_ERROR,
ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
ACE_TEXT ("Received invalid event type.\n")
ACE_TEXT ("EventType domain: <%s>\n")
ACE_TEXT ("EventType type: <%s>\n")
ACE_TEXT ("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(), FT::FT_DOMAIN_ID) != 0)
{
if (TAO_debug_level > 6)
{
ORBSVCS_ERROR ((LM_ERROR,
ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
ACE_TEXT ("Received invalid structured event.\n")
ACE_TEXT ("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(), FT::FT_LOCATION) != 0)
{
if (TAO_debug_level > 6)
{
ORBSVCS_ERROR ((LM_ERROR,
ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
ACE_TEXT ("Received invalid structured event.\n")
ACE_TEXT ("filterable_data[1] must be \"Location\", not \"%s\"\n"),
event.filterable_data[1].name.in()
));
}
result = -1;
}
}
else
{
if (TAO_debug_level > 6)
{
ORBSVCS_ERROR ((LM_ERROR,
ACE_TEXT ("TAO::FT_DefaultFaultAnalyzer::validate_event_type: ")
ACE_TEXT ("Received invalid structured event.\n")
ACE_TEXT ("There must be at least two name/value pairs in ")
ACE_TEXT ("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)
{
ACE_UNUSED_ARG (event);
if (TAO_debug_level > 6)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT (
"In TAO::FT_DefaultFaultAnalyzer::analyze_fault_event.\n")
));
}
// no-op
return 0;
}
TAO_END_VERSIONED_NAMESPACE_DECL
|