From: Casey Bodley Date: Sat, 21 Oct 2017 16:29:37 +0000 (-0400) Subject: msg: initial seastar messenger interfaces X-Git-Tag: v14.0.1~1115^2~15 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=36197eec608823b2e61330af9b0245b48b954774;p=ceph.git msg: initial seastar messenger interfaces Signed-off-by: Casey Bodley --- diff --git a/src/crimson/net/Connection.h b/src/crimson/net/Connection.h new file mode 100644 index 0000000000000..67ba97e6de3ec --- /dev/null +++ b/src/crimson/net/Connection.h @@ -0,0 +1,60 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2017 Red Hat, Inc + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#pragma once + +#include +#include + +#include "Fwd.h" + +namespace ceph::net { + +class Connection : public boost::intrusive_ref_counter { + protected: + Messenger *const messenger; + entity_addr_t my_addr; + entity_addr_t peer_addr; + + public: + Connection(Messenger *messenger, const entity_addr_t& my_addr, + const entity_addr_t& peer_addr) + : messenger(messenger), my_addr(my_addr), peer_addr(peer_addr) {} + virtual ~Connection() {} + + Messenger* get_messenger() const { return messenger; } + + const entity_addr_t& get_my_addr() const { return my_addr; } + const entity_addr_t& get_peer_addr() const { return peer_addr; } + + /// true if the handshake has completed and no errors have been encountered + virtual bool is_connected() = 0; + + /// complete a handshake from the client's perspective + virtual seastar::future<> client_handshake() = 0; + + /// complete a handshake from the server's perspective + virtual seastar::future<> server_handshake() = 0; + + /// read a message from a connection that has completed its handshake + virtual seastar::future read_message() = 0; + + /// send a message over a connection that has completed its handshake + virtual seastar::future<> send(MessageRef msg) = 0; + + /// close the connection and cancel any any pending futures from read/send + virtual seastar::future<> close() = 0; +}; + +} // namespace ceph::net diff --git a/src/crimson/net/Dispatcher.h b/src/crimson/net/Dispatcher.h new file mode 100644 index 0000000000000..646c70f3c9511 --- /dev/null +++ b/src/crimson/net/Dispatcher.h @@ -0,0 +1,52 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2017 Red Hat, Inc + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#pragma once + +#include + +#include "Fwd.h" + +namespace ceph { +namespace net { + +class Dispatcher { + public: + virtual ~Dispatcher() {} + + virtual seastar::future<> ms_dispatch(ConnectionRef conn, MessageRef m) { + return seastar::make_ready_future<>(); + } + + virtual seastar::future<> ms_handle_accept(ConnectionRef conn) { + return seastar::make_ready_future<>(); + } + + virtual seastar::future<> ms_handle_connect(ConnectionRef conn) { + return seastar::make_ready_future<>(); + } + + virtual seastar::future<> ms_handle_reset(ConnectionRef conn) { + return seastar::make_ready_future<>(); + } + + virtual seastar::future<> ms_handle_remote_reset(ConnectionRef conn) { + return seastar::make_ready_future<>(); + } + + // TODO: authorizer +}; + +} // namespace net +} // namespace ceph diff --git a/src/crimson/net/Fwd.h b/src/crimson/net/Fwd.h new file mode 100644 index 0000000000000..44f4c76a3813d --- /dev/null +++ b/src/crimson/net/Fwd.h @@ -0,0 +1,34 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2017 Red Hat, Inc + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#pragma once + +#include + +#include "msg/msg_types.h" + +class Message; +using MessageRef = boost::intrusive_ptr; + +namespace ceph::net { + +class Connection; +using ConnectionRef = boost::intrusive_ptr; + +class Dispatcher; + +class Messenger; + +} // namespace ceph::net + diff --git a/src/crimson/net/Messenger.h b/src/crimson/net/Messenger.h new file mode 100644 index 0000000000000..5230b77c6d152 --- /dev/null +++ b/src/crimson/net/Messenger.h @@ -0,0 +1,55 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2017 Red Hat, Inc + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#pragma once + +#include + +#include "Fwd.h" + +class AuthAuthorizer; + +namespace ceph::net { + +class Messenger { + entity_name_t my_name; + entity_addr_t my_addr; + + public: + Messenger(const entity_name_t& name) + : my_name(name) + {} + virtual ~Messenger() {} + + const entity_name_t& get_myname() const { return my_name; } + const entity_addr_t& get_myaddr() const { return my_addr; } + void set_myaddr(const entity_addr_t& addr) { + my_addr = addr; + } + + /// bind to the given address + virtual void bind(const entity_addr_t& addr) = 0; + + /// start the messenger + virtual seastar::future<> start(Dispatcher *dispatcher) = 0; + + /// establish a client connection and complete a handshake + virtual seastar::future connect(const entity_addr_t& addr) = 0; + + /// stop listenening and wait for all connections to close. safe to destruct + /// after this future becomes available + virtual seastar::future<> shutdown() = 0; +}; + +} // namespace ceph::net