tablets: Introduce tablet_map::for_each_tablet()
This commit is contained in:
@@ -153,6 +153,15 @@ void tablet_map::set_tablet_transition_info(tablet_id id, tablet_transition_info
|
||||
_transitions.insert_or_assign(id, std::move(info));
|
||||
}
|
||||
|
||||
future<> tablet_map::for_each_tablet(seastar::noncopyable_function<void(tablet_id, const tablet_info&)> func) const {
|
||||
std::optional<tablet_id> tid = first_tablet();
|
||||
for (const tablet_info& ti : tablets()) {
|
||||
co_await coroutine::maybe_yield();
|
||||
func(*tid, ti);
|
||||
tid = next_tablet(*tid);
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<shard_id> tablet_map::get_shard(tablet_id tid, host_id host) const {
|
||||
auto&& info = get_tablet_info(tid);
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <seastar/core/reactor.hh>
|
||||
#include <seastar/util/log.hh>
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include <seastar/util/noncopyable_function.hh>
|
||||
#include <seastar/coroutine/maybe_yield.hh>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -216,6 +219,9 @@ public:
|
||||
return _tablets;
|
||||
}
|
||||
|
||||
/// Calls a given function for each tablet in the map in token ownership order.
|
||||
future<> for_each_tablet(seastar::noncopyable_function<void(tablet_id, const tablet_info&)> func) const;
|
||||
|
||||
const auto& transitions() const {
|
||||
return _transitions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user