Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / ImR_Locator_i.h
blobc64bfc6cc978be320c911398813fb2cef308a23b
1 // -*- C++ -*-
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"
15 #include <memory>
16 #include "AsyncAccessManager.h"
17 #include "tao/IORTable/IORTable.h"
19 #include "ImR_LocatorS.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 class ACE_Reactor;
27 ACE_END_VERSIONED_NAMESPACE_DECL
29 class INS_Locator;
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
38 public:
39 ImR_Locator_i();
41 ~ImR_Locator_i ();
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*.
50 int fini ();
52 /// Run using the orb reference created during init()
53 int run ();
55 /// Called by the signal handler to notify of shutdown request
56 void signal_shutdown ();
58 /// Shutdown the orb.
59 void shutdown (bool wait_for_completion);
61 /// Access the options
62 const Options *opts () const;
64 static int debug ();
65 // Note : See the IDL for descriptions of the operations.
67 // Activator->Locator
69 virtual void register_activator
70 (ImplementationRepository::AMH_LocatorResponseHandler_ptr _tao_rh,
71 const char* name,
72 ImplementationRepository::Activator_ptr admin);
74 virtual void unregister_activator
75 (ImplementationRepository::AMH_LocatorResponseHandler_ptr _tao_rh,
76 const char* name,
77 CORBA::Long token);
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);
87 // tao_imr->Locator
89 virtual void activate_server
90 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
91 const char * name);
93 virtual void add_or_update_server
94 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
95 const char * name,
96 const ImplementationRepository::StartupOptions &options);
98 virtual void link_servers
99 (ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh,
100 const char * name,
101 const CORBA::StringSeq & peers);
103 virtual void kill_server
104 (ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh,
105 const char * name,
106 CORBA::Short signum);
108 virtual void remove_server
109 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
110 const char * name);
112 virtual void shutdown_server
113 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
114 const char * name);
116 virtual void force_remove_server
117 (ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh,
118 const char * name,
119 CORBA::Short signum);
121 virtual void find
122 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
123 const char * name);
125 virtual void list
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);
135 // Server->Locator
137 virtual void server_is_running
138 (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
139 const char* name,
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,
145 const char * name);
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,
156 bool manual_start,
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);
182 private:
183 bool get_info_for_name (const char *name, Server_Info_Ptr &si);
185 void activate_server_i (UpdateableServerInfo& info,
186 bool manual_start,
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,
206 CORBA::Short signum,
207 CORBA::Exception *&ex);
209 bool shutdown_server_i (const Server_Info_Ptr &si,
210 CORBA::Exception *&ex,
211 bool force);
213 private:
214 static int debug_;
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
226 LiveCheck pinger_;
228 /// A collection of asynch activator instances
229 typedef ACE_Unbounded_Set<AsyncAccessManager_ptr> AAM_Set;
230 AAM_Set aam_active_;
231 AAM_Set aam_terminating_;
233 CORBA::ORB_var orb_;
234 PortableServer::POA_var root_poa_;
235 PortableServer::POA_var imr_poa_;
237 Repository_Ptr repository_;
239 Options *opts_;
241 TAO_SYNCH_MUTEX lock_;
243 class Shutdown_Handler : public ACE_Event_Handler
245 public :
246 ImR_Locator_i *owner_;
247 Shutdown_Handler (ImR_Locator_i *owner) : owner_ (owner) {}
248 int handle_exception (ACE_HANDLE);
249 } shutdown_handler_;
252 //----------------------------------------------------------------------------
254 class SyncListener : public LiveListener
256 public:
257 SyncListener (const char *server, CORBA::ORB_ptr orb, LiveCheck &pinger);
259 virtual ~SyncListener ();
261 bool is_alive ();
263 bool status_changed (LiveStatus status);
265 private:
266 CORBA::ORB_var orb_;
267 LiveCheck &pinger_;
268 LiveStatus status_;
269 bool got_it_;
270 bool callback_;
273 //----------------------------------------------------------------------------
275 * @class ImR_Loc_ResponseHandler
277 * @brief specialized reply handler for Locator interface calls which have a
278 * void return.
280 class ImR_SyncResponseHandler : public ImR_ResponseHandler
282 public:
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 ();
291 private:
292 CORBA::String_var result_;
293 CORBA::Exception *excep_;
294 ACE_CString key_;
295 CORBA::ORB_var orb_;
298 //----------------------------------------------------------------------------
300 * @class ImR_Loc_ResponseHandler
302 * @brief specialized reply handler for Locator interface calls which have a
303 * void return.
305 class ImR_Loc_ResponseHandler : public ImR_ResponseHandler
307 public:
308 enum Loc_Operation_Id
310 LOC_ACTIVATE_SERVER,
311 LOC_ADD_OR_UPDATE_SERVER,
312 LOC_FORCE_REMOVE_SERVER,
313 LOC_REMOVE_SERVER,
314 LOC_SHUTDOWN_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);
328 private:
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 */