]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: initial seastar messenger interfaces
authorCasey Bodley <cbodley@redhat.com>
Sat, 21 Oct 2017 16:29:37 +0000 (12:29 -0400)
committerKefu Chai <kchai@redhat.com>
Wed, 13 Jun 2018 06:09:21 +0000 (14:09 +0800)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/crimson/net/Connection.h [new file with mode: 0644]
src/crimson/net/Dispatcher.h [new file with mode: 0644]
src/crimson/net/Fwd.h [new file with mode: 0644]
src/crimson/net/Messenger.h [new file with mode: 0644]

diff --git a/src/crimson/net/Connection.h b/src/crimson/net/Connection.h
new file mode 100644 (file)
index 0000000..67ba97e
--- /dev/null
@@ -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 <boost/smart_ptr/intrusive_ref_counter.hpp>
+#include <core/future.hh>
+
+#include "Fwd.h"
+
+namespace ceph::net {
+
+class Connection : public boost::intrusive_ref_counter<Connection> {
+ 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<MessageRef> 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 (file)
index 0000000..646c70f
--- /dev/null
@@ -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 <core/future.hh>
+
+#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 (file)
index 0000000..44f4c76
--- /dev/null
@@ -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 <boost/intrusive_ptr.hpp>
+
+#include "msg/msg_types.h"
+
+class Message;
+using MessageRef = boost::intrusive_ptr<Message>;
+
+namespace ceph::net {
+
+class Connection;
+using ConnectionRef = boost::intrusive_ptr<Connection>;
+
+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 (file)
index 0000000..5230b77
--- /dev/null
@@ -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 <core/future.hh>
+
+#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<ConnectionRef> 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