From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/rgw/rgw_object_expirer.cc | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/rgw/rgw_object_expirer.cc (limited to 'src/rgw/rgw_object_expirer.cc') diff --git a/src/rgw/rgw_object_expirer.cc b/src/rgw/rgw_object_expirer.cc new file mode 100644 index 000000000..42aefea67 --- /dev/null +++ b/src/rgw/rgw_object_expirer.cc @@ -0,0 +1,104 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab ft=cpp + +#include +#include +#include +#include + + +#include "auth/Crypto.h" + +#include "common/armor.h" +#include "common/ceph_json.h" +#include "common/config.h" +#include "common/ceph_argparse.h" +#include "common/Formatter.h" +#include "common/errno.h" + +#include "global/global_init.h" + +#include "include/utime.h" +#include "include/str_list.h" + +#include "rgw_user.h" +#include "rgw_bucket.h" +#include "rgw_acl.h" +#include "rgw_acl_s3.h" +#include "rgw_log.h" +#include "rgw_formats.h" +#include "rgw_usage.h" +#include "rgw_object_expirer_core.h" + +#define dout_subsys ceph_subsys_rgw + +static rgw::sal::RGWRadosStore *store = NULL; + +class StoreDestructor { + rgw::sal::RGWRadosStore *store; + +public: + explicit StoreDestructor(rgw::sal::RGWRadosStore *_s) : store(_s) {} + ~StoreDestructor() { + if (store) { + RGWStoreManager::close_storage(store); + } + } +}; + +static void usage() +{ + generic_server_usage(); +} + +int main(const int argc, const char **argv) +{ + vector args; + argv_to_vec(argc, argv, args); + if (args.empty()) { + cerr << argv[0] << ": -h or --help for usage" << std::endl; + exit(1); + } + if (ceph_argparse_need_usage(args)) { + usage(); + exit(0); + } + + auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_DAEMON, + CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); + + for (std::vector::iterator i = args.begin(); i != args.end(); ) { + if (ceph_argparse_double_dash(args, i)) { + break; + } + } + + if (g_conf()->daemonize) { + global_init_daemonize(g_ceph_context); + } + + common_init_finish(g_ceph_context); + + const DoutPrefix dp(cct.get(), dout_subsys, "rgw object expirer: "); + store = RGWStoreManager::get_storage(&dp, g_ceph_context, false, false, false, false, false); + if (!store) { + std::cerr << "couldn't init storage provider" << std::endl; + return EIO; + } + + /* Guard to not forget about closing the rados store. */ + StoreDestructor store_dtor(store); + + RGWObjectExpirer objexp(store); + objexp.start_processor(); + + const utime_t interval(g_ceph_context->_conf->rgw_objexp_gc_interval, 0); + while (true) { + interval.sleep(); + } + + /* unreachable */ + + return EXIT_SUCCESS; +} -- cgit v1.2.3