]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
messages: add ceph-mgr messages
authorJohn Spray <john.spray@redhat.com>
Thu, 19 May 2016 11:56:39 +0000 (12:56 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 29 Sep 2016 16:26:53 +0000 (17:26 +0100)
Signed-off-by: John Spray <john.spray@redhat.com>
src/messages/MMDSMap.h
src/messages/MMgrBeacon.h [new file with mode: 0644]
src/messages/MMgrConfigure.h [new file with mode: 0644]
src/messages/MMgrDigest.h [new file with mode: 0644]
src/messages/MMgrMap.h [new file with mode: 0644]
src/messages/MMgrOpen.h [new file with mode: 0644]
src/messages/MMgrReport.h [new file with mode: 0644]
src/msg/Message.cc
src/msg/Message.h

index 36b9e958144da2ecd6bf8597683ef64acf03da5c..d177369ce750b3c80be79db1d0f6e038f4e5dff3 100644 (file)
 #include "include/ceph_features.h"
 
 class MMDSMap : public Message {
- public:
-  /*
-  map<epoch_t, bufferlist> maps;
-  map<epoch_t, bufferlist> incremental_maps;
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+public:
 
-  epoch_t get_first() {
-    epoch_t e = 0;
-    map<epoch_t, bufferlist>::iterator i = maps.begin();
-    if (i != maps.end())  e = i->first;
-    i = incremental_maps.begin();    
-    if (i != incremental_maps.end() &&
-        (e == 0 || i->first < e)) e = i->first;
-    return e;
-  }
-  epoch_t get_last() {
-    epoch_t e = 0;
-    map<epoch_t, bufferlist>::reverse_iterator i = maps.rbegin();
-    if (i != maps.rend())  e = i->first;
-    i = incremental_maps.rbegin();    
-    if (i != incremental_maps.rend() &&
-        (e == 0 || i->first > e)) e = i->first;
-    return e;
-  }
-  */
-  
   uuid_d fsid;
   epoch_t epoch;
   bufferlist encoded;
@@ -54,9 +33,9 @@ class MMDSMap : public Message {
   bufferlist& get_encoded() { return encoded; }
 
   MMDSMap() : 
-    Message(CEPH_MSG_MDS_MAP) {}
+    Message(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION) {}
   MMDSMap(const uuid_d &f, MDSMap *mm) :
-    Message(CEPH_MSG_MDS_MAP),
+    Message(CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION),
     fsid(f) {
     epoch = mm->get_epoch();
     mm->encode(encoded, -1);  // we will reencode with fewer features as necessary
diff --git a/src/messages/MMgrBeacon.h b/src/messages/MMgrBeacon.h
new file mode 100644 (file)
index 0000000..e38227e
--- /dev/null
@@ -0,0 +1,69 @@
+// -*- 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) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * 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.
+ * 
+ */
+
+#ifndef CEPH_MMGRBEACON_H
+#define CEPH_MMGRBEACON_H
+
+#include "messages/PaxosServiceMessage.h"
+
+#include "include/types.h"
+
+
+class MMgrBeacon : public PaxosServiceMessage {
+
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+protected:
+  uint64_t gid;
+  entity_addr_t server_addr;
+
+public:
+  MMgrBeacon()
+    : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION)
+  {
+  }
+
+  MMgrBeacon(uint64_t gid_, entity_addr_t server_addr_)
+    : PaxosServiceMessage(MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION),
+      gid(gid_), server_addr(server_addr_)
+  {
+  }
+
+  uint64_t get_gid() const { return gid; }
+  entity_addr_t get_server_addr() const { return server_addr; }
+
+private:
+  ~MMgrBeacon() {}
+
+public:
+
+  const char *get_type_name() const { return "mgrbeacon"; }
+
+  void print(ostream& out) const {
+    out << get_type_name() << "(" << gid << ", " << server_addr << ")";
+  }
+
+  void encode_payload(uint64_t features) {
+    paxos_encode();
+    ::encode(server_addr, payload, features);
+  }
+  void decode_payload() {
+    bufferlist::iterator p = payload.begin();
+    paxos_decode(p);
+    ::decode(server_addr, p);
+  }
+};
+
+#endif
diff --git a/src/messages/MMgrConfigure.h b/src/messages/MMgrConfigure.h
new file mode 100644 (file)
index 0000000..e9b7439
--- /dev/null
@@ -0,0 +1,53 @@
+// -*- 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) 2016 John Spray <john.spray@redhat.com>
+ *
+ * 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.
+ */
+
+
+#ifndef CEPH_MMGRCONFIGURE_H_
+#define CEPH_MMGRCONFIGURE_H_
+
+#include "msg/Message.h"
+
+/**
+ * This message is sent from ceph-mgr to MgrClient, instructing it
+ * it about what data to send back to ceph-mgr at what frequency.
+ */
+class MMgrConfigure : public Message
+{
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+public:
+  uint32_t stats_period;
+
+  void decode_payload()
+  {
+    bufferlist::iterator p = payload.begin();
+    ::decode(stats_period, p);
+  }
+
+  void encode_payload(uint64_t features) {
+    ::encode(stats_period, payload);
+  }
+
+  const char *get_type_name() const { return "mgrconfigure"; }
+  void print(ostream& out) const {
+    out << get_type_name() << "()";
+  }
+
+  MMgrConfigure()
+    : Message(MSG_MGR_CONFIGURE, HEAD_VERSION, COMPAT_VERSION)
+  {}
+};
+
+#endif
+
diff --git a/src/messages/MMgrDigest.h b/src/messages/MMgrDigest.h
new file mode 100644 (file)
index 0000000..3823a1d
--- /dev/null
@@ -0,0 +1,53 @@
+// -*- 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) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * 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.
+ * 
+ */
+
+
+#ifndef CEPH_MMGRDIGEST_H
+#define CEPH_MMGRDIGEST_H
+
+#include "msg/Message.h"
+
+/**
+ * The mgr digest is a way for the mgr to subscribe to things
+ * other than the cluster maps, which are needed by 
+ */
+class MMgrDigest : public Message {
+public:
+  bufferlist mon_status_json;
+  bufferlist health_json;
+
+  MMgrDigest() : 
+    Message(MSG_MGR_DIGEST) {}
+
+  const char *get_type_name() const { return "mgrdigest"; }
+  void print(ostream& out) const {
+    out << get_type_name();
+  }
+
+  void decode_payload() {
+    bufferlist::iterator p = payload.begin();
+    ::decode(mon_status_json, p);
+    ::decode(health_json, p);
+  }
+  void encode_payload(uint64_t features) {
+    ::encode(mon_status_json, payload);
+    ::encode(health_json, payload);
+  }
+
+private:
+  ~MMgrDigest() {}
+
+};
+
+#endif
diff --git a/src/messages/MMgrMap.h b/src/messages/MMgrMap.h
new file mode 100644 (file)
index 0000000..00dfcb8
--- /dev/null
@@ -0,0 +1,54 @@
+// -*- 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) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * 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.
+ * 
+ */
+
+
+#ifndef CEPH_MMGRMAP_H
+#define CEPH_MMGRMAP_H
+
+#include "msg/Message.h"
+#include "mon/MgrMap.h"
+
+class MMgrMap : public Message {
+protected:
+  MgrMap map;
+
+public:
+  const MgrMap & get_map() {return map;}
+
+  MMgrMap() : 
+    Message(MSG_MGR_MAP) {}
+  MMgrMap(const MgrMap &map_) :
+    Message(MSG_MGR_MAP), map(map_)
+  {
+  }
+
+private:
+  ~MMgrMap() {}
+
+public:
+  const char *get_type_name() const { return "mgrmap"; }
+  void print(ostream& out) const {
+    out << get_type_name() << "(e " << map.epoch << ")";
+  }
+
+  void decode_payload() {
+    bufferlist::iterator p = payload.begin();
+    ::decode(map, p);
+  }
+  void encode_payload(uint64_t features) {
+    ::encode(map, payload, features);
+  }
+};
+
+#endif
diff --git a/src/messages/MMgrOpen.h b/src/messages/MMgrOpen.h
new file mode 100644 (file)
index 0000000..2fdfa05
--- /dev/null
@@ -0,0 +1,50 @@
+// -*- 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) 2016 John Spray <john.spray@redhat.com>
+ *
+ * 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.
+ */
+
+
+#ifndef CEPH_MMGROPEN_H_
+#define CEPH_MMGROPEN_H_
+
+#include "msg/Message.h"
+
+class MMgrOpen : public Message
+{
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+public:
+
+  std::string daemon_name;
+
+  void decode_payload()
+  {
+    bufferlist::iterator p = payload.begin();
+    ::decode(daemon_name, p);
+  }
+
+  void encode_payload(uint64_t features) {
+    ::encode(daemon_name, payload);
+  }
+
+  const char *get_type_name() const { return "mgropen"; }
+  void print(ostream& out) const {
+    out << get_type_name() << "(" << daemon_name << ")"; 
+  }
+
+  MMgrOpen()
+    : Message(MSG_MGR_OPEN, HEAD_VERSION, COMPAT_VERSION)
+  {}
+};
+
+#endif
+
diff --git a/src/messages/MMgrReport.h b/src/messages/MMgrReport.h
new file mode 100644 (file)
index 0000000..907cf47
--- /dev/null
@@ -0,0 +1,105 @@
+// -*- 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) 2016 John Spray <john.spray@redhat.com>
+ *
+ * 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.
+ */
+
+
+#ifndef CEPH_MMGRREPORT_H_
+#define CEPH_MMGRREPORT_H_
+
+#include "msg/Message.h"
+
+#include "common/perf_counters.h"
+
+class PerfCounterType
+{
+public:
+  std::string path;
+  std::string description;
+  std::string nick;
+  enum perfcounter_type_d type;
+
+  void encode(bufferlist &bl) const
+  {
+    // TODO: decide whether to drop the per-type
+    // encoding here, we could rely on the MgrReport
+    // verisoning instead.
+    ENCODE_START(1, 1, bl);
+    ::encode(path, bl);
+    ::encode(description, bl);
+    ::encode(nick, bl);
+    assert(type < 256);
+    ::encode((uint8_t)type, bl);
+    ENCODE_FINISH(bl);
+  }
+  
+  void decode(bufferlist::iterator &p)
+  {
+    DECODE_START(1, p);
+    ::decode(path, p);
+    ::decode(description, p);
+    ::decode(nick, p);
+    ::decode((uint8_t&)type, p);
+    DECODE_FINISH(p);
+  }
+};
+WRITE_CLASS_ENCODER(PerfCounterType)
+
+class MMgrReport : public Message
+{
+  static const int HEAD_VERSION = 1;
+  static const int COMPAT_VERSION = 1;
+
+public:
+  /**
+   * Client is responsible for remembering whether it has introduced
+   * each perf counter to the server.  When first sending a particular
+   * counter, it must inline the counter's schema here.
+   */
+  std::vector<PerfCounterType> declare_types;
+
+  // For all counters present, sorted by idx, output
+  // as many bytes as are needed to represent them
+
+  // Decode: iterate over the types we know about, sorted by idx,
+  // and use the current type's type to decide how to decode
+  // the next bytes from the bufferlist.
+  bufferlist packed;
+
+  std::string daemon_name;
+
+  void decode_payload()
+  {
+    bufferlist::iterator p = payload.begin();
+    ::decode(daemon_name, p);
+    ::decode(declare_types, p);
+    ::decode(packed, p);
+  }
+
+  void encode_payload(uint64_t features) {
+    ::encode(daemon_name, payload);
+    ::encode(declare_types, payload);
+    ::encode(packed, payload);
+  }
+
+  const char *get_type_name() const { return "mgrreport"; }
+  void print(ostream& out) const {
+    out << get_type_name() << "(" << declare_types.size() << " "
+        << packed.length() << ")"; 
+  }
+
+  MMgrReport()
+    : Message(MSG_MGR_REPORT, HEAD_VERSION, COMPAT_VERSION)
+  {}
+};
+
+#endif
+
index 743c89c33e18212ef26388f8e80e820f7d27af27..7b87667f384d7dcc206951e38a257b5b4d908da6 100644 (file)
@@ -156,6 +156,13 @@ using namespace std;
 #include "messages/MCacheExpire.h"
 #include "messages/MInodeFileCaps.h"
 
+#include "messages/MMgrBeacon.h"
+#include "messages/MMgrMap.h"
+#include "messages/MMgrDigest.h"
+#include "messages/MMgrReport.h"
+#include "messages/MMgrOpen.h"
+#include "messages/MMgrConfigure.h"
+
 #include "messages/MLock.h"
 
 #include "messages/MWatchNotify.h"
@@ -706,6 +713,30 @@ Message *decode_message(CephContext *cct, int crcflags,
     m = new MLock();
     break;
 
+  case MSG_MGR_BEACON:
+    m = new MMgrBeacon();
+    break;
+
+  case MSG_MGR_MAP:
+    m = new MMgrMap();
+    break;
+
+  case MSG_MGR_DIGEST:
+    m = new MMgrDigest();
+    break;
+
+  case MSG_MGR_OPEN:
+    m = new MMgrOpen();
+    break;
+
+  case MSG_MGR_REPORT:
+    m = new MMgrReport();
+    break;
+
+  case MSG_MGR_CONFIGURE:
+    m = new MMgrConfigure();
+    break;
+
   case MSG_TIMECHECK:
     m = new MTimeCheck();
     break;
index bc64b891bf66cff2e7c96678b302e5aeb8475ff1..40eb336dd578bba4af2970c858dd71e53d224f00 100644 (file)
 // Special
 #define MSG_NOP                   0x607
 
+// *** ceph-mgr <-> OSD/MDS daemons ***
+#define MSG_MGR_OPEN              0x700
+#define MSG_MGR_CONFIGURE         0x701
+#define MSG_MGR_REPORT            0x702
+
+// *** ceph-mgr <-> ceph-mon ***
+#define MSG_MGR_BEACON            0x703
+
+// *** ceph-mon(MgrMonitor) -> OSD/MDS daemons ***
+#define MSG_MGR_MAP               0x704
+
+// *** ceph-mon(MgrMonitor) -> ceph-mgr
+#define MSG_MGR_DIGEST               0x705
+
 // ======================================================
 
 // abstract Message class