summaryrefslogtreecommitdiffstats
path: root/src/rgw/rgw_period_pusher.h
blob: 0f6d43b01db6b18e4bf99c851b03fa64aa35017d (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 ft=cpp

#ifndef RGW_PERIOD_PUSHER_H
#define RGW_PERIOD_PUSHER_H

#include <memory>
#include <mutex>
#include <vector>

#include "common/async/yield_context.h"
#include "rgw_realm_reloader.h"

namespace rgw {
namespace sal {
class RGWRadosStore;
}
}

class RGWPeriod;

// RGWRealmNotify payload for push coordination
using RGWZonesNeedPeriod = RGWPeriod;

/**
 * RGWPeriodPusher coordinates with other nodes via the realm watcher to manage
 * the responsibility for pushing period updates to other zones or zonegroups.
 */
class RGWPeriodPusher final : public RGWRealmWatcher::Watcher,
                              public RGWRealmReloader::Pauser {
 public:
  explicit RGWPeriodPusher(const DoutPrefixProvider *dpp, rgw::sal::RGWRadosStore* store, optional_yield y);
  ~RGWPeriodPusher() override;

  /// respond to realm notifications by pushing new periods to other zones
  void handle_notify(RGWRealmNotify type, bufferlist::const_iterator& p) override;

  /// avoid accessing RGWRados while dynamic reconfiguration is in progress.
  /// notifications will be enqueued until resume()
  void pause() override;

  /// continue processing notifications with a new RGWRados instance
  void resume(rgw::sal::RGWRadosStore* store) override;

 private:
  void handle_notify(RGWZonesNeedPeriod&& period);

  CephContext *const cct;
  rgw::sal::RGWRadosStore* store;

  std::mutex mutex;
  epoch_t realm_epoch{0}; //< the current realm epoch being sent
  epoch_t period_epoch{0}; //< the current period epoch being sent

  /// while paused for reconfiguration, we need to queue up notifications
  std::vector<RGWZonesNeedPeriod> pending_periods;

  class CRThread; //< contains thread, coroutine manager, http manager
  std::unique_ptr<CRThread> cr_thread; //< thread to run the push coroutines
};

#endif // RGW_PERIOD_PUSHER_H