]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_object_expirer_core.h
813eca3f939a17724dacca94acd93172f76c6f7b
[ceph.git] / ceph / src / rgw / rgw_object_expirer_core.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_OBJEXP_H
5 #define CEPH_OBJEXP_H
6
7 #include <atomic>
8 #include <string>
9 #include <cerrno>
10 #include <sstream>
11 #include <iostream>
12
13 #include "auth/Crypto.h"
14
15 #include "common/armor.h"
16 #include "common/ceph_json.h"
17 #include "common/config.h"
18 #include "common/ceph_argparse.h"
19 #include "common/Formatter.h"
20 #include "common/errno.h"
21
22 #include "common/Mutex.h"
23 #include "common/Cond.h"
24 #include "common/Thread.h"
25
26 #include "global/global_init.h"
27
28 #include "include/utime.h"
29 #include "include/str_list.h"
30
31 #include "rgw_user.h"
32 #include "rgw_bucket.h"
33 #include "rgw_rados.h"
34 #include "rgw_acl.h"
35 #include "rgw_acl_s3.h"
36 #include "rgw_log.h"
37 #include "rgw_formats.h"
38 #include "rgw_usage.h"
39 #include "rgw_replica_log.h"
40
41 class RGWObjectExpirer {
42 protected:
43 RGWRados *store;
44
45 int init_bucket_info(const std::string& tenant_name,
46 const std::string& bucket_name,
47 const std::string& bucket_id,
48 RGWBucketInfo& bucket_info);
49
50 class OEWorker : public Thread {
51 CephContext *cct;
52 RGWObjectExpirer *oe;
53 Mutex lock;
54 Cond cond;
55
56 public:
57 OEWorker(CephContext * const cct,
58 RGWObjectExpirer * const oe)
59 : cct(cct),
60 oe(oe),
61 lock("OEWorker") {
62 }
63
64 void *entry() override;
65 void stop();
66 };
67
68 OEWorker *worker;
69 std::atomic<bool> down_flag = { false };
70
71 public:
72 explicit RGWObjectExpirer(RGWRados *_store)
73 : store(_store) {
74 }
75
76 int garbage_single_object(objexp_hint_entry& hint);
77
78 void garbage_chunk(std::list<cls_timeindex_entry>& entries, /* in */
79 bool& need_trim); /* out */
80
81 void trim_chunk(const std::string& shard,
82 const utime_t& from,
83 const utime_t& to,
84 const string& from_marker,
85 const string& to_marker);
86
87 bool process_single_shard(const std::string& shard,
88 const utime_t& last_run,
89 const utime_t& round_start);
90
91 bool inspect_all_shards(const utime_t& last_run,
92 const utime_t& round_start);
93
94 bool going_down();
95 void start_processor();
96 void stop_processor();
97 };
98 #endif /* CEPH_OBJEXP_H */