From 824c20b76da7d87ba27ae8701700d2cd8f210a3c Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Wed, 31 Oct 2018 00:18:33 -0200 Subject: [PATCH] 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 --- sstables/sstables.cc | 2 ++ sstables/sstables.hh | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/sstables/sstables.cc b/sstables/sstables.cc index 09ab91efee..193bcff8a5 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -4126,6 +4126,8 @@ sstable::~sstable() { } } + + _on_closed(*this); } sstring diff --git a/sstables/sstables.hh b/sstables/sstables.hh index 5a44e50153..c7500527bb 100644 --- a/sstables/sstables.hh +++ b/sstables/sstables.hh @@ -61,6 +61,7 @@ #include "db/large_partition_handler.hh" #include "column_translation.hh" #include "stats.hh" +#include "utils/observable.hh" #include @@ -388,6 +389,10 @@ public: } std::vector component_filenames() const; + utils::observer add_on_closed_handler(std::function on_closed_handler) noexcept { + return _on_closed.observe(on_closed_handler); + } + template auto sstable_write_io_check(Func&& func, Args&&... args) const { return do_io_check(_write_error_handler, func, std::forward(args)...); @@ -429,6 +434,7 @@ private: stdx::optional _first; stdx::optional _last; utils::UUID _run_identifier; + utils::observable _on_closed; lw_shared_ptr _single_partition_history = make_lw_shared(); lw_shared_ptr _partition_range_history = make_lw_shared();