]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_realm_reloader.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_realm_reloader.h
CommitLineData
7c673cae 1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
9f95a23c 2// vim: ts=8 sw=2 smarttab ft=cpp
7c673cae
FG
3
4#ifndef RGW_REALM_RELOADER_H
5#define RGW_REALM_RELOADER_H
6
7#include "rgw_realm_watcher.h"
8#include "common/Cond.h"
9
9f95a23c
TL
10namespace rgw {
11namespace sal {
20effc67 12class Store;
9f95a23c
TL
13}
14}
7c673cae
FG
15
16/**
17 * RGWRealmReloader responds to new period notifications by recreating RGWRados
18 * with the updated realm configuration.
19 */
20class RGWRealmReloader : public RGWRealmWatcher::Watcher {
21 public:
22 /**
23 * Pauser is an interface to pause/resume frontends. Frontend cooperation
24 * is required to ensure that they stop issuing requests on the old
25 * RGWRados instance, and restart with the updated configuration.
26 *
11fdf7f2 27 * This abstraction avoids a dependency on class RGWFrontend.
7c673cae
FG
28 */
29 class Pauser {
30 public:
31 virtual ~Pauser() = default;
32
33 /// pause all frontends while realm reconfiguration is in progress
34 virtual void pause() = 0;
35 /// resume all frontends with the given RGWRados instance
20effc67 36 virtual void resume(rgw::sal::Store* store) = 0;
7c673cae
FG
37 };
38
20effc67 39 RGWRealmReloader(rgw::sal::Store*& store, std::map<std::string, std::string>& service_map_meta,
224ce89b 40 Pauser* frontends);
7c673cae
FG
41 ~RGWRealmReloader() override;
42
43 /// respond to realm notifications by scheduling a reload()
11fdf7f2 44 void handle_notify(RGWRealmNotify type, bufferlist::const_iterator& p) override;
7c673cae
FG
45
46 private:
47 /// pause frontends and replace the RGWRados instance
48 void reload();
49
50 class C_Reload; //< Context that calls reload()
51
20effc67
TL
52 /// main()'s Store pointer as a reference, modified by reload()
53 rgw::sal::Store*& store;
224ce89b 54 std::map<std::string, std::string>& service_map_meta;
7c673cae
FG
55 Pauser *const frontends;
56
57 /// reload() takes a significant amount of time, so we don't want to run
58 /// it in the handle_notify() thread. we choose a timer thread instead of a
59 /// Finisher because it allows us to cancel events that were scheduled while
60 /// reload() is still running
61 SafeTimer timer;
9f95a23c
TL
62 ceph::mutex mutex; //< protects access to timer and reload_scheduled
63 ceph::condition_variable cond; //< to signal reload() after an invalid realm config
7c673cae
FG
64 C_Reload* reload_scheduled; //< reload() context if scheduled
65};
66
67#endif // RGW_REALM_RELOADER_H