2 //=============================================================================
4 * @file FT_ReplicationManagerFaultAnalyzer.h
6 * This file is part of TAO's implementation of Fault Tolerant CORBA.
7 * This is the Replication Manager's implementation of a fault analyzer.
9 * @author Steve Totten <totten_s@ociweb.com>
11 //=============================================================================
14 #ifndef FT_REPLICATION_MANAGER_FAULT_ANALYZER_H_
15 #define FT_REPLICATION_MANAGER_FAULT_ANALYZER_H_
17 #include /**/ "ace/pre.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "orbsvcs/FT_ReplicationManager/FT_DefaultFaultAnalyzer.h"
25 #include "orbsvcs/FT_CORBAC.h"
27 // Forward declarations.
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 template <class T
> class ACE_Unbounded_Set
;
30 template <class T
> class ACE_Unbounded_Set_Iterator
;
31 ACE_END_VERSIONED_NAMESPACE_DECL
33 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
38 ///////////////////////
39 // Forward declarations
40 class FT_ReplicationManager
;
41 struct FT_FaultEventDescriptor
;
43 typedef ACE_Unbounded_Set
<PortableGroup::Location
> FT_Location_Set
;
46 * Replication Manager's fault analyzer.
49 class FT_ReplicationManagerFaultAnalyzer
50 : public ::TAO::FT_DefaultFaultAnalyzer
56 * @param replication_manager Pointer to TAO::FT_ReplicationManager.
58 FT_ReplicationManagerFaultAnalyzer (
59 const TAO::FT_ReplicationManager
* replication_manager
);
64 virtual ~FT_ReplicationManagerFaultAnalyzer ();
69 * Validate event type to make sure it is one we can handle.
70 * @param event The structured fault event, as from the Fault Notifier.
71 * @return 0 if it is a valid event type, -1 otherwise.
73 virtual int validate_event_type (
74 const CosNotification::StructuredEvent
& event
);
77 * Analyze a fault event.
78 * @param event The structured fault event, as from the Fault Notifier.
79 * @return 0 on success, -1 on failure.
81 virtual int analyze_fault_event (
82 const CosNotification::StructuredEvent
& event
);
87 /// Default constructor.
88 FT_ReplicationManagerFaultAnalyzer ();
91 FT_ReplicationManagerFaultAnalyzer (
92 const FT_ReplicationManagerFaultAnalyzer
& rhs
);
94 /// Assignment operator.
95 FT_ReplicationManagerFaultAnalyzer
& operator = (
96 const FT_ReplicationManagerFaultAnalyzer
& rhs
);
98 /////////////////////////
99 // Implementation methods
102 /// Helper functions for fault analysis.
104 // Extract the type id from a CORBA any.
105 int get_type_id (const CORBA::Any
& val
, PortableGroup::TypeId_out type_id
);
107 // Extract the ObjectGroupId from a CORBA any.
108 int get_object_group_id (const CORBA::Any
& val
, PortableGroup::ObjectGroupId
& id
);
110 // Extract the PortableGroup::Location from a CORBA any.
111 int get_location (const CORBA::Any
& val
, PortableGroup::Location_out location
);
113 // Get the MembershipStyle property.
114 int get_membership_style (
115 const PortableGroup::Properties
& properties
,
116 PortableGroup::MembershipStyleValue
& membership_style
);
118 // Get the ReplicationStyle property.
119 int get_replication_style (
120 const PortableGroup::Properties
& properties
,
121 FT::ReplicationStyleValue
& replication_style
);
123 // Get the MinimumNumberMembers property.
124 int get_minimum_number_members (
125 const PortableGroup::Properties
& properties
,
126 PortableGroup::MinimumNumberMembersValue
& minimum_number_members
);
128 // Get the InitialNumberMembers property.
129 int get_initial_number_members (
130 const PortableGroup::Properties
& properties
,
131 PortableGroup::InitialNumberMembersValue
& initial_number_members
);
133 // Get the Factories property.
135 const PortableGroup::Properties
& properties
,
136 PortableGroup::FactoryInfos_out factories
);
138 // Handle a single replica failure.
139 int single_replica_failure (
140 TAO::FT_FaultEventDescriptor
& fault_event_desc
);
142 // Handle a location failure.
143 int location_failure (
144 TAO::FT_FaultEventDescriptor
& fault_event_desc
);
146 // Handle a type at location failure.
148 TAO::FT_FaultEventDescriptor
& fault_event_desc
);
150 // Is the replica at location the primary member of its ObjectGroup?
151 // Sets <object_is_primary> and returns 0 on success.
152 // Returns -1 on failure.
153 int is_primary_member (
154 const PortableGroup::ObjectGroup_ptr iogr
,
155 const PortableGroup::Location
& location
,
156 int & object_is_primary
);
158 /// remove a failed member from a group
159 int remove_failed_member (
160 PortableGroup::ObjectGroup_ptr iogr
,
161 TAO::FT_FaultEventDescriptor
& fault_event_desc
,
162 PortableGroup::ObjectGroup_out new_iogr
);
165 // Choose a new primary member for the ObjectGroup.
166 // Sets <new_iogr> and returns 0 on success.
167 // Returns -1 on failure.
168 int set_new_primary (
169 PortableGroup::ObjectGroup_ptr iogr
,
170 TAO::FT_FaultEventDescriptor
& fault_event_desc
,
171 PortableGroup::ObjectGroup_out new_iogr
);
173 #if 0 // this is handled by the remove_member method
174 // While the number of members in the object group is less than
175 // the MinimumNumberMembers property, add new members.
176 // Sets <new_iogr> and returns 0 on success.
177 // Returns -1 on failure.
179 PortableGroup::ObjectGroup_ptr iogr
,
180 TAO::FT_FaultEventDescriptor
& fault_event_desc
,
181 PortableGroup::ObjectGroup_out new_iogr
);
187 FT_ReplicationManager
* replication_manager_
;
193 TAO_END_VERSIONED_NAMESPACE_DECL
195 #include /**/ "ace/post.h"
197 #endif /* FT_REPLICATION_MANAGER_FAULT_ANALYZER_H_ */