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);