2 //=============================================================================
4 * @file FT_ReplicationManager.h
6 * This file is part of Fault Tolerant CORBA.
8 * @author Curt Hibbs <hibbs_c@ociweb.com>
10 //=============================================================================
13 #ifndef FT_REPLICATION_MANAGER_H_
14 #define FT_REPLICATION_MANAGER_H_
16 #include /**/ "ace/pre.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include <orbsvcs/FT_ReplicationManagerS.h>
24 //#include <orbsvcs/PortableGroup/PG_PropertyManager.h>
25 //#include <orbsvcs/PortableGroup/PG_GenericFactory.h>
26 //#include <orbsvcs/PortableGroup/PG_ObjectGroupManager.h>
27 // Note: the new, improved versions...
28 //#include <orbsvcs/PortableGroup/PG_Object_Group_Map.h>
29 #include <orbsvcs/PortableGroup/PG_Properties_Support.h>
30 #include <orbsvcs/PortableGroup/PG_Group_Factory.h>
32 #include <orbsvcs/PortableGroup/PG_FactoryRegistry.h>
33 #include <orbsvcs/FT_ReplicationManager/FT_FaultConsumer.h>
35 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
40 * Implement the ReplicationManager interfaces.
42 * The ReplicationManager does most of its work by delegating to
43 * support objects. These include:
45 * TAO::PG_Group_Factory group_factory_;
46 * The group factory contains a collection of TAO::PG_Object_Groups
47 * It provides methods to create new groups, destroy old groups and
48 * find existing groups.
50 * TAO::PG_Object_Group
51 * These objects which can be found through the group factory provde
52 * methods to create and add group members, remove and delete group
53 * members and set group properties.
55 * TAO::PG_Properties_Support properties_support_;
56 * This object maintains sets of properties(TAO::PG_Property_Set).
57 * In particular it has one default property set, and a collection of
58 * property sets indexed by type_id.
59 * The default property set acts as a parent to the type_id property
60 * sets and the type_id property sets act as parents to the property
61 * sets contained in PG_Object_Group.
63 * FT::FaultNotifier_var fault_notifier_;
64 * This notification channel is "the" source of fault notifications.
66 * TAO::FT_FaultConsumer fault_consumer_;
67 * This object subscribes to the fault_notifier_as a fault consumer. It
68 * analyzes incoming fault notifications and calls appropriate ReplicationManager
69 * methods to respond to the fault.
71 * TAO::PG_FactoryRegistry factory_registry_;
72 * This object maintains a collection of factory registrations. When a factory
73 * is started it registeres itself with the ReplicationManager (delegated to this
74 * object). When a member needs to be created in an object group this factory
75 * registry is queried to find factories that can create the member.
77 class FT_ReplicationManager
78 : public virtual POA_FT::ReplicationManager
80 //////////////////////
81 // non-CORBA interface
85 * Default constructor.
86 * Call init after constructing the object to prepare it for use.
88 FT_ReplicationManager ();
92 * Actual cleanup happens in the fini function.
94 virtual ~FT_ReplicationManager ();
98 * Parse command line arguments.
99 * @param argc traditional C argc
100 * @param argv traditional C argv
101 * @return zero for success; nonzero is process return code for failure.
103 int parse_args (int argc
, ACE_TCHAR
* argv
[]);
106 * Initialize this object.
107 * @param orb Our CORBA::ORB -- we keep var to it.
108 * @return zero for success; nonzero is process return code for failure.
110 int init (CORBA::ORB_ptr orb
);
114 * @return zero for success; nonzero is process return code for failure.
119 * Idle-time activity.
121 * @param result is set to process return code if return value is non-zero.
122 * @return zero to continue; nonzero to exit
124 int idle (int & result
);
128 * Identify this fault detector factory.
129 * @return a string to identify this object for logging/console message purposes.
131 const char * identity () const;
134 * Get the type_id associated with an object group.
135 * @param object_group The ObjectGroup.
136 * @return String identifying the type id associated with the ObjectGroup.
138 char * type_id (PortableGroup::ObjectGroup_ptr object_group
);
141 //////////////////////
142 // CORBA interface(s)
146 * @name POA_FT::ReplicationManager Methods
148 * Methods required by the POA_FT::ReplicationManager interface.
151 /// Registers the Fault Notifier with the Replication Manager.
152 virtual void register_fault_notifier (
153 FT::FaultNotifier_ptr fault_notifier
);
155 /// Returns the reference of the Fault Notifier.
156 virtual FT::FaultNotifier_ptr
get_fault_notifier ();
158 /// TAO-specific find factory registry
159 virtual ::PortableGroup::FactoryRegistry_ptr
get_factory_registry (
160 const PortableGroup::Criteria
& selection_criteria
);
162 /// TAO-specific shutdown operation.
163 virtual void shutdown ();
168 * @name PortableGroup::PropertyManager Methods
170 * Methods required by the PortableGroup::PropertyManager interface.
173 /// Set the default properties to be used by all object groups.
174 virtual void set_default_properties (
175 const PortableGroup::Properties
& props
);
177 /// Get the default properties used by all object groups.
178 virtual PortableGroup::Properties
* get_default_properties ();
180 /// Remove default properties.
181 virtual void remove_default_properties (
182 const PortableGroup::Properties
& props
);
185 * Set properties associated with a given Replica type. These
186 * properties override the default properties on a name-by-name basis.
188 virtual void set_type_properties (
189 const char * type_id
,
190 const PortableGroup::Properties
& overrides
);
193 * Return the properties associated with a given Replica type. These
194 * properties include the type-specific properties in use, in
195 * addition to the default properties that were not overridden.
197 virtual PortableGroup::Properties
* get_type_properties (
198 const char * type_id
);
200 /// Remove the given properties associated with the Replica type ID.
201 virtual void remove_type_properties (
202 const char * type_id
,
203 const PortableGroup::Properties
& props
);
206 * Dynamically set the properties associated with a given object
207 * group as the replication manager and replicas are being executed.
208 * These properties override the type-specific and default
211 virtual void set_properties_dynamically (
212 PortableGroup::ObjectGroup_ptr object_group
,
213 const PortableGroup::Properties
& overrides
);
216 * Return the properties currently in use by the given object
217 * group. These properties include those that were set dynamically,
218 * type-specific properties that weren't overridden, properties that
219 * were used when the Replica was created, and default properties
220 * that weren't overridden.
222 virtual PortableGroup::Properties
* get_properties (
223 PortableGroup::ObjectGroup_ptr object_group
);
228 * @name FT::FTObjectGroupManager methods
230 * Methods required by the FT::FTObjectGroupManager
234 /// Create a member in an object group.
235 virtual PortableGroup::ObjectGroup_ptr
create_member (
236 PortableGroup::ObjectGroup_ptr object_group
,
237 const PortableGroup::Location
& the_location
,
238 const char * type_id
,
239 const PortableGroup::Criteria
& the_criteria
);
241 /// Add an existing object to the ObjectGroup.
242 virtual PortableGroup::ObjectGroup_ptr
add_member (
243 PortableGroup::ObjectGroup_ptr object_group
,
244 const PortableGroup::Location
& the_location
,
245 CORBA::Object_ptr member
);
248 * Remove the member at a specific location from an
249 * ObjectGroup. Application created objects must be
250 * deleted by the application. Objects created by the
251 * infrastructure (replication manager) will be deleted by the
253 * For infrastructure-controlled membership: After the member
254 * is removed from the group the minumum number of members
255 * parameter will be checked and new members will be created
256 * as necessary (if possible.)
258 virtual PortableGroup::ObjectGroup_ptr
remove_member (
259 PortableGroup::ObjectGroup_ptr object_group
,
260 const PortableGroup::Location
& the_location
);
262 /// Return the locations of the members in the given ObjectGroup.
263 virtual PortableGroup::Locations
* locations_of_members (
264 PortableGroup::ObjectGroup_ptr object_group
);
266 /// Return the locations of the members in the given ObjectGroup.
267 virtual PortableGroup::ObjectGroups
* groups_at_location (
268 const PortableGroup::Location
& the_location
);
270 /// Return the ObjectGroupId for the given ObjectGroup.
271 virtual PortableGroup::ObjectGroupId
get_object_group_id (
272 PortableGroup::ObjectGroup_ptr object_group
);
275 * Return an update the IOGR for an object group. If no changes have
276 * been made in the group the return value will be the same as the object_group
279 virtual PortableGroup::ObjectGroup_ptr
get_object_group_ref (
280 PortableGroup::ObjectGroup_ptr object_group
);
283 * TAO-specific extension.
284 * Return the ObjectGroup reference for the given ObjectGroupId.
286 virtual PortableGroup::ObjectGroup_ptr
get_object_group_ref_from_id (
287 PortableGroup::ObjectGroupId group_id
);
290 * Return the reference corresponding to the Replica of a given
291 * ObjectGroup at the given location.
293 virtual CORBA::Object_ptr
get_member_ref (
294 PortableGroup::ObjectGroup_ptr object_group
,
295 const PortableGroup::Location
& loc
);
297 /// Sets the primary member of a group.
298 virtual PortableGroup::ObjectGroup_ptr
set_primary_member (
299 PortableGroup::ObjectGroup_ptr object_group
,
300 const PortableGroup::Location
& the_location
306 * @name PortableGroup::GenericFactory methods
308 * Methods required by the PortableGroup::GenericFactory interface.
312 * Create an object of the specified type that adheres to the
313 * restrictions defined by the provided Criteria. The out
314 * FactoryCreationId parameter may be passed to the delete_object()
315 * method to delete the object.
317 * Infrastructure controlled membership: The initial number of members
318 * property will be honored by creating new members and adding them to
321 virtual CORBA::Object_ptr
create_object (
322 const char * type_id
,
323 const PortableGroup::Criteria
& the_criteria
,
324 PortableGroup::GenericFactory::FactoryCreationId_out
325 factory_creation_id
);
328 * Delete the object group corresponding to the provided
329 * FactoryCreationId. For infratructure-controlled membership
330 * all members will be deleted. For application-controlled membership
331 * the application is responsible for deleting group members.
333 virtual void delete_object (
334 const PortableGroup::GenericFactory::FactoryCreationId
&
335 factory_creation_id
);
339 /////////////////////////
340 // Implementation methods
343 * Write this factory's IOR to a file
347 /// Registers the Fault Notifier with the Replication Manager.
348 void register_fault_notifier_i (
349 FT::FaultNotifier_ptr fault_notifier
354 FT_ReplicationManager (const FT_ReplicationManager
& rhs
);
355 FT_ReplicationManager
& operator = (const FT_ReplicationManager
& rhs
);
364 PortableServer::POA_var poa_
;
366 /// A file to which the factory's IOR should be written.
367 const ACE_TCHAR
* ior_output_file_
;
369 /// A name to be used to register the factory with the name service.
370 ACE_CString ns_name_
;
371 CosNaming::NamingContext_var naming_context_
;
372 CosNaming::Name this_name_
;
374 /// Our object reference.
375 FT::ReplicationManager_var replication_manager_ref_
;
377 /// A human-readable string to identify this Replication Manager.
378 ACE_CString identity_
;
380 /// an object that manages a collection of object groups
381 TAO::PG_Group_Factory group_factory_
;
383 /// an object that manages default and type_id related properties
384 TAO::PG_Properties_Support properties_support_
;
386 /// The fault notifier.
387 FT::FaultNotifier_var fault_notifier_
;
388 /// set by command line -f option
389 const ACE_TCHAR
* fault_notifier_ior_string_
;
391 /// The fault consumer.
392 TAO::FT_FaultConsumer fault_consumer_
;
394 /// The factory registry
395 TAO::PG_FactoryRegistry factory_registry_
;
402 TAO_END_VERSIONED_NAMESPACE_DECL
404 #include /**/ "ace/post.h"
406 #endif /* FT_REPLICATION_MANAGER_H_ */