Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / orbsvcs / FT_ReplicationManager / FT_ReplicationManagerFaultAnalyzer.h
blob520cfe46714ea3ef1f3bead47c4de6875fe6583a
1 /* -*- C++ -*- */
2 //=============================================================================
3 /**
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"
18 #include <ace/ACE.h>
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #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
35 namespace TAO
37 ///////////////////////
38 // Forward declarations
39 class FT_ReplicationManager;
40 struct FT_FaultEventDescriptor;
42 typedef ACE_Unbounded_Set<PortableGroup::Location> FT_Location_Set;
44 /**
45 * Replication Manager's fault analyzer.
48 class FT_ReplicationManagerFaultAnalyzer
49 : public ::TAO::FT_DefaultFaultAnalyzer
51 public:
52 /**
53 * Constructor.
54 * @param replication_manager Pointer to TAO::FT_ReplicationManager.
56 FT_ReplicationManagerFaultAnalyzer (
57 const TAO::FT_ReplicationManager * replication_manager);
59 /**
60 * Destructor.
62 virtual ~FT_ReplicationManagerFaultAnalyzer ();
64 public:
65 /**
66 * Validate event type to make sure it is one we can handle.
67 * @param event The structured fault event, as from the Fault Notifier.
68 * @return 0 if it is a valid event type, -1 otherwise.
70 virtual int validate_event_type (
71 const CosNotification::StructuredEvent & event);
73 /**
74 * Analyze a fault event.
75 * @param event The structured fault event, as from the Fault Notifier.
76 * @return 0 on success, -1 on failure.
78 virtual int analyze_fault_event (
79 const CosNotification::StructuredEvent & event);
81 ////////////////////
82 // Forbidden methods
83 private:
84 /// Default constructor.
85 FT_ReplicationManagerFaultAnalyzer ();
87 /// Copy constructor.
88 FT_ReplicationManagerFaultAnalyzer (
89 const FT_ReplicationManagerFaultAnalyzer & rhs);
91 /// Assignment operator.
92 FT_ReplicationManagerFaultAnalyzer & operator = (
93 const FT_ReplicationManagerFaultAnalyzer & rhs);
95 /////////////////////////
96 // Implementation methods
97 protected:
98 /// Helper functions for fault analysis.
100 // Extract the type id from a CORBA any.
101 int get_type_id (const CORBA::Any& val, PortableGroup::TypeId_out type_id);
103 // Extract the ObjectGroupId from a CORBA any.
104 int get_object_group_id (const CORBA::Any& val, PortableGroup::ObjectGroupId& id);
106 // Extract the PortableGroup::Location from a CORBA any.
107 int get_location (const CORBA::Any& val, PortableGroup::Location_out location);
109 // Get the MembershipStyle property.
110 int get_membership_style (
111 const PortableGroup::Properties & properties,
112 PortableGroup::MembershipStyleValue & membership_style);
114 // Get the ReplicationStyle property.
115 int get_replication_style (
116 const PortableGroup::Properties & properties,
117 FT::ReplicationStyleValue & replication_style);
119 // Get the MinimumNumberMembers property.
120 int get_minimum_number_members (
121 const PortableGroup::Properties & properties,
122 PortableGroup::MinimumNumberMembersValue & minimum_number_members);
124 // Get the InitialNumberMembers property.
125 int get_initial_number_members (
126 const PortableGroup::Properties & properties,
127 PortableGroup::InitialNumberMembersValue & initial_number_members);
129 // Get the Factories property.
130 int get_factories (
131 const PortableGroup::Properties & properties,
132 PortableGroup::FactoryInfos_out factories);
134 // Handle a single replica failure.
135 int single_replica_failure (
136 TAO::FT_FaultEventDescriptor & fault_event_desc);
138 // Handle a location failure.
139 int location_failure (
140 TAO::FT_FaultEventDescriptor & fault_event_desc);
142 // Handle a type at location failure.
143 int type_failure (
144 TAO::FT_FaultEventDescriptor & fault_event_desc);
146 // Is the replica at location the primary member of its ObjectGroup?
147 // Sets <object_is_primary> and returns 0 on success.
148 // Returns -1 on failure.
149 int is_primary_member (
150 const PortableGroup::ObjectGroup_ptr iogr,
151 const PortableGroup::Location & location,
152 int & object_is_primary);
154 /// remove a failed member from a group
155 int remove_failed_member (
156 PortableGroup::ObjectGroup_ptr iogr,
157 TAO::FT_FaultEventDescriptor & fault_event_desc,
158 PortableGroup::ObjectGroup_out new_iogr);
161 // Choose a new primary member for the ObjectGroup.
162 // Sets <new_iogr> and returns 0 on success.
163 // Returns -1 on failure.
164 int set_new_primary (
165 PortableGroup::ObjectGroup_ptr iogr,
166 TAO::FT_FaultEventDescriptor & fault_event_desc,
167 PortableGroup::ObjectGroup_out new_iogr);
169 #if 0 // this is handled by the remove_member method
170 // While the number of members in the object group is less than
171 // the MinimumNumberMembers property, add new members.
172 // Sets <new_iogr> and returns 0 on success.
173 // Returns -1 on failure.
174 int add_members (
175 PortableGroup::ObjectGroup_ptr iogr,
176 TAO::FT_FaultEventDescriptor & fault_event_desc,
177 PortableGroup::ObjectGroup_out new_iogr);
178 #endif
180 ///////////////
181 // Data Members
182 private:
183 FT_ReplicationManager * replication_manager_;
185 } // namespace TAO
187 TAO_END_VERSIONED_NAMESPACE_DECL
189 #include /**/ "ace/post.h"
191 #endif /* FT_REPLICATION_MANAGER_FAULT_ANALYZER_H_ */