]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: move health_status_t to health.h
authorSage Weil <sage@redhat.com>
Sun, 11 Jun 2017 18:33:10 +0000 (14:33 -0400)
committerSage Weil <sage@redhat.com>
Wed, 12 Jul 2017 16:51:30 +0000 (12:51 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/include/health.h [new file with mode: 0644]
src/include/types.h
src/mds/MDSMap.h
src/messages/MMonMgrReport.h
src/mon/Monitor.h
src/mon/PGMap.h

diff --git a/src/include/health.h b/src/include/health.h
new file mode 100644 (file)
index 0000000..b23a4d4
--- /dev/null
@@ -0,0 +1,68 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <ostream>
+#include <string>
+
+#include "include/encoding.h"
+
+// health_status_t
+enum health_status_t {
+  HEALTH_ERR = 0,
+  HEALTH_WARN = 1,
+  HEALTH_OK = 2,
+};
+
+static inline void encode(health_status_t hs, bufferlist& bl) {
+  uint8_t v = hs;
+  ::encode(v, bl);
+}
+static inline void decode(health_status_t& hs, bufferlist::iterator& p) {
+  uint8_t v;
+  ::decode(v, p);
+  hs = health_status_t(v);
+}
+template<>
+struct denc_traits<health_status_t> {
+  static constexpr bool supported = true;
+  static constexpr bool featured = false;
+  static constexpr bool bounded = true;
+  static constexpr bool need_contiguous = false;
+  static void bound_encode(const bufferptr& v, size_t& p, uint64_t f=0) {
+    p++;
+  }
+  static void encode(const health_status_t& v,
+                    buffer::list::contiguous_appender& p,
+                    uint64_t f=0) {
+    ::denc((uint8_t)v, p);
+  }
+  static void decode(health_status_t& v, buffer::ptr::iterator& p,
+                    uint64_t f=0) {
+    uint8_t tmp;
+    ::denc(tmp, p);
+    v = health_status_t(tmp);
+  }
+  static void decode(health_status_t& v, buffer::list::iterator& p,
+                    uint64_t f=0) {
+    uint8_t tmp;
+    ::denc(tmp, p);
+    v = health_status_t(tmp);
+  }
+};
+
+inline std::ostream& operator<<(std::ostream &oss, const health_status_t status) {
+  switch (status) {
+    case HEALTH_ERR:
+      oss << "HEALTH_ERR";
+      break;
+    case HEALTH_WARN:
+      oss << "HEALTH_WARN";
+      break;
+    case HEALTH_OK:
+      oss << "HEALTH_OK";
+      break;
+  }
+  return oss;
+}
index 371f884f82e85183b04b1771e0a6d1bbb3ad1833..e904a151d75d800112de1a342a4fb3dec76dc139 100644 (file)
@@ -411,29 +411,6 @@ inline ostream& operator<<(ostream& out, const ceph_mon_subscribe_item& i)
             << ((i.flags & CEPH_SUBSCRIBE_ONETIME) ? "" : "+");
 }
 
-enum health_status_t {
-  HEALTH_ERR = 0,
-  HEALTH_WARN = 1,
-  HEALTH_OK = 2,
-};
-
-#ifdef __cplusplus
-inline ostream& operator<<(ostream &oss, const health_status_t status) {
-  switch (status) {
-    case HEALTH_ERR:
-      oss << "HEALTH_ERR";
-      break;
-    case HEALTH_WARN:
-      oss << "HEALTH_WARN";
-      break;
-    case HEALTH_OK:
-      oss << "HEALTH_OK";
-      break;
-  }
-  return oss;
-}
-#endif
-
 struct weightf_t {
   float v;
   // cppcheck-suppress noExplicitConstructor
index e99be2be67b575f1d7e495b4b057ee59f3dc8995..d94204715192c2eba24cb09903fabde854ee6349 100644 (file)
@@ -21,6 +21,7 @@
 #include "include/types.h"
 #include "common/Clock.h"
 #include "msg/Message.h"
+#include "include/health.h"
 
 #include <set>
 #include <map>
index 8f3a8fe9115402ca8184ddfc07e3f8cba3622a12..dc5e965156d011dd515f89dbee78d4b24d5e185e 100644 (file)
 
 #include "messages/PaxosServiceMessage.h"
 #include "include/types.h"
-
-// health_status_t
-static inline void encode(health_status_t hs, bufferlist& bl) {
-  uint8_t v = hs;
-  ::encode(v, bl);
-}
-static inline void decode(health_status_t& hs, bufferlist::iterator& p) {
-  uint8_t v;
-  ::decode(v, p);
-  hs = health_status_t(v);
-}
+#include "include/health.h"
 
 class MMonMgrReport : public PaxosServiceMessage {
 
index ac3f3f0b01838909fbd6aab8b88868db4a2a102d..7b3aa0522c5f71b0f0679c4479b3d4171c968692 100644 (file)
@@ -27,6 +27,7 @@
 #include <cmath>
 
 #include "include/types.h"
+#include "include/health.h"
 #include "msg/Messenger.h"
 
 #include "common/Timer.h"
index 6d58e6b2546d75001a302d74711f555c12e1ac2b..6e367c104e53c5831ff1ec01692f1c81a2eeefc2 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef CEPH_PGMAP_H
 #define CEPH_PGMAP_H
 
+#include "include/health.h"
 #include "common/debug.h"
 #include "common/TextTable.h"
 #include "osd/osd_types.h"