Update Constraint_Nodes.cpp
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / AsyncListManager.h
blob4879ac15547eef7df68f96a9a524e0281402f083
1 // -*- C++ -*-
2 /*
3 * @file AsyncListManager.h
5 * @author Phil Mesnier <mesnier_p@ociweb.com>
6 */
8 #ifndef IMR_ASYNCLISTMANAGER_H_
9 #define IMR_ASYNCLISTMANAGER_H_
11 #include "locator_export.h"
13 #include "ImR_LocatorC.h"
14 #include "ace/Vector_T.h"
15 #include "ace/SString.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 #pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "tao/Intrusive_Ref_Count_Handle_T.h"
22 #include <atomic>
23 #include "LiveCheck.h"
25 class Locator_Repository;
27 //----------------------------------------------------------------------------
29 * @class AsyncListManager
31 * @brief manages active detection of multiple servers to satisfy "list -a"
33 * A client of the locator may issue a list command to be filtered to
34 * currently active servers only. To satisfy that request each server must
35 * be pinged to determine liveness. The AsyncListManager handles the
36 * callbacks for all of the ping requests as efficiently as possible.
39 class AsyncListManager
41 public:
42 AsyncListManager (const Locator_Repository *repo,
43 PortableServer::POA_ptr poa,
44 LiveCheck *pinger);
46 ~AsyncListManager ();
48 PortableServer::POA_ptr poa ();
49 void list (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
50 CORBA::ULong count);
52 CORBA::ULong list (ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_ptr _tao_rh,
53 CORBA::ULong start, CORBA::ULong count);
55 bool evaluate_status (CORBA::ULong index, LiveStatus status, int pid);
56 void ping_replied (CORBA::ULong index, LiveStatus status, int pid);
58 AsyncListManager *_add_ref ();
59 void _remove_ref ();
61 private:
62 void init_list ();
63 void list_i (CORBA::ULong start, CORBA::ULong count);
64 bool make_iterator (ImplementationRepository::ServerInformationIterator_out si,
65 CORBA::ULong start);
66 void final_state ();
68 const Locator_Repository *repo_;
69 PortableServer::POA_var poa_;
70 ImplementationRepository::AMH_AdministrationResponseHandler_var primary_;
71 ImplementationRepository::AMH_ServerInformationIteratorResponseHandler_var secondary_;
72 LiveCheck *pinger_;
73 ImplementationRepository::ServerInformationList server_list_;
74 CORBA::ULong first_;
75 CORBA::ULong how_many_;
76 CORBA::ULong waiters_;
77 std::atomic<int> refcount_;
80 typedef TAO_Intrusive_Ref_Count_Handle<AsyncListManager> AsyncListManager_ptr;
82 //----------------------------------------------------------------------------
84 class ListLiveListener : public LiveListener
86 public:
87 ListLiveListener (const char * server,
88 int pid,
89 CORBA::ULong index,
90 AsyncListManager *owner,
91 LiveCheck &pinger);
93 virtual ~ListLiveListener ();
94 bool start ();
95 void cancel ();
96 LiveStatus status ();
97 bool status_changed (LiveStatus status);
99 private:
100 AsyncListManager_ptr owner_;
101 LiveCheck &pinger_;
102 LiveStatus status_;
103 CORBA::ULong index_;
104 bool started_;
105 int pid_;
108 #endif /* IMR_ASYNCACCESSMANGER_H_ */