HeartbeatMap.cc
LogClient.cc
LogEntry.cc
+ ostream_temp.cc
Mutex.cc
OutputDataSocket.cc
PluginRegistry.cc
{
}
-LogClientTemp::LogClientTemp(clog_type type_, LogChannel &parent_)
- : type(type_), parent(parent_)
-{
-}
-
-LogClientTemp::LogClientTemp(const LogClientTemp &rhs)
- : type(rhs.type), parent(rhs.parent)
-{
- // don't want to-- nor can we-- copy the ostringstream
-}
-
-LogClientTemp::~LogClientTemp()
-{
- if (ss.peek() != EOF)
- parent.do_log(type, ss);
-}
-
void LogChannel::update_config(map<string,string> &log_to_monitors,
map<string,string> &log_to_syslog,
map<string,string> &log_channels,
#include <atomic>
#include "common/LogEntry.h"
+#include "common/ostream_temp.h"
#include "common/ceph_mutex.h"
#include "include/health.h"
uuid_d &fsid,
std::string &host);
-class LogClientTemp
-{
-public:
- LogClientTemp(clog_type type_, LogChannel &parent_);
- LogClientTemp(const LogClientTemp &rhs);
- ~LogClientTemp();
-
- template<typename T>
- std::ostream& operator<<(const T& rhs)
- {
- return ss << rhs;
- }
-
-private:
- clog_type type;
- LogChannel &parent;
- std::stringstream ss;
-};
-
/** Manage where we output to and at which priority
*
* Not to be confused with the LogClient, which is the almighty coordinator
* Past queueing the LogEntry, the LogChannel is done with the whole thing.
* LogClient will deal with sending and handling of LogEntries.
*/
-class LogChannel
+class LogChannel : public OstreamTemp::OstreamTempSink
{
public:
const std::string &facility,
const std::string &prio);
- LogClientTemp debug() {
- return LogClientTemp(CLOG_DEBUG, *this);
+ OstreamTemp debug() {
+ return OstreamTemp(CLOG_DEBUG, this);
}
void debug(std::stringstream &s) {
do_log(CLOG_DEBUG, s);
* Convenience function mapping health status to
* the appropriate cluster log severity.
*/
- LogClientTemp health(health_status_t health) {
+ OstreamTemp health(health_status_t health) {
switch(health) {
case HEALTH_OK:
return info();
ceph_abort();
}
}
- LogClientTemp info() {
- return LogClientTemp(CLOG_INFO, *this);
+ OstreamTemp info() {
+ return OstreamTemp(CLOG_INFO, this);
}
void info(std::stringstream &s) {
do_log(CLOG_INFO, s);
}
- LogClientTemp warn() {
- return LogClientTemp(CLOG_WARN, *this);
+ OstreamTemp warn() {
+ return OstreamTemp(CLOG_WARN, this);
}
void warn(std::stringstream &s) {
do_log(CLOG_WARN, s);
}
- LogClientTemp error() {
- return LogClientTemp(CLOG_ERROR, *this);
+ OstreamTemp error() {
+ return OstreamTemp(CLOG_ERROR, this);
}
void error(std::stringstream &s) {
do_log(CLOG_ERROR, s);
}
- LogClientTemp sec() {
- return LogClientTemp(CLOG_SEC, *this);
+ OstreamTemp sec() {
+ return OstreamTemp(CLOG_SEC, this);
}
void sec(std::stringstream &s) {
do_log(CLOG_SEC, s);
bool log_to_monitors;
std::shared_ptr<ceph::logging::Graylog> graylog;
-
- friend class LogClientTemp;
};
typedef LogChannel::Ref LogChannelRef;
#include "include/utime.h"
#include "msg/msg_types.h"
#include "common/entity_name.h"
+#include "ostream_temp.h"
namespace ceph {
class Formatter;
}
-typedef enum {
- CLOG_DEBUG = 0,
- CLOG_INFO = 1,
- CLOG_SEC = 2,
- CLOG_WARN = 3,
- CLOG_ERROR = 4,
- CLOG_UNKNOWN = -1,
-} clog_type;
-
static const std::string CLOG_CHANNEL_NONE = "none";
static const std::string CLOG_CHANNEL_DEFAULT = "cluster";
static const std::string CLOG_CHANNEL_CLUSTER = "cluster";
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "common/ostream_temp.h"
+
+OstreamTemp::OstreamTemp(clog_type type_, OstreamTempSink *parent_)
+ : type(type_), parent(parent_)
+{
+}
+
+OstreamTemp::~OstreamTemp()
+{
+ if (ss.peek() != EOF && parent)
+ parent->do_log(type, ss);
+}
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <sstream>
+
+typedef enum {
+ CLOG_DEBUG = 0,
+ CLOG_INFO = 1,
+ CLOG_SEC = 2,
+ CLOG_WARN = 3,
+ CLOG_ERROR = 4,
+ CLOG_UNKNOWN = -1,
+} clog_type;
+
+class OstreamTemp
+{
+public:
+ class OstreamTempSink {
+ public:
+ virtual void do_log(clog_type prio, std::stringstream& ss) = 0;
+ virtual ~OstreamTempSink() {}
+ };
+ OstreamTemp(clog_type type_, OstreamTempSink *parent_);
+ OstreamTemp(OstreamTemp &&rhs) = default;
+ ~OstreamTemp();
+
+ template<typename T>
+ std::ostream& operator<<(const T& rhs)
+ {
+ return ss << rhs;
+ }
+
+private:
+ clog_type type;
+ OstreamTempSink *parent;
+ std::stringstream ss;
+};
return osd->get_superblock().oldest_map;
}
-LogChannel &PG::get_clog() {
- return *(osd->clog);
+OstreamTemp PG::get_clog_info() {
+ return osd->clog->info();
+}
+
+OstreamTemp PG::get_clog_debug() {
+ return osd->clog->debug();
+}
+
+OstreamTemp PG::get_clog_error() {
+ return osd->clog->error();
}
void PG::schedule_event_after(
void clear_primary_state() override;
epoch_t oldest_stored_osdmap() override;
- LogChannel &get_clog() override;
+ OstreamTemp &get_clog_error() override;
+ OstreamTemp &get_clog_info() override;
+ OstreamTemp &get_clog_debug() override;
void schedule_event_after(
PGPeeringEventRef event,
#include "common/LogClient.h"
#include <string>
#include "PGTransaction.h"
+#include "common/ostream_temp.h"
namespace Scrub {
class Store;
virtual ceph_tid_t get_tid() = 0;
- virtual LogClientTemp clog_error() = 0;
- virtual LogClientTemp clog_warn() = 0;
+ virtual OstreamTemp clog_error() = 0;
+ virtual OstreamTemp clog_warn() = 0;
virtual bool check_failsafe_full() = 0;
pl->oldest_stored_osdmap());
if (rpib.first >= rpib.second) {
if (!past_intervals.empty()) {
- pl->get_clog().error() << info.pgid << " required past_interval bounds are"
+ pl->get_clog_error() << info.pgid << " required past_interval bounds are"
<< " empty [" << rpib << ") but past_intervals is not: "
<< past_intervals;
derr << info.pgid << " required past_interval bounds are"
}
} else {
if (past_intervals.empty()) {
- pl->get_clog().error() << info.pgid << " required past_interval bounds are"
+ pl->get_clog_error() << info.pgid << " required past_interval bounds are"
<< " not empty [" << rpib << ") but past_intervals "
<< past_intervals << " is empty";
derr << info.pgid << " required past_interval bounds are"
auto apib = past_intervals.get_bounds();
if (apib.first > rpib.first) {
- pl->get_clog().error() << info.pgid << " past_intervals [" << apib
+ pl->get_clog_error() << info.pgid << " past_intervals [" << apib
<< ") start interval does not contain the required"
<< " bound [" << rpib << ") start";
derr << info.pgid << " past_intervals [" << apib
ceph_abort_msg("past_interval start interval mismatch");
}
if (apib.second != rpib.second) {
- pl->get_clog().error() << info.pgid << " past_interal bound [" << apib
+ pl->get_clog_error() << info.pgid << " past_interal bound [" << apib
<< ") end does not match required [" << rpib
<< ") end";
derr << info.pgid << " past_interal bound [" << apib
void PeeringState::log_weirdness()
{
if (pg_log.get_tail() != info.log_tail)
- pl->get_clog().error() << info.pgid
+ pl->get_clog_error() << info.pgid
<< " info mismatch, log.tail " << pg_log.get_tail()
<< " != info.log_tail " << info.log_tail;
if (pg_log.get_head() != info.last_update)
- pl->get_clog().error() << info.pgid
+ pl->get_clog_error() << info.pgid
<< " info mismatch, log.head " << pg_log.get_head()
<< " != info.last_update " << info.last_update;
if (!pg_log.get_log().empty()) {
// sloppy check
if ((pg_log.get_log().log.begin()->version <= pg_log.get_tail()))
- pl->get_clog().error() << info.pgid
+ pl->get_clog_error() << info.pgid
<< " log bound mismatch, info (tail,head] ("
<< pg_log.get_tail() << ","
<< pg_log.get_head() << "]"
}
if (pg_log.get_log().caller_ops.size() > pg_log.get_log().log.size()) {
- pl->get_clog().error() << info.pgid
+ pl->get_clog_error() << info.pgid
<< " caller_ops.size "
<< pg_log.get_log().caller_ops.size()
<< " > log size " << pg_log.get_log().log.size();
if (pi.last_update == info.last_update && !force_restart_backfill) {
// empty log
if (!pi.last_backfill.is_max())
- pl->get_clog().info() << info.pgid << " continuing backfill to osd."
+ pl->get_clog_info() << info.pgid << " continuing backfill to osd."
<< peer
<< " from (" << pi.log_tail << "," << pi.last_update
<< "] " << pi.last_backfill
* behind.
*/
// backfill
- pl->get_clog().debug() << info.pgid << " starting backfill to osd." << peer
+ pl->get_clog_debug() << info.pgid << " starting backfill to osd." << peer
<< " from (" << pi.log_tail << "," << pi.last_update
<< "] " << pi.last_backfill
<< " to " << info.last_update;
psdout(10) << " sending info+missing+log since " << query.since
<< dendl;
if (query.since != eversion_t() && query.since < pg_log.get_tail()) {
- pl->get_clog().error() << info.pgid << " got broken pg_query_t::LOG since "
+ pl->get_clog_error() << info.pgid << " got broken pg_query_t::LOG since "
<< query.since
<< " when my log.tail is " << pg_log.get_tail()
<< ", sending full log instead";
if (unfound > 0 &&
ps->all_unfound_are_queried_or_lost(ps->get_osdmap())) {
if (ps->cct->_conf->osd_auto_mark_unfound_lost) {
- pl->get_clog().error() << context< PeeringMachine >().spgid.pgid << " has " << unfound
+ pl->get_clog_error() << context< PeeringMachine >().spgid.pgid << " has " << unfound
<< " objects unfound and apparently lost, would automatically "
<< "mark these objects lost but this feature is not yet implemented "
<< "(osd_auto_mark_unfound_lost)";
} else
- pl->get_clog().error() << context< PeeringMachine >().spgid.pgid << " has "
+ pl->get_clog_error() << context< PeeringMachine >().spgid.pgid << " has "
<< unfound << " objects unfound and apparently lost";
}
#include "os/ObjectStore.h"
#include "OSDMap.h"
#include "MissingLoc.h"
-#include "common/LogClient.h"
#include "osd/osd_perf_counters.h"
+#include "common/ostream_temp.h"
struct PGPool {
CephContext* cct;
const char *state_name, utime_t enter_time,
uint64_t events, utime_t event_dur) = 0;
virtual void dump_recovery_info(Formatter *f) const = 0;
- virtual LogChannel &get_clog() = 0;
+
+ virtual OstreamTemp get_clog_info() = 0;
+ virtual OstreamTemp get_clog_error() = 0;
+ virtual OstreamTemp get_clog_debug() = 0;
virtual ~PeeringListener() {}
};
ceph_tid_t get_tid() override { return osd->get_tid(); }
- LogClientTemp clog_error() override { return osd->clog->error(); }
- LogClientTemp clog_warn() override { return osd->clog->warn(); }
+ OstreamTemp clog_error() override { return osd->clog->error(); }
+ OstreamTemp clog_warn() override { return osd->clog->warn(); }
struct watch_disconnect_t {
uint64_t cookie;