]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/mgr/client.h
add stop-gap to fix compat with CPUs not supporting SSE 4.1
[ceph.git] / ceph / src / crimson / mgr / client.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #pragma once
5
6 #include <seastar/core/timer.hh>
7
8 #include "crimson/common/gated.h"
9 #include "crimson/net/Dispatcher.h"
10 #include "crimson/net/Fwd.h"
11 #include "mon/MgrMap.h"
12
13 template<typename Message> using Ref = boost::intrusive_ptr<Message>;
14 namespace crimson::net {
15 class Messenger;
16 }
17
18 class MMgrMap;
19 class MMgrConfigure;
20
21 namespace crimson::mgr
22 {
23
24 // implement WithStats if you want to report stats to mgr periodically
25 class WithStats {
26 public:
27 virtual seastar::future<MessageURef> get_stats() const = 0;
28 virtual ~WithStats() {}
29 };
30
31 class Client : public crimson::net::Dispatcher {
32 public:
33 Client(crimson::net::Messenger& msgr,
34 WithStats& with_stats);
35 seastar::future<> start();
36 seastar::future<> stop();
37 void report();
38
39 private:
40 std::optional<seastar::future<>> ms_dispatch(
41 crimson::net::ConnectionRef conn, Ref<Message> m) override;
42 void ms_handle_reset(crimson::net::ConnectionRef conn, bool is_replace) final;
43 void ms_handle_connect(crimson::net::ConnectionRef conn) final;
44 seastar::future<> handle_mgr_map(crimson::net::ConnectionRef conn,
45 Ref<MMgrMap> m);
46 seastar::future<> handle_mgr_conf(crimson::net::ConnectionRef conn,
47 Ref<MMgrConfigure> m);
48 seastar::future<> reconnect();
49
50 void print(std::ostream&) const;
51 friend std::ostream& operator<<(std::ostream& out, const Client& client);
52 private:
53 MgrMap mgrmap;
54 crimson::net::Messenger& msgr;
55 WithStats& with_stats;
56 crimson::net::ConnectionRef conn;
57 seastar::timer<seastar::lowres_clock> report_timer;
58 crimson::common::Gated gate;
59 };
60
61 inline std::ostream& operator<<(std::ostream& out, const Client& client) {
62 client.print(out);
63 return out;
64 }
65
66 }
67
68 #if FMT_VERSION >= 90000
69 template <> struct fmt::formatter<crimson::mgr::Client> : fmt::ostream_formatter {};
70 #endif