Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
fix(conan): build using conan-center works again
Browse files Browse the repository at this point in the history
* fix(json): json11 changed to nlohmann_json
* enh(conan): All our external packages come from the conan center
* fix(test/config): fix somes parser tests
* enh(influxdb/test): all tests works fine
* fix(tcp): warning removed in unittests compilation
* fix(bam): unittest could fail because of a missing loop test.
* fix(link): several link issues
* fix(stats): The center could segfault if the strand is not empty at destruction

Co-authored-by: centreonpm <pmargale@centreon.com>
  • Loading branch information
bouda1 and centreonpm authored May 10, 2021
1 parent b6e3a26 commit 888c7c9
Show file tree
Hide file tree
Showing 79 changed files with 828 additions and 735 deletions.
18 changes: 11 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# Changelog
## 21.04.2

## 21.04.1

`Date of the release`

### Build

Since the bintray closure, we could not build cbd. Dependencies have been moved
to the conan-center and the build is back.

### Bam

*meta-services*

Meta-services are removed from broker. This code was not used and could produce

## 21.04.1

`Date of the release`

### Enhancements

*Storage*

We optimize queries by removing useless join. A join with hosts table is not necessary in
certain queries.
We optimize queries by removing useless join. A join with hosts table is not
necessary in certain queries.

## 21.04.0

Expand Down
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_ID STREQ
message(FATAL_ERROR "You can build broker with g++ or clang++. CMake will exit.")
endif ()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=1")

# With ASIO DEBUGGING ENABLED
Expand Down Expand Up @@ -65,12 +65,11 @@ add_custom_target(table_max_size DEPENDS ${INC_DIR}/database/table_max_size.hh)
set_source_files_properties(${INC_DIR}/database/table_max_size.hh PROPERTIES GENERATED TRUE)

set(protobuf_MODULE_COMPATIBLE True)
find_package(json11 REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
find_package(asio REQUIRED)
find_package(protobuf REQUIRED)
find_package(protoc_installer REQUIRED)
find_package(Protobuf REQUIRED)
find_package(gRPC REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(c-ares REQUIRED)
Expand All @@ -79,16 +78,17 @@ find_package(mariadb-connector-c REQUIRED)

add_definitions(${spdlog_DEFINITIONS} ${mariadb-connector-c_DEFINITIONS})

include_directories(${json11_INCLUDE_DIRS})
include_directories(${nlohmann_json_INCLUDE_DIRS})
include_directories(${fmt_INCLUDE_DIRS})
include_directories(${spdlog_INCLUDE_DIRS})
include_directories(${asio_INCLUDE_DIRS})
include_directories(${protobuf_INCLUDE_DIRS})
include_directories(${absl_INCLUDE_DIRS})
include_directories(${gRPC_INCLUDE_DIRS})
include_directories(${ZLIB_INCLUDE_DIRS})
include_directories(${mariadb-connector-c_INCLUDE_DIRS}/mysql)
include_directories(${mariadb-connector-c_INCLUDE_DIRS})

link_directories(${json11_LIB_DIRS})
link_directories(${nlohmann_json_LIB_DIRS})
link_directories(${fmt_LIB_DIRS})
link_directories(${spdlog_LIB_DIRS})
link_directories(${protobuf_LIB_DIRS})
Expand All @@ -98,8 +98,7 @@ link_directories(${OpenSSL_LIB_DIRS})
link_directories(${ZLIB_LIB_DIRS})
link_directories(${mariadb-connector-c_LIB_DIRS})

message(STATUS "Using protobuf ${gRPC_VERSION}")
set(PROTOBUF_PREFIX "${protoc_installer_LIB_DIRS}/..")
set(PROTOBUF_PREFIX "${protobuf_LIB_DIRS}/..")
message(STATUS "${PROTOBUF_PREFIX}/bin/protoc")
set(GRPC_PREFIX "${gRPC_LIB_DIRS}/..")

Expand Down Expand Up @@ -574,23 +573,23 @@ set(LIBROKER_SOURCES
# Static libraries.
add_library(rokerbase STATIC ${LIBROKER_SOURCES})
set_target_properties(rokerbase PROPERTIES COMPILE_FLAGS "-fPIC")
target_link_libraries(rokerbase ${ZLIB_LIBRARIES} ${mariadb-connector-c_LIBS} pthread dl berpc)
target_link_libraries(rokerbase ${ZLIB_LIBRARIES} ${OpenSSL_LIBS} ${mariadb-connector-c_LIBS} pthread dl berpc)

add_library(roker STATIC
${SRC_DIR}/config/applier/init.cc
${SRC_DIR}/config/applier/logger.cc)
target_link_libraries(roker rokerbase dl ${c-ares_LIBS} ${gRPC_LIBS} ${absl_LIBS} grpc++_reflection)
target_link_libraries(roker rokerbase dl ${c-ares_LIBS} ${OpenSSL_LIBS} ${gRPC_LIBS} ${absl_LIBS} grpc++_reflection)

# Standalone binary.
set(DAEMON cbd)
add_executable(${DAEMON} ${SRC_DIR}/main.cc)

#Flags needed to include all symbols in binary.
target_link_libraries("${DAEMON}"
"-Wl,--whole-archive" grpc++_reflection rokerbase roker "-Wl,--no-whole-archive" ${json11_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${gRPC_LIBS} ${absl_LIBS} )
"-Wl,--whole-archive" grpc++_reflection rokerbase roker "-Wl,--no-whole-archive" ${nlohmann_json_LIBS} ${fmt_LIBS} ${spdlog_LIBS} ${gRPC_LIBS} ${absl_LIBS} pthread)

# Centreon Broker Watchdog
option(WITH_CBWD "Build centreon broker watchdong." ON)
option(WITH_CBWD "Build centreon broker watchdog." ON)
if (WITH_CBWD)
add_subdirectory(watchdog)
endif ()
Expand Down
2 changes: 1 addition & 1 deletion bam/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
## Copyright 2011-2016 Centreon
## Copyright 2011-2021 Centreon
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bam/inc/com/centreon/broker/bam/monitoring_stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class monitoring_stream : public io::stream {
int32_t stop() override;
void initialize();
bool read(std::shared_ptr<io::data>& d, time_t deadline) override;
void statistics(json11::Json::object& tree) const override;
void statistics(nlohmann::json& tree) const override;
void update() override final;
int write(std::shared_ptr<io::data> const& d) override;

Expand Down
2 changes: 1 addition & 1 deletion bam/inc/com/centreon/broker/bam/reporting_stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class reporting_stream : public io::stream {
int32_t flush() override;
int32_t stop() override;
bool read(std::shared_ptr<io::data>& d, time_t deadline) override;
void statistics(json11::Json::object& tree) const override;
void statistics(nlohmann::json& tree) const override;
int write(std::shared_ptr<io::data> const& d) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion bam/src/monitoring_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool monitoring_stream::read(std::shared_ptr<io::data>& d, time_t deadline) {
*
* @param[out] tree Output tree.
*/
void monitoring_stream::statistics(json11::Json::object& tree) const {
void monitoring_stream::statistics(nlohmann::json& tree) const {
std::lock_guard<std::mutex> lock(_statusm);
if (!_status.empty())
tree["status"] = _status;
Expand Down
2 changes: 1 addition & 1 deletion bam/src/reporting_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ bool reporting_stream::read(std::shared_ptr<io::data>& d, time_t deadline) {
*
* @param[out] tree Output tree.
*/
void reporting_stream::statistics(json11::Json::object& tree) const {
void reporting_stream::statistics(nlohmann::json& tree) const {
std::lock_guard<std::mutex> lock(_statusm);
if (!_status.empty())
tree["status"] = _status;
Expand Down
14 changes: 8 additions & 6 deletions bam/test/ba/kpi_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,10 @@ TEST_F(BamBA, KpiServiceImpactState) {
ASSERT_EQ(it->end_time, -1);
ASSERT_EQ(it->status, 2);
ASSERT_FALSE(it->in_downtime);
do {
++it;
} while (it->typ != test_visitor::test_event::kpi);
while (++it != events.end()) {
if (it->typ == test_visitor::test_event::kpi)
break;
}
}
}
}
Expand Down Expand Up @@ -335,9 +336,10 @@ TEST_F(BamBA, KpiServiceWorstState) {
ASSERT_EQ(it->end_time, -1);
ASSERT_EQ(it->status, 2);
ASSERT_FALSE(it->in_downtime);
do {
++it;
} while (it->typ != test_visitor::test_event::kpi);
while (++it != events.end()) {
if (it->typ == test_visitor::test_event::kpi)
break;
}
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[requires]
gtest/1.8.1@bincrafters/stable
gtest/cci.20210126
asio/1.18.1
fmt/7.1.2
spdlog/1.8.1
json11/e2e3a11@centreon/stable
openssl/1.1.1h
grpc/1.27.3@inexorgame/stable
mariadb-connector-c/3.1.10
fmt/7.1.3
spdlog/1.8.5
nlohmann_json/3.9.1
openssl/1.1.1k
protobuf/3.15.5
grpc/1.37.0
mariadb-connector-c/3.1.12
zlib/1.2.11

[generators]
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/bbdo/acceptor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class acceptor : public io::endpoint {
acceptor(const acceptor&) = delete;
acceptor& operator=(const acceptor&) = delete;
std::unique_ptr<io::stream> open() override;
void stats(json11::Json::object& tree) override;
void stats(nlohmann::json& tree) override;
bool is_one_peer_retention() const { return _one_peer_retention_mode; }

private:
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/bbdo/stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class stream : public io::stream {
const std::pair<std::string, std::string>& extensions =
std::make_pair("", ""));
void set_timeout(int timeout);
void statistics(json11::Json::object& tree) const override;
void statistics(nlohmann::json& tree) const override;
int write(std::shared_ptr<io::data> const& d) override;
void acknowledge_events(uint32_t events);
void send_event_acknowledgement();
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/compression/stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class stream : public io::stream {
int32_t stop() override;
bool read(std::shared_ptr<io::data>& d,
time_t deadline = (time_t)-1) override;
void statistics(json11::Json::object& tree) const override;
void statistics(nlohmann::json& tree) const override;
int write(std::shared_ptr<io::data> const& d) override;

private:
Expand Down
4 changes: 2 additions & 2 deletions core/inc/com/centreon/broker/config/endpoint.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define CCB_CONFIG_ENDPOINT_HH

#include <ctime>
#include <json11.hpp>
#include <nlohmann/json.hpp>
#include <list>
#include <map>
#include <set>
Expand Down Expand Up @@ -72,7 +72,7 @@ class endpoint {
std::string type;
std::set<std::string> write_filters;
bool cache_enabled;
json11::Json cfg;
nlohmann::json cfg;
};
} // namespace config

Expand Down
6 changes: 3 additions & 3 deletions core/inc/com/centreon/broker/config/parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef CCB_CONFIG_PARSER_HH
#define CCB_CONFIG_PARSER_HH

#include <json11.hpp>
#include <nlohmann/json.hpp>
#include <string>
#include "com/centreon/broker/config/state.hh"
#include "com/centreon/broker/namespace.hh"
Expand All @@ -44,8 +44,8 @@ class parser {
static bool parse_boolean(std::string const& value);

private:
void _parse_endpoint(json11::Json const& elem, endpoint& e);
void _parse_logger(json11::Json const& elem, logger& l);
void _parse_endpoint(nlohmann::json const& elem, endpoint& e);
void _parse_logger(nlohmann::json const& elem, logger& l);
};
} // namespace config

Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/file/stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class stream : public io::stream {
std::string peer() const override;
bool read(std::shared_ptr<io::data>& d, time_t deadline) override;
void remove_all_files();
void statistics(json11::Json::object& tree) const override;
void statistics(nlohmann::json& tree) const override;
int32_t write(std::shared_ptr<io::data> const& d) override;
int32_t stop() override;
};
Expand Down
5 changes: 3 additions & 2 deletions core/inc/com/centreon/broker/io/endpoint.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Copyright 2011-2012 Centreon
** Copyright 2011-2012, 2021 Centreon
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
#define CCB_IO_ENDPOINT_HH

#include <memory>
#include <nlohmann/json.hpp>
#include <set>
#include <string>

Expand Down Expand Up @@ -56,7 +57,7 @@ class endpoint {
bool is_connector() const noexcept;
virtual std::unique_ptr<stream> open() = 0;
virtual bool is_ready() const;
virtual void stats(json11::Json::object& tree);
virtual void stats(nlohmann::json& tree);
void set_filter(std::set<uint32_t> const& filter);
};
} // namespace io
Expand Down
4 changes: 2 additions & 2 deletions core/inc/com/centreon/broker/io/stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#define CCB_IO_STREAM_HH

#include <ctime>
#include <json11.hpp>
#include <memory>
#include <nlohmann/json.hpp>
#include <string>

#include "com/centreon/broker/io/data.hh"
Expand Down Expand Up @@ -72,7 +72,7 @@ class stream {
time_t deadline = (time_t)-1) = 0;
virtual void set_substream(std::shared_ptr<stream> substream);
std::shared_ptr<stream> get_substream();
virtual void statistics(json11::Json::object& tree) const;
virtual void statistics(nlohmann::json& tree) const;
virtual void update();
bool validate(std::shared_ptr<io::data> const& d, std::string const& error);
virtual int write(std::shared_ptr<data> const& d) = 0;
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/multiplexing/muxer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class muxer : public io::stream {
uint32_t get_event_queue_size() const;
void nack_events();
void remove_queue_files();
void statistics(json11::Json::object& tree) const override;
void statistics(nlohmann::json& tree) const override;
void wake();
int32_t write(std::shared_ptr<io::data> const& d) override;
int32_t stop() override;
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/persistent_file.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class persistent_file : public io::stream {
bool read(std::shared_ptr<io::data>& d,
time_t deadline = (time_t)-1) override;
void remove_all_files();
void statistics(json11::Json::object& tree) const override;
void statistics(nlohmann::json& tree) const override;
int32_t write(const std::shared_ptr<io::data>& d) override;
int32_t stop() override;
};
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/processing/acceptor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class acceptor : public endpoint {
// From stat_visitable
std::string const& _get_read_filters() const override;
std::string const& _get_write_filters() const override;
virtual void _forward_statistic(json11::Json::object& tree) override;
virtual void _forward_statistic(nlohmann::json& tree) override;
virtual uint32_t _get_queued_events() const override;

public:
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/processing/failover.hh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class failover : public endpoint {
std::string const& _get_read_filters() const override;
std::string const& _get_write_filters() const override;
uint32_t _get_queued_events() const override;
virtual void _forward_statistic(json11::Json::object& tree) override;
virtual void _forward_statistic(nlohmann::json& tree) override;

private:
void _launch_failover();
Expand Down
2 changes: 1 addition & 1 deletion core/inc/com/centreon/broker/processing/feeder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class feeder : public stat_visitable {
protected:
const std::string& _get_read_filters() const override;
const std::string& _get_write_filters() const override;
void _forward_statistic(json11::Json::object& tree) override;
void _forward_statistic(nlohmann::json& tree) override;
uint32_t _get_queued_events() const override;

public:
Expand Down
Loading

0 comments on commit 888c7c9

Please sign in to comment.