1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
7 #include <seastar/core/future.hh>
8 #include <seastar/core/future-util.hh>
10 #include "crimson/common/log.h"
12 namespace crimson::common
{
14 class system_shutdown_exception final
: public std::exception
{
16 const char* what() const noexcept final
{
17 return "system shutting down";
21 class actingset_changed final
: public std::exception
{
23 actingset_changed(bool sp
) : still_primary(sp
) {}
24 const char* what() const noexcept final
{
25 return "acting set changed";
27 bool is_primary() const {
31 const bool still_primary
;
34 template<typename Func
, typename
... Args
>
35 inline seastar::future
<> handle_system_shutdown(Func
&& func
, Args
&&... args
)
37 return seastar::futurize_invoke(std::forward
<Func
>(func
),
38 std::forward
<Args
>(args
)...)
39 .handle_exception([](std::exception_ptr eptr
) {
40 if (*eptr
.__cxa_exception_type() ==
41 typeid(crimson::common::system_shutdown_exception
)) {
42 crimson::get_logger(ceph_subsys_osd
).debug(
43 "operation skipped, system shutdown");
44 return seastar::now();
46 std::rethrow_exception(eptr
);