Skip to content

Commit

Permalink
Merge pull request #7523 from tchaikov/wip-fix-cmake
Browse files Browse the repository at this point in the history
cmake: fix the build of tests
  • Loading branch information
alimaredia committed Feb 11, 2016
2 parents 6adb694 + 075e595 commit aa6d0a9
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 60 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Expand Up @@ -7,6 +7,15 @@ if (NOT (CMAKE_MAJOR_VERSION LESS 3))
# Tweak policies (this one disables "missing" dependency warning)
cmake_policy(SET CMP0046 OLD)
endif(NOT (CMAKE_MAJOR_VERSION LESS 3))
# we use LINK_PRIVATE keyword instead of PRIVATE, but do not specify the LINK_PUBLIC
# for target_link_libraries() command when PUBLIC should be used instead, it's just
# for backward compatibility with cmake 2.8.11.
if (POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif (POLICY CMP0022)
if (POLICY CMP0023)
cmake_policy(SET CMP0023 OLD)
endif (POLICY CMP0023)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")

Expand Down
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Expand Up @@ -76,8 +76,7 @@ else()
endif()


set(EXTRALIBS uuid rt dl
${Boost_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ${ATOMIC_OPS_LIBRARIES})
set(EXTRALIBS uuid rt dl ${ATOMIC_OPS_LIBRARIES})

if(${WITH_PROFILER})
list(APPEND EXTRALIBS profiler)
Expand Down
9 changes: 4 additions & 5 deletions src/common/Graylog.cc
Expand Up @@ -5,16 +5,15 @@

#include <iostream>
#include <sstream>
#include <memory>

#include <arpa/inet.h>

#include <boost/asio.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/zlib.hpp>
#include <boost/lexical_cast.hpp>

#include "common/Formatter.h"
#include "common/LogEntry.h"
#include "log/Entry.h"
#include "log/SubsystemMap.h"
#include "include/uuid.h"

namespace ceph {
Expand Down Expand Up @@ -71,7 +70,7 @@ void Graylog::set_hostname(const std::string& host)
m_hostname = host;
}

void Graylog::set_fsid(uuid_d fsid)
void Graylog::set_fsid(const uuid_d& fsid)
{
std::vector<char> buf(40);
fsid.print(&buf[0]);
Expand Down
15 changes: 10 additions & 5 deletions src/common/Graylog.h
Expand Up @@ -7,19 +7,24 @@

#include <memory>

#include <boost/thread/mutex.hpp>
#include <boost/asio.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/zlib.hpp>

#include "log/Entry.h"
#include "log/SubsystemMap.h"
#include "common/LogEntry.h"
#include "include/memory.h"

struct uuid_d;
class LogEntry;

namespace ceph {

class Formatter;

namespace log {

struct Entry;
class SubsystemMap;

// Graylog logging backend: Convert log datastructures (LogEntry, Entry) to
// GELF (http://www.graylog2.org/resources/gelf/specification) and send it
// to a GELF UDP receiver
Expand All @@ -45,7 +50,7 @@ class Graylog
virtual ~Graylog();

void set_hostname(const std::string& host);
void set_fsid(uuid_d fsid);
void set_fsid(const uuid_d& fsid);

void set_destination(const std::string& host, int port);

Expand Down
4 changes: 4 additions & 0 deletions src/common/LogClient.cc
Expand Up @@ -16,6 +16,7 @@

#include "include/types.h"
#include "include/str_map.h"
#include "include/uuid.h"

#include "msg/Messenger.h"
#include "msg/Message.h"
Expand All @@ -34,6 +35,9 @@
#include <sys/mount.h>
#endif // DARWIN

#include "common/Graylog.h"
// wipe the assert() introduced by boost headers included by Graylog.h
#include "include/assert.h"
#include "common/LogClient.h"

#include "common/config.h"
Expand Down
11 changes: 8 additions & 3 deletions src/common/LogClient.h
Expand Up @@ -17,8 +17,6 @@

#include "common/LogEntry.h"
#include "common/Mutex.h"
#include "include/uuid.h"
#include "common/Graylog.h"

#include <iosfwd>
#include <sstream>
Expand All @@ -29,10 +27,17 @@ class MLogAck;
class Messenger;
class MonMap;
class Message;
struct uuid_d;
struct Connection;

class LogChannel;

namespace ceph {
namespace log {
class Graylog;
}
}

int parse_log_client_options(CephContext *cct,
map<string,string> &log_to_monitors,
map<string,string> &log_to_syslog,
Expand Down Expand Up @@ -177,7 +182,7 @@ class LogChannel
std::string syslog_facility;
bool log_to_syslog;
bool log_to_monitors;
ceph::log::Graylog::Ref graylog;
shared_ptr<ceph::log::Graylog> graylog;


friend class LogClientTemp;
Expand Down
1 change: 1 addition & 0 deletions src/common/ceph_context.cc
Expand Up @@ -27,6 +27,7 @@
#include "common/errno.h"
#include "common/lockdep.h"
#include "common/Formatter.h"
#include "common/Graylog.h"
#include "log/Log.h"
#include "auth/Crypto.h"
#include "include/str_list.h"
Expand Down
1 change: 1 addition & 0 deletions src/log/Log.cc
Expand Up @@ -17,6 +17,7 @@
#include "common/errno.h"
#include "common/safe_io.h"
#include "common/Clock.h"
#include "common/Graylog.h"
#include "common/valgrind.h"
#include "common/Formatter.h"
#include "include/assert.h"
Expand Down
9 changes: 4 additions & 5 deletions src/log/Log.h
Expand Up @@ -6,18 +6,17 @@

#include "common/Thread.h"

#include <assert.h>
#include <pthread.h>
#include <boost/asio.hpp>

#include "Entry.h"
#include "EntryQueue.h"
#include "SubsystemMap.h"
#include "common/Graylog.h"

namespace ceph {
namespace log {

class Graylog;

class Log : private Thread
{
Log **m_indirect_this;
Expand All @@ -42,7 +41,7 @@ class Log : private Thread
int m_stderr_log, m_stderr_crash;
int m_graylog_log, m_graylog_crash;

Graylog::Ref m_graylog;
shared_ptr<Graylog> m_graylog;

bool m_stop;

Expand Down Expand Up @@ -78,7 +77,7 @@ class Log : private Thread
void start_graylog();
void stop_graylog();

Graylog::Ref graylog() { return m_graylog; }
shared_ptr<Graylog> graylog() { return m_graylog; }

Entry *create_entry(int level, int subsys);
Entry *create_entry(int level, int subsys, size_t* expected_size);
Expand Down
27 changes: 27 additions & 0 deletions src/mon/LogMonitor.cc
Expand Up @@ -26,6 +26,7 @@
#include "messages/MLogAck.h"

#include "common/Timer.h"
#include "common/Graylog.h"

#include "osd/osd_types.h"
#include "common/errno.h"
Expand Down Expand Up @@ -743,6 +744,32 @@ bool LogMonitor::log_channel_info::do_log_to_syslog(const string &channel) {
return ret;
}

ceph::log::Graylog::Ref LogMonitor::log_channel_info::get_graylog(
const string &channel)
{
generic_dout(25) << __func__ << " for channel '"
<< channel << "'" << dendl;

if (graylogs.count(channel) == 0) {
ceph::log::Graylog::Ref graylog = ceph::log::Graylog::Ref(new ceph::log::Graylog("mon"));

graylog->set_fsid(g_conf->fsid);
graylog->set_hostname(g_conf->host);
graylog->set_destination(get_str_map_key(log_to_graylog_host, channel,
&CLOG_CONFIG_DEFAULT_KEY),
atoi(get_str_map_key(log_to_graylog_port, channel,
&CLOG_CONFIG_DEFAULT_KEY).c_str()));

graylogs[channel] = graylog;
generic_dout(20) << __func__ << " for channel '"
<< channel << "' to graylog host '"
<< log_to_graylog_host[channel] << ":"
<< log_to_graylog_port[channel]
<< "'" << dendl;
}
return graylogs[channel];
}

void LogMonitor::handle_conf_change(const struct md_config_t *conf,
const std::set<std::string> &changed)
{
Expand Down
33 changes: 8 additions & 25 deletions src/mon/LogMonitor.h
Expand Up @@ -25,12 +25,17 @@ using namespace std;

#include "common/LogEntry.h"
#include "messages/MLog.h"
#include "common/Graylog.h"

class MMonCommand;

static const string LOG_META_CHANNEL = "$channel";

namespace ceph {
namespace log {
class Graylog;
}
}

class LogMonitor : public PaxosService,
public md_config_obs_t {
private:
Expand All @@ -49,7 +54,7 @@ class LogMonitor : public PaxosService,
map<string,string> log_to_graylog_host;
map<string,string> log_to_graylog_port;

map<string, ceph::log::Graylog::Ref> graylogs;
map<string, shared_ptr<ceph::log::Graylog>> graylogs;
uuid_d fsid;
string host;

Expand Down Expand Up @@ -120,29 +125,7 @@ class LogMonitor : public PaxosService,
&CLOG_CONFIG_DEFAULT_KEY) == "true");
}

ceph::log::Graylog::Ref get_graylog(const string &channel) {
generic_dout(25) << __func__ << " for channel '"
<< channel << "'" << dendl;

if (graylogs.count(channel) == 0) {
ceph::log::Graylog::Ref graylog = ceph::log::Graylog::Ref(new ceph::log::Graylog("mon"));

graylog->set_fsid(g_conf->fsid);
graylog->set_hostname(g_conf->host);
graylog->set_destination(get_str_map_key(log_to_graylog_host, channel,
&CLOG_CONFIG_DEFAULT_KEY),
atoi(get_str_map_key(log_to_graylog_port, channel,
&CLOG_CONFIG_DEFAULT_KEY).c_str()));

graylogs[channel] = graylog;
generic_dout(20) << __func__ << " for channel '"
<< channel << "' to graylog host '"
<< log_to_graylog_host[channel] << ":"
<< log_to_graylog_port[channel]
<< "'" << dendl;
}
return graylogs[channel];
}
shared_ptr<ceph::log::Graylog> get_graylog(const string &channel);
} channels;

void update_log_channels();
Expand Down

0 comments on commit aa6d0a9

Please sign in to comment.