Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Replicator.h
blobe5384dd4dc444e9430eb4d96c0958dde307b32f4
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Replicator.h
7 * This class manages the synchronizing of XML files and server status
8 * shared between multiple Locators.
11 //=============================================================================
13 #ifndef REPLICATOR_H
14 #define REPLICATOR_H
16 #include "ace/config-lite.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ImR_LocatorS.h"
23 #include "ace/Bound_Ptr.h"
24 #include "ace/Vector_T.h"
25 #include "ace/Task.h"
27 #include <set>
29 class Replicator;
30 class Shared_Backing_Store;
31 class Options;
33 class UPN_i : public virtual POA_ImplementationRepository::UpdatePushNotification
35 public:
36 UPN_i (Replicator &owner);
38 /// provide the implementation for being notified of a
39 /// server or activator update
40 virtual void notify_update (CORBA::ULongLong seq_num,
41 const ImplementationRepository::UpdateInfoSeq& info);
43 /// provide the implementation for registering a peer replica
44 /// @param replica the peer replica
45 /// @param ft_imr_ior the fault tolerant ImR IOR (passed in
46 /// as the replica's ImR IOR, passed back as fault
47 /// tolerant ImR IOR)
48 /// @param seq_num current sequence number to return to replica
49 virtual void register_replica
50 (ImplementationRepository::UpdatePushNotification_ptr replica,
51 char*& ft_imr_ior,
52 CORBA::ULongLong_out seq_num);
54 private:
55 Replicator &owner_;
58 /**
59 * @class Replicator
61 * @brief XML backing store containing all ImR persistent information in
62 * multiple files shared between multiple Locators
65 class Replicator : public ACE_Task_Base
67 public:
68 friend class UPN_i;
70 typedef ImplementationRepository::UpdatePushNotification_var Replica_var;
71 typedef ImplementationRepository::UpdatePushNotification_ptr Replica_ptr;
72 typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
73 ImplementationRepository::AAM_Status,
74 ACE_Hash<ACE_CString>,
75 ACE_Equal_To<ACE_CString>,
76 ACE_Null_Mutex> AAM_StatusMap;
78 Replicator (Shared_Backing_Store &repo, const Options& opts);
80 virtual ~Replicator(void);
82 virtual int svc (void);
83 virtual int handle_exception (ACE_HANDLE );
85 void stop (void);
86 void send_access_state (const char *name, ImplementationRepository::AAM_Status state);
87 void send_entity (ImplementationRepository::UpdateInfo &info);
89 void init_orb (void);
91 bool init_peer (const ACE_CString &filename );
92 int send_registration (char *&ior );
94 bool peer_available (void);
95 char * ior (void);
97 private:
98 Replica_var me_;
99 Replica_var peer_;
100 CORBA::ULongLong seq_num_;
101 CORBA::ULongLong replica_seq_num_;
102 Shared_Backing_Store &repo_;
103 AAM_StatusMap prev_update_;
104 CORBA::ORB_var orb_;
105 ACE_Reactor *reactor_;
106 TAO_SYNCH_MUTEX lock_;
107 bool notified_;
108 ImplementationRepository::UpdateInfoSeq to_send_;
109 int debug_;
110 ACE_CString endpoint_;
111 ACE_Time_Value update_delay_;
114 #endif /* REPLICATOR_H */