From 87fbe29cf98264c3642ba4ad4aed7b05ae701554 Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Wed, 2 Dec 2015 16:50:34 -0200 Subject: [PATCH] api: add support to compaction history Signed-off-by: Raphael S. Carvalho --- api/compaction_manager.cc | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/api/compaction_manager.cc b/api/compaction_manager.cc index 6ee6d14178..909fd58a2d 100644 --- a/api/compaction_manager.cc +++ b/api/compaction_manager.cc @@ -21,6 +21,7 @@ #include "compaction_manager.hh" #include "api/api-doc/compaction_manager.json.hh" +#include "db/system_keyspace.hh" namespace api { @@ -83,11 +84,29 @@ void set_compaction_manager(http_context& ctx, routes& r) { }); cm::get_compaction_history.set(r, [] (std::unique_ptr req) { - //TBD - // FIXME - warn(unimplemented::cause::API); - std::vector res; - return make_ready_future(res); + return db::system_keyspace::get_compaction_history().then([] (std::vector history) { + std::vector res; + res.reserve(history.size()); + + for (auto& entry : history) { + cm::history h; + h.id = entry.id.to_sstring(); + h.ks = std::move(entry.ks); + h.cf = std::move(entry.cf); + h.compacted_at = entry.compacted_at; + h.bytes_in = entry.bytes_in; + h.bytes_out = entry.bytes_out; + for (auto it : entry.rows_merged) { + httpd::compaction_manager_json::row_merged e; + e.key = it.first; + e.value = it.second; + h.rows_merged.push(std::move(e)); + } + res.push_back(std::move(h)); + } + + return make_ready_future(res); + }); }); cm::get_compaction_info.set(r, [] (std::unique_ptr req) {