]> git.proxmox.com Git - ceph.git/blame_incremental - ceph/src/rgw/rgw_realm_reloader.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rgw / rgw_realm_reloader.h
... / ...
CommitLineData
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab ft=cpp
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
10namespace rgw {
11namespace sal {
12class Store;
13}
14}
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 *
27 * This abstraction avoids a dependency on class RGWFrontend.
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
36 virtual void resume(rgw::sal::Store* store) = 0;
37 };
38
39 RGWRealmReloader(rgw::sal::Store*& store, std::map<std::string, std::string>& service_map_meta,
40 Pauser* frontends);
41 ~RGWRealmReloader() override;
42
43 /// respond to realm notifications by scheduling a reload()
44 void handle_notify(RGWRealmNotify type, bufferlist::const_iterator& p) override;
45
46 private:
47 /// pause frontends and replace the RGWRados instance
48 void reload();
49
50 class C_Reload; //< Context that calls reload()
51
52 /// main()'s Store pointer as a reference, modified by reload()
53 rgw::sal::Store*& store;
54 std::map<std::string, std::string>& service_map_meta;
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;
62 ceph::mutex mutex; //< protects access to timer and reload_scheduled
63 ceph::condition_variable cond; //< to signal reload() after an invalid realm config
64 C_Reload* reload_scheduled; //< reload() context if scheduled
65};
66
67#endif // RGW_REALM_RELOADER_H