From 311c6371f86d1eac813b08952f5ec7dacd8bc9c2 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 16 Oct 2018 23:24:05 +0800 Subject: [PATCH] crimson/mon: move mon::Connection into .cc Signed-off-by: Kefu Chai --- src/crimson/mon/MonClient.cc | 39 +++++++++++++++++++++++++++++++++ src/crimson/mon/MonClient.h | 41 +++++------------------------------ src/test/crimson/test_monc.cc | 1 + 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/crimson/mon/MonClient.cc b/src/crimson/mon/MonClient.cc index b79cc32c710..ab8e53ce854 100644 --- a/src/crimson/mon/MonClient.cc +++ b/src/crimson/mon/MonClient.cc @@ -15,9 +15,11 @@ #include "crimson/common/config_proxy.h" #include "crimson/common/log.h" #include "crimson/net/Connection.h" +#include "crimson/net/Errors.h" #include "crimson/net/Messenger.h" #include "messages/MAuth.h" +#include "messages/MAuthReply.h" #include "messages/MConfig.h" #include "messages/MLogAck.h" #include "messages/MMonCommand.h" @@ -42,6 +44,40 @@ namespace { namespace ceph::mon { + +class Connection { +public: + Connection(ceph::net::ConnectionRef conn, + KeyRing* keyring); + seastar::future<> handle_auth_reply(Ref m); + seastar::future<> authenticate(epoch_t epoch, + const EntityName& name, + const AuthMethodList& auth_methods, + uint32_t want_keys); + seastar::future<> close(); + bool is_my_peer(const entity_addr_t& addr) const; + + seastar::future<> renew_tickets(); + ceph::net::ConnectionRef get_conn(); + +private: + seastar::future<> setup_session(epoch_t epoch, + const AuthMethodList& auth_methods, + const EntityName& name); + std::unique_ptr create_auth(Ref m, + const EntityName& name, + uint32_t want_keys); + seastar::future do_auth(); + +private: + bool closed = false; + seastar::promise> reply; + ceph::net::ConnectionRef conn; + std::unique_ptr auth; + RotatingKeyRing rotating_keyring; + uint64_t global_id; +}; + Connection::Connection(ceph::net::ConnectionRef conn, KeyRing* keyring) : conn{conn}, @@ -223,6 +259,9 @@ Client::Client(const EntityName& name, msgr{messenger} {} +Client::Client(Client&&) = default; +Client::~Client() = default; + seastar::future<> Client::load_keyring() { if (!auth_methods.is_supported_auth(CEPH_AUTH_CEPHX)) { diff --git a/src/crimson/mon/MonClient.h b/src/crimson/mon/MonClient.h index c4356a61c1f..ed94a4812a8 100644 --- a/src/crimson/mon/MonClient.h +++ b/src/crimson/mon/MonClient.h @@ -9,15 +9,12 @@ #include #include -#include "auth/AuthClientHandler.h" #include "auth/AuthMethodList.h" #include "auth/KeyRing.h" -#include "auth/RotatingKeyRing.h" -#include "crimson/net/Connection.h" #include "crimson/net/Dispatcher.h" +#include "crimson/net/Fwd.h" -#include "messages/MAuthReply.h" #include "mon/MonMap.h" #include "mon/MonSub.h" @@ -27,6 +24,7 @@ namespace ceph::net { class Messenger; } +class MAuthReply; struct MMonMap; struct MMonSubscribeAck; struct MMonGetVersionReply; @@ -36,38 +34,7 @@ struct MConfig; namespace ceph::mon { -class Connection { -public: - Connection(ceph::net::ConnectionRef conn, - KeyRing* keyring); - seastar::future<> handle_auth_reply(Ref m); - seastar::future<> authenticate(epoch_t epoch, - const EntityName& name, - const AuthMethodList& auth_methods, - uint32_t want_keys); - seastar::future<> close(); - bool is_my_peer(const entity_addr_t& addr) const; - - seastar::future<> renew_tickets(); - ceph::net::ConnectionRef get_conn(); - -private: - seastar::future<> setup_session(epoch_t epoch, - const AuthMethodList& auth_methods, - const EntityName& name); - std::unique_ptr create_auth(Ref m, - const EntityName& name, - uint32_t want_keys); - seastar::future do_auth(); - -private: - bool closed = false; - seastar::promise> reply; - ceph::net::ConnectionRef conn; - std::unique_ptr auth; - RotatingKeyRing rotating_keyring; - uint64_t global_id; -}; +class Connection; class Client : public ceph::net::Dispatcher { const EntityName entity_name; @@ -100,6 +67,8 @@ class Client : public ceph::net::Dispatcher { public: Client(const EntityName& name, ceph::net::Messenger& messenger); + Client(Client&&); + ~Client(); seastar::future<> load_keyring(); seastar::future<> build_initial_map(); seastar::future<> authenticate(std::chrono::seconds seconds); diff --git a/src/test/crimson/test_monc.cc b/src/test/crimson/test_monc.cc index 16cfe3b7111..0df9b13791a 100644 --- a/src/test/crimson/test_monc.cc +++ b/src/test/crimson/test_monc.cc @@ -2,6 +2,7 @@ #include "common/ceph_argparse.h" #include "crimson/common/config_proxy.h" #include "crimson/mon/MonClient.h" +#include "crimson/net/Connection.h" #include "crimson/net/SocketMessenger.h" using Config = ceph::common::ConfigProxy; -- 2.39.5