2 #ifndef IMR_LOCATOR_I_H
3 #define IMR_LOCATOR_I_H
4 #include /**/ "ace/pre.h"
6 #include "locator_export.h"
8 #include "Adapter_Activator.h"
9 #include "Activator_Info.h"
10 #include "Forwarder.h"
11 #include "LiveCheck.h"
12 #include "ImR_ResponseHandler.h"
13 #include "Locator_Options.h"
14 #include "UpdateableServerInfo.h"
16 #include "AsyncAccessManager.h"
17 #include "tao/IORTable/IORTable.h"
19 #include "ImR_LocatorS.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 ACE_END_VERSIONED_NAMESPACE_DECL
31 /// Gets a request from a client and depending on the POA name,
32 /// requests an activator to take care of activating the
33 /// corresponding server and raises a forward exception to the
34 /// client pointing to the correct server.
35 class Locator_Export ImR_Locator_i
:
36 public virtual POA_ImplementationRepository::AMH_Locator
43 /// Initialize the service, creating its own orb, poa, etc.
44 int init (Options
& opts
);
46 /// Same as above, but use the given orb
47 int init_with_orb (CORBA::ORB_ptr orb
); //, Options& opts);
49 /// Cleans up any state created by init*.
52 /// Run using the orb reference created during init()
55 /// Called by the signal handler to notify of shutdown request
56 void signal_shutdown ();
59 void shutdown (bool wait_for_completion
);
61 /// Access the options
62 const Options
*opts () const;
65 // Note : See the IDL for descriptions of the operations.
69 virtual void register_activator
70 (ImplementationRepository::AMH_LocatorResponseHandler_ptr _tao_rh
,
72 ImplementationRepository::Activator_ptr admin
);
74 virtual void unregister_activator
75 (ImplementationRepository::AMH_LocatorResponseHandler_ptr _tao_rh
,
79 virtual void child_death_pid
80 (ImplementationRepository::AMH_LocatorResponseHandler_ptr _tao_rh
,
81 const char* name
, CORBA::Long pid
);
83 virtual void spawn_pid
84 (ImplementationRepository::AMH_LocatorResponseHandler_ptr _tao_rh
,
85 const char* name
, CORBA::Long pid
);
89 virtual void activate_server
90 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
93 virtual void add_or_update_server
94 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
96 const ImplementationRepository::StartupOptions
&options
);
98 virtual void link_servers
99 (ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh
,
101 const CORBA::StringSeq
& peers
);
103 virtual void kill_server
104 (ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh
,
106 CORBA::Short signum
);
108 virtual void remove_server
109 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
112 virtual void shutdown_server
113 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
116 virtual void force_remove_server
117 (ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh
,
119 CORBA::Short signum
);
122 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
126 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
127 CORBA::ULong how_many
,
128 CORBA::Boolean determine_active_status
);
130 virtual void shutdown
131 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
132 CORBA::Boolean activators
,
133 CORBA::Boolean servers
);
137 virtual void server_is_running
138 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
140 const char* partial_ior
,
141 ImplementationRepository::ServerObject_ptr server_object
);
143 virtual void server_is_shutting_down
144 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh
,
147 // Used by the INS_Locator to start a sever given an object name synchronously
148 char* activate_server_by_object (const char* object_name
);
149 char* activate_server_by_name (const char * name
, bool manual_start
);
151 // Asynchronous versions, used by both INS_Locator and Forwarder
152 void activate_server_by_info (const Server_Info_Ptr
&si
,
153 ImR_ResponseHandler
*rh
);
155 void activate_server_by_name (const char * name
,
157 ImR_ResponseHandler
*rh
);
159 bool split_key (ACE_CString
&full
, ACE_CString
&key
, Server_Info_Ptr
&si
);
161 // interfaces to aid with collaboration
163 LiveCheck
&pinger ();
164 PortableServer::POA_ptr
root_poa ();
165 Activator_Info_Ptr
get_activator (const ACE_CString
& name
);
167 void remove_server_i (const Server_Info_Ptr
&si
);
168 void destroy_poa (const ACE_CString
&poa_name
);
169 void remove_aam (AsyncAccessManager_ptr
&aam
);
170 void remove_aam (const char *name
);
171 AsyncAccessManager
*find_aam (const char *name
, bool active
= true);
172 AsyncAccessManager
*find_not_running_aam (const char *name
, bool active
= true);
173 AsyncAccessManager
*create_aam (UpdateableServerInfo
&info
, bool running
= false);
174 void make_terminating (AsyncAccessManager_ptr
&aam
, const char *name
, int pid
);
175 /// Receiving an update from remote peer
176 void remote_access_update (const char *name
,
177 ImplementationRepository::AAM_Status state
);
179 CORBA::Object_ptr
set_timeout_policy(CORBA::Object_ptr obj
,
180 const ACE_Time_Value
& to
);
183 bool get_info_for_name (const char *name
, Server_Info_Ptr
&si
);
185 void activate_server_i (UpdateableServerInfo
& info
,
187 ImR_ResponseHandler
*rh
);
189 bool server_is_alive (UpdateableServerInfo
& info
);
191 void unregister_activator_i (const char* activator
);
193 void connect_activator (Activator_Info
& info
);
195 void auto_start_servers ();
197 void connect_server (UpdateableServerInfo
& info
);
199 PortableServer::POA_ptr
findPOA (const char* name
);
201 void child_death_i (const char* name
, int pid
);
203 void remove_aam_i (const char *name
, bool active
);
205 bool kill_server_i (const Server_Info_Ptr
&si
,
207 CORBA::Exception
*&ex
);
209 bool shutdown_server_i (const Server_Info_Ptr
&si
,
210 CORBA::Exception
*&ex
,
216 // The class that handles the forwarding.
217 ImR_DSI_Forwarder dsi_forwarder_
;
219 // Used for the forwarding of any type of POA.
220 ImR_Adapter adapter_
;
222 /// The locator interface for the IORTable
223 IORTable::Locator_var ins_locator_
;
225 /// The asynch server ping adapter
228 /// A collection of asynch activator instances
229 typedef ACE_Unbounded_Set
<AsyncAccessManager_ptr
> AAM_Set
;
231 AAM_Set aam_terminating_
;
234 PortableServer::POA_var root_poa_
;
235 PortableServer::POA_var imr_poa_
;
237 Repository_Ptr repository_
;
241 TAO_SYNCH_MUTEX lock_
;
243 class Shutdown_Handler
: public ACE_Event_Handler
246 ImR_Locator_i
*owner_
;
247 Shutdown_Handler (ImR_Locator_i
*owner
) : owner_ (owner
) {}
248 int handle_exception (ACE_HANDLE
);
252 //----------------------------------------------------------------------------
254 class SyncListener
: public LiveListener
257 SyncListener (const char *server
, CORBA::ORB_ptr orb
, LiveCheck
&pinger
);
259 virtual ~SyncListener ();
263 bool status_changed (LiveStatus status
);
273 //----------------------------------------------------------------------------
275 * @class ImR_Loc_ResponseHandler
277 * @brief specialized reply handler for Locator interface calls which have a
280 class ImR_SyncResponseHandler
: public ImR_ResponseHandler
283 ImR_SyncResponseHandler (const char *key
, CORBA::ORB_ptr orb
);
284 virtual ~ImR_SyncResponseHandler ();
286 virtual void send_ior (const char *pior
);
287 virtual void send_exception (CORBA::Exception
*ex
);
289 char *wait_for_result ();
292 CORBA::String_var result_
;
293 CORBA::Exception
*excep_
;
298 //----------------------------------------------------------------------------
300 * @class ImR_Loc_ResponseHandler
302 * @brief specialized reply handler for Locator interface calls which have a
305 class ImR_Loc_ResponseHandler
: public ImR_ResponseHandler
308 enum Loc_Operation_Id
311 LOC_ADD_OR_UPDATE_SERVER
,
312 LOC_FORCE_REMOVE_SERVER
,
315 LOC_SERVER_IS_RUNNING
,
316 LOC_SERVER_IS_SHUTTING_DOWN
319 ImR_Loc_ResponseHandler (Loc_Operation_Id opid
,
320 ImplementationRepository::AMH_AdministrationResponseHandler_ptr rh
);
321 ImR_Loc_ResponseHandler (Loc_Operation_Id opid
,
322 ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr rh
);
323 virtual ~ImR_Loc_ResponseHandler ();
325 virtual void send_ior (const char *pior
);
326 virtual void send_exception (CORBA::Exception
*ex
);
329 void send_ior_ext (const char *pior
);
330 void send_exception_ext (CORBA::Exception
*ex
);
332 Loc_Operation_Id op_id_
;
333 ImplementationRepository::AMH_AdministrationResponseHandler_var resp_
;
334 ImplementationRepository::AMH_AdministrationExtResponseHandler_var ext_
;
337 #include /**/ "ace/post.h"
338 #endif /* IMR_LOCATOR_I_H */