This adds a stub implementation to the commit log metrics. The calls return the currect value type with a stub value. After this patch the following url will be available: /commitlog/metrics/completed_tasks /commitlog/metrics/pending_tasks /commitlog/metrics/total_commit_log_size Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
/*
|
|
* Copyright 2015 Cloudius Systems
|
|
*/
|
|
|
|
#include "commitlog.hh"
|
|
#include <db/commitlog/commitlog.hh>
|
|
#include "api/api-doc/commitlog.json.hh"
|
|
#include <vector>
|
|
|
|
namespace api {
|
|
|
|
void set_commitlog(http_context& ctx, routes& r) {
|
|
httpd::commitlog_json::get_active_segment_names.set(r,
|
|
[&ctx](std::unique_ptr<request> req) {
|
|
auto res = make_shared<std::vector<sstring>>();
|
|
return ctx.db.map_reduce([res](std::vector<sstring> names) {
|
|
res->insert(res->end(), names.begin(), names.end());
|
|
}, [](database& db) {
|
|
if (db.commitlog() == nullptr) {
|
|
return make_ready_future<std::vector<sstring>>(std::vector<sstring>());
|
|
}
|
|
return make_ready_future<std::vector<sstring>>(db.commitlog()->get_active_segment_names());
|
|
}).then([res] {
|
|
return make_ready_future<json::json_return_type>(*res.get());
|
|
});
|
|
});
|
|
|
|
// We currently do not support archive segments
|
|
httpd::commitlog_json::get_archiving_segment_names.set(r, [](const_req req) {
|
|
std::vector<sstring> res;
|
|
return res;
|
|
});
|
|
|
|
httpd::commitlog_json::get_completed_tasks.set(r, [](std::unique_ptr<request> req) {
|
|
//TBD
|
|
return make_ready_future<json::json_return_type>(0);
|
|
});
|
|
|
|
httpd::commitlog_json::get_pending_tasks.set(r, [](std::unique_ptr<request> req) {
|
|
//TBD
|
|
return make_ready_future<json::json_return_type>(0);
|
|
});
|
|
|
|
httpd::commitlog_json::get_total_commit_log_size.set(r, [](std::unique_ptr<request> req) {
|
|
//TBD
|
|
return make_ready_future<json::json_return_type>(0);
|
|
});
|
|
}
|
|
|
|
}
|