]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/StoreIoAction.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / StoreIoAction.cc
CommitLineData
8822ebee 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
8822ebee 3 *
bbc27441
AJ
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
8822ebee
AR
7 */
8
bbc27441
AJ
9/* DEBUG: section 16 Cache Manager API */
10
f7f3304a 11#include "squid.h"
8822ebee
AR
12#include "base/TextException.h"
13#include "ipc/Messages.h"
14#include "ipc/TypedMsgHdr.h"
15#include "mgr/StoreIoAction.h"
16#include "Store.h"
5bed43d6 17#include "tools.h"
8822ebee 18
8822ebee
AR
19Mgr::StoreIoActionData::StoreIoActionData()
20{
e297be13 21 memset(this, 0, sizeof(*this));
8822ebee
AR
22}
23
24Mgr::StoreIoActionData&
25Mgr::StoreIoActionData::operator += (const StoreIoActionData& stats)
26{
27 create_calls += stats.create_calls;
28 create_select_fail += stats.create_select_fail;
29 create_create_fail += stats.create_create_fail;
30 create_success += stats.create_success;
31
32 return *this;
33}
34
35Mgr::StoreIoAction::Pointer
36Mgr::StoreIoAction::Create(const CommandPointer &cmd)
37{
38 return new StoreIoAction(cmd);
39}
40
9dca980d 41Mgr::StoreIoAction::StoreIoAction(const CommandPointer &aCmd):
f53969cc 42 Action(aCmd), data()
8822ebee
AR
43{
44 debugs(16, 5, HERE);
45}
46
47void
48Mgr::StoreIoAction::add(const Action& action)
49{
50 debugs(16, 5, HERE);
51 data += dynamic_cast<const StoreIoAction&>(action).data;
52}
53
54void
55Mgr::StoreIoAction::collect()
56{
57 data.create_calls = store_io_stats.create.calls;
58 data.create_select_fail = store_io_stats.create.select_fail;
59 data.create_create_fail = store_io_stats.create.create_fail;
60 data.create_success = store_io_stats.create.success;
61}
62
63void
64Mgr::StoreIoAction::dump(StoreEntry* entry)
65{
66 debugs(16, 5, HERE);
67 Must(entry != NULL);
68 storeAppendPrintf(entry, "Store IO Interface Stats\n");
69 storeAppendPrintf(entry, "create.calls %.0f\n", data.create_calls);
70 storeAppendPrintf(entry, "create.select_fail %.0f\n", data.create_select_fail);
71 storeAppendPrintf(entry, "create.create_fail %.0f\n", data.create_create_fail);
72 storeAppendPrintf(entry, "create.success %.0f\n", data.create_success);
73}
74
75void
76Mgr::StoreIoAction::pack(Ipc::TypedMsgHdr& msg) const
77{
78 msg.setType(Ipc::mtCacheMgrResponse);
79 msg.putPod(data);
80}
81
82void
83Mgr::StoreIoAction::unpack(const Ipc::TypedMsgHdr& msg)
84{
85 msg.checkType(Ipc::mtCacheMgrResponse);
86 msg.getPod(data);
87}
f53969cc 88