Skip to content

Commit

Permalink
common: get ride of OpHistory::dump_ops_by_duration
Browse files Browse the repository at this point in the history
Signed-off-by: Chang Liu <[email protected]>
  • Loading branch information
liuchang0812 committed Mar 29, 2018
1 parent 3272b68 commit 01ff39d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 36 deletions.
49 changes: 15 additions & 34 deletions src/common/TrackedOp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void OpHistory::cleanup(utime_t now)
}
}

void OpHistory::dump_ops(utime_t now, Formatter *f, set<string> filters)
void OpHistory::dump_ops(utime_t now, Formatter *f, set<string> filters, bool by_duration)
{
Mutex::Locker history_lock(ops_history_lock);
cleanup(now);
Expand All @@ -117,35 +117,20 @@ void OpHistory::dump_ops(utime_t now, Formatter *f, set<string> filters)
f->dump_int("duration", history_duration);
{
f->open_array_section("ops");
for (auto i = arrived.begin();
i != arrived.end();
++i) {
if (!i->second->filter_out(filters))
continue;
f->open_object_section("op");
i->second->dump(now, f);
f->close_section();
}
f->close_section();
}
f->close_section();
}
auto dump_fn = [&f, &now, &filters](auto begin_iter, auto end_iter) {
for (auto i=begin_iter; i!=end_iter; ++i) {
if (!i->second->filter_out(filters))
continue;
f->open_object_section("op");
i->second->dump(now, f);
f->close_section();
}
};

void OpHistory::dump_ops_by_duration(utime_t now, Formatter *f, set<string> filters)
{
Mutex::Locker history_lock(ops_history_lock);
cleanup(now);
f->open_object_section("op_history");
f->dump_int("size", history_size);
f->dump_int("duration", history_duration);
{
f->open_array_section("ops");
for (auto i = duration.rbegin(); i != duration.rend(); ++i) {
f->open_object_section("op");
if (!i->second->filter_out(filters))
continue;
i->second->dump(now, f);
f->close_section();
if (by_duration) {
dump_fn(duration.rbegin(), duration.rend());
} else {
dump_fn(arrived.begin(), arrived.end());
}
f->close_section();
}
Expand Down Expand Up @@ -188,11 +173,7 @@ bool OpTracker::dump_historic_ops(Formatter *f, bool by_duration, set<string> fi

RWLock::RLocker l(lock);
utime_t now = ceph_clock_now();
if (by_duration) {
history.dump_ops_by_duration(now, f, filters);
} else {
history.dump_ops(now, f, filters);
}
history.dump_ops(now, f, filters, by_duration);
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions src/common/TrackedOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class OpHistory {
}

void _insert_delayed(const utime_t& now, TrackedOpRef op);
void dump_ops(utime_t now, Formatter *f, set<string> filters = {""});
void dump_ops_by_duration(utime_t now, Formatter *f, set<string> filters = {""});
void dump_ops(utime_t now, Formatter *f, set<string> filters = {""}, bool by_duration=false);
void dump_slow_ops(utime_t now, Formatter *f, set<string> filters = {""});
void on_shutdown();
void set_size_and_duration(uint32_t new_size, uint32_t new_duration) {
Expand Down

0 comments on commit 01ff39d

Please sign in to comment.