]>
git.proxmox.com Git - ceph.git/blob - ceph/src/osd/PGStateUtils.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "PGStateUtils.h"
5 #include "common/Clock.h"
7 /*------NamedState----*/
8 NamedState::NamedState(PGStateHistory
*pgsh
, const char *state_name
)
9 : pgsh(pgsh
), state_name(state_name
), enter_time(ceph_clock_now()) {
11 pgsh
->enter(enter_time
, state_name
);
15 NamedState::~NamedState() {
17 pgsh
->exit(state_name
);
21 /*---------PGStateHistory---------*/
22 void PGStateHistory::enter(const utime_t entime
, const char* state
)
25 pi
= std::make_unique
<PGStateInstance
>();
27 pi
->enter_state(entime
, state
);
30 void PGStateHistory::exit(const char* state
) {
31 pi
->setepoch(es
.get_osdmap_epoch());
32 pi
->exit_state(ceph_clock_now());
38 void PGStateHistory::dump(Formatter
* f
) const {
39 f
->open_array_section("history");
40 for (auto pi
= buffer
.begin(); pi
!= buffer
.end(); ++pi
) {
41 f
->open_object_section("epochs");
42 f
->dump_stream("epoch") << (*pi
)->this_epoch
;
43 f
->open_array_section("states");
44 for (auto she
: (*pi
)->state_history
) {
45 f
->open_object_section("state");
46 f
->dump_string("state", std::get
<2>(she
));
47 f
->dump_stream("enter") << std::get
<0>(she
);
48 f
->dump_stream("exit") << std::get
<1>(she
);