]>
Commit | Line | Data |
---|---|---|
8822ebee AR |
1 | /* |
2 | * $Id$ | |
3 | * | |
4 | * DEBUG: section 16 Cache Manager API | |
5 | * | |
6 | */ | |
7 | ||
8 | #ifndef SQUID_MGR_INQUIRER_H | |
9 | #define SQUID_MGR_INQUIRER_H | |
10 | ||
11 | #include "base/AsyncJobCalls.h" | |
12 | #include "base/AsyncJob.h" | |
13 | #include "ipc/StrandCoords.h" | |
14 | #include "MemBuf.h" | |
15 | #include "mgr/Action.h" | |
16 | #include "mgr/Request.h" | |
17 | #include <map> | |
18 | ||
19 | class CommIoCbParams; | |
20 | class CommCloseCbParams; | |
21 | ||
22 | namespace Mgr | |
23 | { | |
24 | ||
25 | /// Coordinator's job that sends a cache manage request to each strand, | |
26 | /// aggregating individual strand responses and dumping the result if needed | |
27 | class Inquirer: public AsyncJob | |
28 | { | |
29 | public: | |
30 | Inquirer(Action::Pointer anAction, int aFd, const Request &aCause, | |
31 | const Ipc::StrandCoords &coords); | |
32 | virtual ~Inquirer(); | |
33 | ||
34 | /// finds and calls the right Inquirer upon strand's response | |
35 | static void HandleRemoteAck(const Mgr::Response& response); | |
36 | ||
37 | protected: | |
38 | /* AsyncJob API */ | |
39 | virtual void start(); | |
40 | virtual void swanSong(); | |
41 | virtual bool doneAll() const; | |
42 | virtual const char *status() const; | |
43 | ||
44 | private: | |
45 | typedef UnaryMemFunT<Inquirer, Response, const Response&> HandleAckDialer; | |
46 | ||
47 | void inquire(); | |
48 | void noteWroteHeader(const CommIoCbParams& params); | |
49 | void noteCommClosed(const CommCloseCbParams& params); | |
50 | ||
51 | void handleRemoteAck(const Response& response); | |
52 | ||
53 | static AsyncCall::Pointer DequeueRequest(unsigned int requestId); | |
54 | ||
55 | static void RequestTimedOut(void* param); | |
56 | void requestTimedOut(); | |
57 | void removeTimeoutEvent(); | |
58 | ||
59 | void close(); | |
60 | void removeCloseHandler(); | |
61 | ||
62 | private: | |
63 | Action::Pointer aggrAction; //< action to aggregate | |
64 | ||
65 | Request cause; ///< cache manager request received from HTTP client | |
66 | int fd; ///< HTTP client socket descriptor | |
67 | ||
68 | Ipc::StrandCoords strands; ///< all strands we want to query, in order | |
69 | Ipc::StrandCoords::const_iterator pos; ///< strand we should query now | |
70 | ||
71 | unsigned int requestId; ///< ID of our outstanding request to strand | |
72 | AsyncCall::Pointer writer; ///< comm_write callback | |
73 | AsyncCall::Pointer closer; ///< comm_close handler | |
74 | const double timeout; ///< number of seconds to wait for strand response | |
75 | ||
76 | /// maps requestId to Inquirer::handleRemoteAck callback | |
77 | typedef std::map<unsigned int, AsyncCall::Pointer> RequestsMap; | |
78 | static RequestsMap TheRequestsMap; ///< pending strand requests | |
79 | ||
80 | static unsigned int LastRequestId; ///< last requestId used | |
81 | ||
82 | CBDATA_CLASS2(Inquirer); | |
83 | }; | |
84 | ||
85 | } // namespace Mgr | |
86 | ||
87 | #endif /* SQUID_MGR_INQUIRER_H */ |