X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fmon%2FOldHealthMonitor.cc;fp=src%2Fceph%2Fsrc%2Fmon%2FOldHealthMonitor.cc;h=d7264a7ee26bd00a597b3e12a94427c5dfd5cfe9;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/mon/OldHealthMonitor.cc b/src/ceph/src/mon/OldHealthMonitor.cc new file mode 100644 index 0000000..d7264a7 --- /dev/null +++ b/src/ceph/src/mon/OldHealthMonitor.cc @@ -0,0 +1,107 @@ +// -*- 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 +#include + +// #include +// 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::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(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::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::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::iterator it = services.begin(); + it != services.end(); + ++it) { + it->second->shutdown(); + delete it->second; + } + services.clear(); +} + +void OldHealthMonitor::get_health( + list >& summary, + list > *detail) +{ + for (map::iterator it = services.begin(); + it != services.end(); + ++it) { + it->second->get_health(summary, detail); + } +}