From 4364d72ca3e9be3c06fbc584a3555edffb99a369 Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Mon, 24 Aug 2015 19:19:01 +0200 Subject: [PATCH] Commitlog: Expose convinience method "list_existing_segments" --- db/commitlog/commitlog.cc | 15 +++++++++++++++ db/commitlog/commitlog.hh | 3 +++ 2 files changed, 18 insertions(+) diff --git a/db/commitlog/commitlog.cc b/db/commitlog/commitlog.cc index 0c3e842512..a5767c799f 100644 --- a/db/commitlog/commitlog.cc +++ b/db/commitlog/commitlog.cc @@ -997,3 +997,18 @@ future> db::commitlog::list_existing_desc future> db::commitlog::list_existing_descriptors(const sstring& dir) const { return _segment_manager->list_descriptors(dir); } + +future> db::commitlog::list_existing_segments() const { + return list_existing_segments(active_config().commit_log_location); +} + +future> db::commitlog::list_existing_segments(const sstring& dir) const { + return list_existing_descriptors(dir).then([dir](auto descs) { + std::vector paths; + std::transform(descs.begin(), descs.end(), std::back_inserter(paths), [&](auto& d) { + return dir + "/" + d.filename(); + }); + return make_ready_future>(std::move(paths)); + }); +} + diff --git a/db/commitlog/commitlog.hh b/db/commitlog/commitlog.hh index 64f553b9af..9f775c55c5 100644 --- a/db/commitlog/commitlog.hh +++ b/db/commitlog/commitlog.hh @@ -187,6 +187,9 @@ public: future> list_existing_descriptors() const; future> list_existing_descriptors(const sstring& dir) const; + future> list_existing_segments() const; + future> list_existing_segments(const sstring& dir) const; + typedef std::function(temporary_buffer, replay_position)> commit_load_reader_func; static subscription, replay_position> read_log_file(file, commit_load_reader_func);