]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/Action.h
SMP Cache Manager, Phase2 implementation.
[thirdparty/squid.git] / src / mgr / Action.h
CommitLineData
8822ebee
AR
1/*
2 * $Id$
3 *
4 * DEBUG: section 16 Cache Manager API
5 *
6 */
7
8#ifndef SQUID_MGR_ACTION_H
9#define SQUID_MGR_ACTION_H
10
11#include "ipc/forward.h"
12#include "mgr/forward.h"
13
14class StoreEntry;
15
16namespace Mgr
17{
18
19/// Base API for organizing the processing of a compiled cache manager command.
20/// Not a job because all methods are synchronous (but they may start jobs).
21class Action: public RefCountable
22{
23public:
24 typedef RefCount<Action> Pointer;
25
26public:
27 Action(const CommandPointer &aCmd);
28 virtual ~Action();
29
30
31 /* for local Cache Manager use */
32
33 /// collect + fillEntry: collect local information and fill the store entry
34 void run(StoreEntry *entry, bool writeHttpHeader);
35
36 /// prepare store entry, dump info, close store entry (if possible)
37 void fillEntry(StoreEntry *entry, bool writeHttpHeader);
38
39
40 /* for global Coordinator use */
41
42 /// incrementally merge in remote information (of the same action type)
43 virtual void add(const Action &action);
44
45
46 /* global-local communication */
47
48 /// respond to Coordinator request; default is to collect and sendResponse
49 virtual void respond(const Request &request);
50
51 /// pack collected action info into a message to be sent to Coordinator
52 virtual void pack(Ipc::TypedMsgHdr &msg) const {}
53 /// unpack action info from the message received by Coordinator
54 virtual void unpack(const Ipc::TypedMsgHdr &msg) {}
55
56 /// notify Coordinator that this action is done with local processing
57 void sendResponse(unsigned int requestId);
58
59
60 /* Action properties */
61
62 /// whether at least some local kid info can be combined and, hence, the
63 /// combined data should be written at the end of the coordinated response
64 virtual bool aggregatable() const { return true; } // most kid classes are
65
66 bool atomic() const; ///< dump() call writes everything before returning
67 const char *name() const; ///< label as seen in the cache manager menu
68 const Command &command() const; ///< the cause of this action
69
70 StoreEntry *createStoreEntry() const; ///< creates store entry from params
71
72protected:
73 /// calculate and keep local action-specific information
74 virtual void collect() {}
75
76 /** start writing action-specific info to Store entry;
77 * may collect info during dump, especially if collect() did nothing
78 * non-atomic() actions may continue writing asynchronously after returning
79 */
80 virtual void dump(StoreEntry *entry) {}
81
82
83private:
84 const CommandPointer cmd; ///< the command that caused this action
85
86
87private:
88 Action(const Action &); // not implemented
89 Action &operator= (const Action &); // not implemented
90};
91
92} // namespace Mgr
93
94#endif /* SQUID_MGR_ACTION_H */