sstables: add sstable's on closed handling

Motivation is that it will be useful for catching regression on compaction
when releasing early exhausted sstables. That's because sstable's space
is only released once it's closed. So this will allow us to write a test
case and possibly use it for entities holding exhausted sstable.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2018-10-31 00:18:33 -02:00
parent 0085e8371d
commit 824c20b76d
2 changed files with 8 additions and 0 deletions

View File

@@ -4126,6 +4126,8 @@ sstable::~sstable() {
}
}
_on_closed(*this);
}
sstring

View File

@@ -61,6 +61,7 @@
#include "db/large_partition_handler.hh"
#include "column_translation.hh"
#include "stats.hh"
#include "utils/observable.hh"
#include <seastar/util/optimized_optional.hh>
@@ -388,6 +389,10 @@ public:
}
std::vector<sstring> component_filenames() const;
utils::observer<sstable&> add_on_closed_handler(std::function<void (sstable&)> on_closed_handler) noexcept {
return _on_closed.observe(on_closed_handler);
}
template<typename Func, typename... Args>
auto sstable_write_io_check(Func&& func, Args&&... args) const {
return do_io_check(_write_error_handler, func, std::forward<Args>(args)...);
@@ -429,6 +434,7 @@ private:
stdx::optional<dht::decorated_key> _first;
stdx::optional<dht::decorated_key> _last;
utils::UUID _run_identifier;
utils::observable<sstable&> _on_closed;
lw_shared_ptr<file_input_stream_history> _single_partition_history = make_lw_shared<file_input_stream_history>();
lw_shared_ptr<file_input_stream_history> _partition_range_history = make_lw_shared<file_input_stream_history>();