+++ /dev/null
-// -*- 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) 2012 Inktank, 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.
- *
- */
-#ifndef CEPH_MMON_HEALTH_H
-#define CEPH_MMON_HEALTH_H
-
-#include "msg/Message.h"
-#include "messages/MMonQuorumService.h"
-#include "mon/mon_types.h"
-
-struct MMonHealth : public MMonQuorumService
-{
- static const int HEAD_VERSION = 1;
-
- enum {
- OP_TELL = 1,
- };
-
- int service_type = 0;
- int service_op = 0;
-
- // service specific data
- DataStats data_stats;
-
- MMonHealth() : MMonQuorumService(MSG_MON_HEALTH, HEAD_VERSION) { }
- MMonHealth(uint32_t type, int op = 0) :
- MMonQuorumService(MSG_MON_HEALTH, HEAD_VERSION),
- service_type(type),
- service_op(op)
- { }
-
-private:
- ~MMonHealth() override { }
-
-public:
- const char *get_type_name() const override { return "mon_health"; }
- const char *get_service_op_name() const {
- switch (service_op) {
- case OP_TELL: return "tell";
- }
- return "???";
- }
- void print(ostream &o) const override {
- o << "mon_health( service " << get_service_type()
- << " op " << get_service_op_name()
- << " e " << get_epoch() << " r " << get_round()
- << " )";
- }
-
- int get_service_type() const {
- return service_type;
- }
-
- int get_service_op() {
- return service_op;
- }
-
- void decode_payload() override {
- bufferlist::iterator p = payload.begin();
- service_decode(p);
- ::decode(service_type, p);
- ::decode(service_op, p);
- ::decode(data_stats, p);
- }
-
- void encode_payload(uint64_t features) override {
- service_encode();
- ::encode(service_type, payload);
- ::encode(service_op, payload);
- ::encode(data_stats, payload);
- }
-
-};
-
-#endif /* CEPH_MMON_HEALTH_H */
AuthMonitor.cc
Elector.cc
HealthMonitor.cc
- OldHealthMonitor.cc
- DataHealthService.cc
PGMonitor.cc
PGMap.cc
ConfigKeyService.cc
+++ /dev/null
-// -*- 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) 2013 Inktank, 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.
- *
- */
-#include "include/memory.h"
-#include <errno.h>
-#include <map>
-#include <list>
-#include <string>
-#include <sstream>
-
-#include "acconfig.h"
-
-#ifdef HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
-
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#include "messages/MMonHealth.h"
-#include "include/assert.h"
-#include "common/Formatter.h"
-#include "common/errno.h"
-
-#include "mon/Monitor.h"
-#include "mon/DataHealthService.h"
-
-#define dout_subsys ceph_subsys_mon
-#undef dout_prefix
-#define dout_prefix _prefix(_dout, mon, this)
-static ostream& _prefix(std::ostream *_dout, const Monitor *mon,
- const DataHealthService *svc) {
- assert(mon != NULL);
- assert(svc != NULL);
- return *_dout << "mon." << mon->name << "@" << mon->rank
- << "(" << mon->get_state_name() << ")." << svc->get_name()
- << "(" << svc->get_epoch() << ") ";
-}
-
-void DataHealthService::start_epoch()
-{
- dout(10) << __func__ << " epoch " << get_epoch() << dendl;
- // we are not bound by election epochs, but we should clear the stats
- // everytime an election is triggerd. As far as we know, a monitor might
- // have been running out of disk space and someone fixed it. We don't want
- // to hold the cluster back, even confusing the user, due to some possibly
- // outdated stats.
- stats.clear();
- last_warned_percent = 0;
-}
-
-int DataHealthService::update_store_stats(DataStats &ours)
-{
- map<string,uint64_t> extra;
- uint64_t store_size = mon->store->get_estimated_size(extra);
- assert(store_size > 0);
-
- ours.store_stats.bytes_total = store_size;
- ours.store_stats.bytes_sst = extra["sst"];
- ours.store_stats.bytes_log = extra["log"];
- ours.store_stats.bytes_misc = extra["misc"];
- ours.last_update = ceph_clock_now();
-
- return 0;
-}
-
-
-int DataHealthService::update_stats()
-{
- entity_inst_t our_inst = mon->messenger->get_myinst();
- DataStats& ours = stats[our_inst];
-
- int err = get_fs_stats(ours.fs_stats, g_conf->mon_data.c_str());
- if (err < 0) {
- derr << __func__ << " get_fs_stats error: " << cpp_strerror(err) << dendl;
- return err;
- }
- dout(0) << __func__ << " avail " << ours.fs_stats.avail_percent << "%"
- << " total " << prettybyte_t(ours.fs_stats.byte_total)
- << ", used " << prettybyte_t(ours.fs_stats.byte_used)
- << ", avail " << prettybyte_t(ours.fs_stats.byte_avail) << dendl;
- ours.last_update = ceph_clock_now();
-
- return update_store_stats(ours);
-}
-
-void DataHealthService::share_stats()
-{
- dout(10) << __func__ << dendl;
- if (!in_quorum())
- return;
-
- assert(!stats.empty());
- entity_inst_t our_inst = mon->messenger->get_myinst();
- assert(stats.count(our_inst) > 0);
- DataStats &ours = stats[our_inst];
- const set<int>& quorum = mon->get_quorum();
- for (set<int>::const_iterator it = quorum.begin();
- it != quorum.end(); ++it) {
- if (mon->monmap->get_name(*it) == mon->name)
- continue;
- entity_inst_t inst = mon->monmap->get_inst(*it);
- MMonHealth *m = new MMonHealth(HealthService::SERVICE_HEALTH_DATA,
- MMonHealth::OP_TELL);
- m->data_stats = ours;
- dout(20) << __func__ << " send " << *m << " to " << inst << dendl;
- mon->messenger->send_message(m, inst);
- }
-}
-
-void DataHealthService::service_tick()
-{
- dout(10) << __func__ << dendl;
-
- int err = update_stats();
- if (err < 0) {
- derr << "something went wrong obtaining our disk stats: "
- << cpp_strerror(err) << dendl;
- force_shutdown();
- return;
- }
- if (in_quorum())
- share_stats();
-
- DataStats &ours = stats[mon->messenger->get_myinst()];
-
- if (ours.fs_stats.avail_percent <= g_conf->mon_data_avail_crit) {
- derr << "reached critical levels of available space on local monitor storage"
- << " -- shutdown!" << dendl;
- force_shutdown();
- return;
- }
-
- // we must backoff these warnings, and track how much data is being
- // consumed in-between reports to assess if it's worth to log this info,
- // otherwise we may very well contribute to the consumption of the
- // already low available disk space.
- if (ours.fs_stats.avail_percent <= g_conf->mon_data_avail_warn) {
- if (ours.fs_stats.avail_percent != last_warned_percent)
- mon->clog->warn()
- << "reached concerning levels of available space on local monitor storage"
- << " (" << ours.fs_stats.avail_percent << "% free)";
- last_warned_percent = ours.fs_stats.avail_percent;
- } else {
- last_warned_percent = 0;
- }
-}
-
-void DataHealthService::handle_tell(MonOpRequestRef op)
-{
- op->mark_event("datahealth:handle_tell");
- MMonHealth *m = static_cast<MMonHealth*>(op->get_req());
- dout(10) << __func__ << " " << *m << dendl;
- assert(m->get_service_op() == MMonHealth::OP_TELL);
-
- stats[m->get_source_inst()] = m->data_stats;
-}
-
-bool DataHealthService::service_dispatch_op(MonOpRequestRef op)
-{
- op->mark_event("datahealth:service_dispatch_op");
- MMonHealth *m = static_cast<MMonHealth*>(op->get_req());
- dout(10) << __func__ << " " << *m << dendl;
- assert(m->get_service_type() == get_type());
- if (!in_quorum()) {
- dout(1) << __func__ << " not in quorum -- drop message" << dendl;
- return false;
- }
-
- switch (m->service_op) {
- case MMonHealth::OP_TELL:
- // someone is telling us their stats
- handle_tell(op);
- break;
- default:
- dout(0) << __func__ << " unknown op " << m->service_op << dendl;
- assert(0 == "Unknown service op");
- break;
- }
- return true;
-}
+++ /dev/null
-// -*- 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) 2013 Inktank, 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.
- *
- */
-#ifndef CEPH_MON_DATA_HEALTH_SERVICE_H
-#define CEPH_MON_DATA_HEALTH_SERVICE_H
-
-#include <errno.h>
-
-#include "include/types.h"
-#include "mon/mon_types.h"
-#include "mon/HealthService.h"
-#include "common/config.h"
-#include "global/signal_handler.h"
-
-struct MMonHealth;
-namespace ceph { class Formatter; }
-
-
-class DataHealthService :
- public HealthService
-{
- map<entity_inst_t,DataStats> stats;
- int last_warned_percent;
-
- void handle_tell(MonOpRequestRef op);
- int update_store_stats(DataStats &ours);
- int update_stats();
- void share_stats();
-
- void force_shutdown() {
- generic_dout(0) << "** Shutdown via Data Health Service **" << dendl;
- queue_async_signal(SIGINT);
- }
-
-protected:
- void service_tick() override;
- bool service_dispatch_op(MonOpRequestRef op) override;
- void service_shutdown() override { }
-
- void start_epoch() override;
- void finish_epoch() override { }
- void cleanup() override { }
-
-public:
- DataHealthService(Monitor *m) :
- HealthService(m),
- last_warned_percent(0)
- {
- set_update_period(g_conf->mon_health_data_update_interval);
- }
- ~DataHealthService() override { }
-
- void init() override {
- generic_dout(20) << "data_health " << __func__ << dendl;
- start_tick();
- }
-
- int get_type() override {
- return HealthService::SERVICE_HEALTH_DATA;
- }
-
- string get_name() const override {
- return "data_health";
- }
-};
-
-#endif /* CEPH_MON_DATA_HEALTH_SERVICE_H */
#include "mon/Monitor.h"
#include "mon/HealthService.h"
#include "mon/HealthMonitor.h"
-#include "mon/DataHealthService.h"
-#include "messages/MMonHealth.h"
#include "messages/MMonHealthChecks.h"
#include "common/Formatter.h"
dout(7) << "prepare_update " << *m
<< " from " << m->get_orig_source_inst() << dendl;
switch (m->get_type()) {
- case MSG_MON_HEALTH:
- {
- MMonHealth *hm = static_cast<MMonHealth*>(op->get_req());
- int service_type = hm->get_service_type();
- if (services.count(service_type) == 0) {
- dout(1) << __func__ << " service type " << service_type
- << " not registered -- drop message!" << dendl;
- return false;
- }
- return services[service_type]->service_dispatch(op);
- }
case MSG_MON_HEALTH_CHECKS:
return prepare_health_checks(op);
default:
//forward declaration
namespace ceph { class Formatter; }
-class HealthService;
class HealthMonitor : public PaxosService
{
- map<int,HealthService*> services;
version_t version = 0;
map<int,health_check_map_t> quorum_checks; // for each quorum member
health_check_map_t leader_checks; // leader only
public:
HealthMonitor(Monitor *m, Paxos *p, const string& service_name);
- ~HealthMonitor() override {
- assert(services.empty());
- }
/**
* @defgroup HealthMonitor_Inherited_h Inherited abstract methods
#include "mon/Monitor.h"
#include "mon/QuorumService.h"
-#include "messages/MMonHealth.h"
-
#include "common/config.h"
struct HealthService : public QuorumService
#include "messages/MGenericMessage.h"
#include "messages/MMonCommand.h"
#include "messages/MMonCommandAck.h"
-#include "messages/MMonHealth.h"
#include "messages/MMonMetadata.h"
#include "messages/MMonSync.h"
#include "messages/MMonScrub.h"
#include "MgrMonitor.h"
#include "MgrStatMonitor.h"
#include "mon/QuorumService.h"
-#include "mon/OldHealthMonitor.h"
#include "mon/HealthMonitor.h"
#include "mon/ConfigKeyService.h"
#include "common/config.h"
paxos_service[PAXOS_MGRSTAT] = new MgrStatMonitor(this, paxos, "mgrstat");
paxos_service[PAXOS_HEALTH] = new HealthMonitor(this, paxos, "health");
- health_monitor = new OldHealthMonitor(this);
config_key_service = new ConfigKeyService(this, paxos);
mon_caps = new MonCap();
{
for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p)
delete *p;
- delete health_monitor;
delete config_key_service;
delete paxos;
assert(session_map.sessions.empty());
dout(10) << "sync_last_committed_floor " << sync_last_committed_floor << dendl;
init_paxos();
- health_monitor->init();
if (is_keyring_required()) {
// we need to bootstrap authentication keys so we can form an
paxos->shutdown();
for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p)
(*p)->shutdown();
- health_monitor->shutdown();
finish_contexts(g_ceph_context, waitfor_quorum, -ECANCELED);
finish_contexts(g_ceph_context, maybe_wait_for_quorum, -ECANCELED);
for (vector<PaxosService*>::iterator p = paxos_service.begin(); p != paxos_service.end(); ++p)
(*p)->restart();
- health_monitor->finish();
}
// round without agreeing on who the participants are.
monmon()->election_finished();
_finish_svc_election();
- health_monitor->start(epoch);
logger->inc(l_mon_election_win);
paxos->peon_init();
_finish_svc_election();
- health_monitor->start(epoch);
logger->inc(l_mon_election_lose);
handle_timecheck(op);
break;
- case MSG_MON_HEALTH:
- health_monitor->dispatch(op);
- break;
-
case MSG_MON_HEALTH_CHECKS:
op->set_type_service();
paxos_service[PAXOS_HEALTH]->dispatch(op);
friend class LogMonitor;
friend class ConfigKeyService;
- QuorumService *health_monitor;
QuorumService *config_key_service;
// -- sessions --
+++ /dev/null
-// -*- 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) 2013 Inktank, 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.
- *
- */
-
-#include <sstream>
-#include <stdlib.h>
-#include <limits.h>
-
-// #include <boost/intrusive_ptr.hpp>
-// Because intusive_ptr clobbers our assert...
-#include "include/assert.h"
-
-#include "mon/Monitor.h"
-#include "mon/HealthService.h"
-#include "mon/OldHealthMonitor.h"
-#include "mon/DataHealthService.h"
-
-#include "messages/MMonHealth.h"
-#include "common/Formatter.h"
-// #include "common/config.h"
-
-#define dout_subsys ceph_subsys_mon
-#undef dout_prefix
-#define dout_prefix _prefix(_dout, mon, this)
-static ostream& _prefix(std::ostream *_dout, const Monitor *mon,
- const OldHealthMonitor *hmon) {
- return *_dout << "mon." << mon->name << "@" << mon->rank
- << "(" << mon->get_state_name() << ")." << hmon->get_name()
- << "(" << hmon->get_epoch() << ") ";
-}
-
-void OldHealthMonitor::init()
-{
- dout(10) << __func__ << dendl;
- assert(services.empty());
- services[HealthService::SERVICE_HEALTH_DATA] = new DataHealthService(mon);
-
- for (map<int,HealthService*>::iterator it = services.begin();
- it != services.end();
- ++it) {
- it->second->init();
- }
-}
-
-bool OldHealthMonitor::service_dispatch(MonOpRequestRef op)
-{
- assert(op->get_req()->get_type() == MSG_MON_HEALTH);
- MMonHealth *hm = static_cast<MMonHealth*>(op->get_req());
- int service_type = hm->get_service_type();
- if (services.count(service_type) == 0) {
- dout(1) << __func__ << " service type " << service_type
- << " not registered -- drop message!" << dendl;
- return false;
- }
- return services[service_type]->service_dispatch(op);
-}
-
-void OldHealthMonitor::start_epoch() {
- epoch_t epoch = get_epoch();
- for (map<int,HealthService*>::iterator it = services.begin();
- it != services.end(); ++it) {
- it->second->start(epoch);
- }
-}
-
-void OldHealthMonitor::finish_epoch() {
- generic_dout(20) << "OldHealthMonitor::finish_epoch()" << dendl;
- for (map<int,HealthService*>::iterator it = services.begin();
- it != services.end(); ++it) {
- assert(it->second != NULL);
- it->second->finish();
- }
-}
-
-void OldHealthMonitor::service_shutdown()
-{
- dout(0) << "OldHealthMonitor::service_shutdown "
- << services.size() << " services" << dendl;
- for (map<int,HealthService*>::iterator it = services.begin();
- it != services.end();
- ++it) {
- it->second->shutdown();
- delete it->second;
- }
- services.clear();
-}
-
+++ /dev/null
-// -*- 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) 2013 Inktank, 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.
- *
- */
-#ifndef CEPH_MON_OLDHEALTHMONITOR_H
-#define CEPH_MON_OLDHEALTHMONITOR_H
-
-#include "mon/QuorumService.h"
-
-//forward declaration
-namespace ceph { class Formatter; }
-class HealthService;
-
-class OldHealthMonitor : public QuorumService
-{
- map<int,HealthService*> services;
-
-protected:
- void service_shutdown() override;
-
-public:
- OldHealthMonitor(Monitor *m) : QuorumService(m) { }
- ~OldHealthMonitor() override {
- assert(services.empty());
- }
-
-
- /**
- * @defgroup OldHealthMonitor_Inherited_h Inherited abstract methods
- * @{
- */
- void init() override;
- bool service_dispatch(MonOpRequestRef op) override;
-
- void start_epoch() override;
-
- void finish_epoch() override;
-
- void cleanup() override { }
- void service_tick() override { }
-
- int get_type() override {
- return QuorumService::SERVICE_HEALTH;
- }
-
- string get_name() const override {
- return "health";
- }
-
- /**
- * @} // OldHealthMonitor_Inherited_h
- */
-};
-
-#endif
#include "messages/MMonGetMap.h"
#include "messages/MMonGetVersion.h"
#include "messages/MMonGetVersionReply.h"
-#include "messages/MMonHealth.h"
#include "messages/MMonHealthChecks.h"
#include "messages/MMonMetadata.h"
#include "messages/MDataPing.h"
m = new MTimeCheck();
break;
- case MSG_MON_HEALTH:
- m = new MMonHealth();
- break;
-
case MSG_MON_HEALTH_CHECKS:
m = new MMonHealthChecks();
break;
// *** generic ***
#define MSG_TIMECHECK 0x600
-#define MSG_MON_HEALTH 0x601
+//#define MSG_MON_HEALTH 0x601 // remove post-luminous
// *** Message::encode() crcflags bits ***
#define MSG_CRC_DATA (1 << 0)