From: Sage Weil Date: Sun, 11 Jun 2017 18:33:10 +0000 (-0400) Subject: mon: move health_status_t to health.h X-Git-Tag: v12.1.1~58^2~44 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=349fb86ee2b374fa05619c60c5aa77321bb05260;p=ceph.git mon: move health_status_t to health.h Signed-off-by: Sage Weil --- diff --git a/src/include/health.h b/src/include/health.h new file mode 100644 index 000000000000..b23a4d4e2b32 --- /dev/null +++ b/src/include/health.h @@ -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 +#include + +#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 { + 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; +} diff --git a/src/include/types.h b/src/include/types.h index 371f884f82e8..e904a151d75d 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -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 diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index e99be2be67b5..d94204715192 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -21,6 +21,7 @@ #include "include/types.h" #include "common/Clock.h" #include "msg/Message.h" +#include "include/health.h" #include #include diff --git a/src/messages/MMonMgrReport.h b/src/messages/MMonMgrReport.h index 8f3a8fe91154..dc5e965156d0 100644 --- a/src/messages/MMonMgrReport.h +++ b/src/messages/MMonMgrReport.h @@ -17,17 +17,7 @@ #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 { diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index ac3f3f0b0183..7b3aa0522c5f 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -27,6 +27,7 @@ #include #include "include/types.h" +#include "include/health.h" #include "msg/Messenger.h" #include "common/Timer.h" diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 6d58e6b2546d..6e367c104e53 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -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"