]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/StoreIoAction.cc
Merged from trunk
[thirdparty/squid.git] / src / mgr / StoreIoAction.cc
1 /*
2 * DEBUG: section 16 Cache Manager API
3 *
4 */
5
6 #include "squid.h"
7 #include "base/TextException.h"
8 #include "ipc/Messages.h"
9 #include "ipc/TypedMsgHdr.h"
10 #include "mgr/StoreIoAction.h"
11 #include "Store.h"
12 #include "tools.h"
13
14 Mgr::StoreIoActionData::StoreIoActionData()
15 {
16 xmemset(this, 0, sizeof(*this));
17 }
18
19 Mgr::StoreIoActionData&
20 Mgr::StoreIoActionData::operator += (const StoreIoActionData& stats)
21 {
22 create_calls += stats.create_calls;
23 create_select_fail += stats.create_select_fail;
24 create_create_fail += stats.create_create_fail;
25 create_success += stats.create_success;
26
27 return *this;
28 }
29
30 Mgr::StoreIoAction::Pointer
31 Mgr::StoreIoAction::Create(const CommandPointer &cmd)
32 {
33 return new StoreIoAction(cmd);
34 }
35
36 Mgr::StoreIoAction::StoreIoAction(const CommandPointer &cmd):
37 Action(cmd), data()
38 {
39 debugs(16, 5, HERE);
40 }
41
42 void
43 Mgr::StoreIoAction::add(const Action& action)
44 {
45 debugs(16, 5, HERE);
46 data += dynamic_cast<const StoreIoAction&>(action).data;
47 }
48
49 void
50 Mgr::StoreIoAction::collect()
51 {
52 data.create_calls = store_io_stats.create.calls;
53 data.create_select_fail = store_io_stats.create.select_fail;
54 data.create_create_fail = store_io_stats.create.create_fail;
55 data.create_success = store_io_stats.create.success;
56 }
57
58 void
59 Mgr::StoreIoAction::dump(StoreEntry* entry)
60 {
61 debugs(16, 5, HERE);
62 Must(entry != NULL);
63 storeAppendPrintf(entry, "Store IO Interface Stats\n");
64 storeAppendPrintf(entry, "create.calls %.0f\n", data.create_calls);
65 storeAppendPrintf(entry, "create.select_fail %.0f\n", data.create_select_fail);
66 storeAppendPrintf(entry, "create.create_fail %.0f\n", data.create_create_fail);
67 storeAppendPrintf(entry, "create.success %.0f\n", data.create_success);
68 }
69
70 void
71 Mgr::StoreIoAction::pack(Ipc::TypedMsgHdr& msg) const
72 {
73 msg.setType(Ipc::mtCacheMgrResponse);
74 msg.putPod(data);
75 }
76
77 void
78 Mgr::StoreIoAction::unpack(const Ipc::TypedMsgHdr& msg)
79 {
80 msg.checkType(Ipc::mtCacheMgrResponse);
81 msg.getPod(data);
82 }