Expose the segment names in commit log

This adds a method to return a vector with full-path to the active
segment names. It will be used by the API.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
Amnon Heiman
2015-05-19 12:22:56 +03:00
parent b795acdf63
commit b95dabba38
2 changed files with 23 additions and 0 deletions

View File

@@ -172,6 +172,7 @@ public:
_timer.arm(std::chrono::milliseconds(cfg.commitlog_sync_period_in_ms));
}
std::vector<sstring> get_active_names() const;
private:
uint64_t _ids = 0;
std::vector<sseg_ptr> _segments;
@@ -460,6 +461,9 @@ public:
bool contains(const replay_position& pos) {
return pos.id == _desc.id;
}
sstring get_segment_name() const {
return _desc.filename();
}
};
const size_t db::commitlog::segment::default_size;
@@ -639,6 +643,17 @@ void db::commitlog::segment_manager::sync() {
}
arm();
}
std::vector<sstring> db::commitlog::segment_manager::get_active_names() const {
std::vector<sstring> res;
for (auto i: _segments) {
if (!i->is_unused()) {
// Each shared is located in its own directory
res.push_back(cfg.commit_log_location + "/" + i->get_segment_name());
}
}
return res;
}
/**
* Add mutation.
*/
@@ -806,3 +821,6 @@ subscription<temporary_buffer<char>> db::commitlog::read_log_file(file f, commit
return ret;
}
std::vector<sstring> db::commitlog::get_active_segment_names() const {
return _segment_manager->get_active_names();
}