blob: 3de54b1aabc2c6a25dc7b5d54f9d6b0b7e7ea1bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef RGW_REALM_RELOADER_H
#define RGW_REALM_RELOADER_H
#include "rgw_realm_watcher.h"
#include "common/Cond.h"
class RGWRados;
/**
* RGWRealmReloader responds to notifications by recreating RGWRados with the
* updated realm configuration.
*/
class RGWRealmReloader : public RGWRealmWatcher::Watcher {
public:
/**
* Pauser is an interface to pause/resume frontends. Frontend cooperation
* is required to ensure that they stop issuing requests on the old
* RGWRados instance, and restart with the updated configuration.
*
* This abstraction avoids a depency on class RGWFrontend, which is only
* defined in rgw_main.cc
*/
class Pauser {
public:
virtual ~Pauser() = default;
/// pause all frontends while realm reconfiguration is in progress
virtual void pause() = 0;
/// resume all frontends with the given RGWRados instance
virtual void resume(RGWRados* store) = 0;
};
RGWRealmReloader(RGWRados*& store, Pauser* frontends);
~RGWRealmReloader() override;
/// respond to realm notifications by scheduling a reload()
void handle_notify(RGWRealmNotify type, bufferlist::iterator& p) override;
private:
/// pause frontends and replace the RGWRados instance
void reload();
class C_Reload; //< Context that calls reload()
/// main()'s RGWRados pointer as a reference, modified by reload()
RGWRados*& store;
Pauser *const frontends;
/// reload() takes a significant amount of time, so we don't want to run
/// it in the handle_notify() thread. we choose a timer thread because we
/// also want to add a delay (see rgw_realm_reconfigure_delay) so that we
/// can batch up notifications within that window
SafeTimer timer;
Mutex mutex; //< protects access to timer and reload_scheduled
Cond cond; //< to signal reload() after an invalid realm config
C_Reload* reload_scheduled; //< reload() context if scheduled
};
#endif // RGW_REALM_RELOADER_H
|