4 * DEBUG: section 16 Cache Manager API
8 #ifndef SQUID_MGR_INQUIRER_H
9 #define SQUID_MGR_INQUIRER_H
11 #include "base/AsyncJobCalls.h"
12 #include "base/AsyncJob.h"
13 #include "ipc/StrandCoords.h"
15 #include "mgr/Action.h"
16 #include "mgr/Request.h"
20 class CommCloseCbParams
;
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
30 Inquirer(Action::Pointer anAction
, int aFd
, const Request
&aCause
,
31 const Ipc::StrandCoords
&coords
);
34 /// finds and calls the right Inquirer upon strand's response
35 static void HandleRemoteAck(const Mgr::Response
& response
);
40 virtual void swanSong();
41 virtual bool doneAll() const;
42 virtual const char *status() const;
45 typedef UnaryMemFunT
<Inquirer
, Response
, const Response
&> HandleAckDialer
;
48 void noteWroteHeader(const CommIoCbParams
& params
);
49 void noteCommClosed(const CommCloseCbParams
& params
);
51 void handleRemoteAck(const Response
& response
);
53 static AsyncCall::Pointer
DequeueRequest(unsigned int requestId
);
55 static void RequestTimedOut(void* param
);
56 void requestTimedOut();
57 void removeTimeoutEvent();
60 void removeCloseHandler();
61 Ipc::StrandCoords
applyQueryParams(const Ipc::StrandCoords
& aStrands
,
62 const QueryParams
& aParams
);
65 Action::Pointer aggrAction
; //< action to aggregate
67 Request cause
; ///< cache manager request received from HTTP client
68 int fd
; ///< HTTP client socket descriptor
70 Ipc::StrandCoords strands
; ///< all strands we want to query, in order
71 Ipc::StrandCoords::const_iterator pos
; ///< strand we should query now
73 unsigned int requestId
; ///< ID of our outstanding request to strand
74 AsyncCall::Pointer writer
; ///< comm_write callback
75 AsyncCall::Pointer closer
; ///< comm_close handler
76 const double timeout
; ///< number of seconds to wait for strand response
78 /// maps requestId to Inquirer::handleRemoteAck callback
79 typedef std::map
<unsigned int, AsyncCall::Pointer
> RequestsMap
;
80 static RequestsMap TheRequestsMap
; ///< pending strand requests
82 static unsigned int LastRequestId
; ///< last requestId used
84 CBDATA_CLASS2(Inquirer
);
89 #endif /* SQUID_MGR_INQUIRER_H */