From 396aad5024b3ea57abbea020057a73c76ea302cd Mon Sep 17 00:00:00 2001 From: Jean Christophe Roques Date: Wed, 22 Mar 2023 16:24:10 +0100 Subject: [PATCH] MON-17452 multiplexing sources are compiled in multiplexing static library --- broker/CMakeLists.txt | 345 +++++++++--------- broker/core/multiplexing/CMakeLists.txt | 48 +++ .../centreon/broker/multiplexing/engine.hh | 0 .../com/centreon/broker/multiplexing/muxer.hh | 0 .../centreon/broker/multiplexing/publisher.hh | 0 .../src}/engine.cc | 0 .../src}/muxer.cc | 0 .../src}/publisher.cc | 0 .../test}/engine/hooker.cc | 0 .../test}/engine/start_stop.cc | 0 .../test}/muxer/read.cc | 0 .../test}/publisher/read.cc | 0 .../test}/publisher/write.cc | 0 broker/core/src/database/mysql_bind.cc | 17 +- broker/core/src/database/mysql_bulk_bind.cc | 17 +- broker/core/src/mysql_connection.cc | 2 +- broker/neb/CMakeLists.txt | 190 +++++----- broker/test/CMakeLists.txt | 34 +- 18 files changed, 363 insertions(+), 290 deletions(-) create mode 100644 broker/core/multiplexing/CMakeLists.txt rename broker/core/{ => multiplexing}/inc/com/centreon/broker/multiplexing/engine.hh (100%) rename broker/core/{ => multiplexing}/inc/com/centreon/broker/multiplexing/muxer.hh (100%) rename broker/core/{ => multiplexing}/inc/com/centreon/broker/multiplexing/publisher.hh (100%) rename broker/core/{src/multiplexing => multiplexing/src}/engine.cc (100%) rename broker/core/{src/multiplexing => multiplexing/src}/muxer.cc (100%) rename broker/core/{src/multiplexing => multiplexing/src}/publisher.cc (100%) rename broker/core/{test/multiplexing => multiplexing/test}/engine/hooker.cc (100%) rename broker/core/{test/multiplexing => multiplexing/test}/engine/start_stop.cc (100%) rename broker/core/{test/multiplexing => multiplexing/test}/muxer/read.cc (100%) rename broker/core/{test/multiplexing => multiplexing/test}/publisher/read.cc (100%) rename broker/core/{test/multiplexing => multiplexing/test}/publisher/write.cc (100%) diff --git a/broker/CMakeLists.txt b/broker/CMakeLists.txt index ef05ea37630..b6f57dbe708 100644 --- a/broker/CMakeLists.txt +++ b/broker/CMakeLists.txt @@ -76,7 +76,7 @@ endif() include_directories( "${PROJECT_SOURCE_DIR}/core/inc" "${PROJECT_SOURCE_DIR}/neb/inc" - "${CMAKE_SOURCE_DIR}/engine/inc") + "${CMAKE_SOURCE_DIR}/engine/inc" "${PROJECT_SOURCE_DIR}/core/multiplexing/inc") set(INC_DIR "${PROJECT_SOURCE_DIR}/core/inc/com/centreon/broker") set(SRC_DIR "${PROJECT_SOURCE_DIR}/core/src") set(TEST_DIR "${PROJECT_SOURCE_DIR}/core/test") @@ -305,177 +305,173 @@ configure_file("${INC_DIR}/vars.hh.in" "${INC_DIR}/vars.hh" "@ONLY") # Core library. set(LIBROKER_SOURCES - # Sources. - ${SRC_DIR}/bbdo/acceptor.cc - ${SRC_DIR}/bbdo/connector.cc - ${SRC_DIR}/bbdo/factory.cc - ${SRC_DIR}/bbdo/internal.cc - ${SRC_DIR}/bbdo/stream.cc - ${SRC_DIR}/broker_impl.cc - ${SRC_DIR}/brokerrpc.cc - ${SRC_DIR}/compression/factory.cc - ${SRC_DIR}/compression/opener.cc - ${SRC_DIR}/compression/stack_array.cc - ${SRC_DIR}/compression/stream.cc - ${SRC_DIR}/compression/zlib.cc - ${SRC_DIR}/config/applier/endpoint.cc - ${SRC_DIR}/config/applier/modules.cc - ${SRC_DIR}/config/applier/state.cc - ${SRC_DIR}/config/endpoint.cc - ${SRC_DIR}/config/parser.cc - ${SRC_DIR}/config/state.cc - ${SRC_DIR}/database_config.cc - ${SRC_DIR}/file/cfile.cc - ${SRC_DIR}/file/disk_accessor.cc - ${SRC_DIR}/file/directory_event.cc - ${SRC_DIR}/file/directory_watcher.cc - ${SRC_DIR}/file/factory.cc - ${SRC_DIR}/file/fifo.cc - ${SRC_DIR}/file/opener.cc - ${SRC_DIR}/file/splitter.cc - ${SRC_DIR}/file/stream.cc - ${SRC_DIR}/instance_broadcast.cc - ${SRC_DIR}/io/data.cc - ${SRC_DIR}/io/endpoint.cc - ${SRC_DIR}/io/limit_endpoint.cc - ${SRC_DIR}/io/events.cc - ${SRC_DIR}/io/factory.cc - ${SRC_DIR}/io/protocols.cc - ${SRC_DIR}/io/raw.cc - ${SRC_DIR}/io/stream.cc - ${SRC_DIR}/mapping/entry.cc - ${SRC_DIR}/misc/diagnostic.cc - ${SRC_DIR}/misc/filesystem.cc - ${SRC_DIR}/misc/misc.cc - ${SRC_DIR}/misc/parse_perfdata.cc - ${SRC_DIR}/misc/perfdata.cc - ${SRC_DIR}/misc/processing_speed_computer.cc - ${SRC_DIR}/misc/string.cc - ${SRC_DIR}/misc/time.cc - ${SRC_DIR}/misc/uuid.cc - ${SRC_DIR}/misc/variant.cc - ${SRC_DIR}/modules/handle.cc - ${SRC_DIR}/multiplexing/engine.cc - ${SRC_DIR}/multiplexing/muxer.cc - ${SRC_DIR}/multiplexing/publisher.cc - ${SRC_DIR}/mysql.cc - ${SRC_DIR}/pool.cc - ${SRC_DIR}/database/mysql_bind_base.cc - ${SRC_DIR}/database/mysql_bind.cc - ${SRC_DIR}/database/mysql_bind_result.cc - ${SRC_DIR}/database/mysql_bulk_bind.cc - ${SRC_DIR}/database/mysql_column.cc - ${SRC_DIR}/mysql_manager.cc - ${SRC_DIR}/database/mysql_result.cc - ${SRC_DIR}/database/mysql_stmt_base.cc - ${SRC_DIR}/database/mysql_stmt.cc - ${SRC_DIR}/database/mysql_bulk_stmt.cc - ${SRC_DIR}/mysql_connection.cc - ${SRC_DIR}/query_preparator.cc - ${SRC_DIR}/persistent_cache.cc - ${SRC_DIR}/persistent_file.cc - ${SRC_DIR}/processing/acceptor.cc - ${SRC_DIR}/processing/failover.cc - ${SRC_DIR}/processing/feeder.cc - ${SRC_DIR}/processing/stat_visitable.cc - ${SRC_DIR}/stats/center.cc - ${SRC_DIR}/stats/helper.cc - ${SRC_DIR}/time/daterange.cc - ${SRC_DIR}/time/timeperiod.cc - ${SRC_DIR}/time/timerange.cc - ${SRC_DIR}/time/timezone_locker.cc - ${SRC_DIR}/time/timezone_manager.cc - # Headers. - ${INC_DIR}/bbdo/acceptor.hh - ${INC_DIR}/bbdo/connector.hh - ${INC_DIR}/bbdo/factory.hh - ${INC_DIR}/bbdo/internal.hh - ${INC_DIR}/bbdo/stream.hh - ${INC_DIR}/broker_impl.hh - ${INC_DIR}/brokerrpc.hh - ${INC_DIR}/compression/factory.hh - ${INC_DIR}/compression/opener.hh - ${INC_DIR}/compression/stack_array.hh - ${INC_DIR}/compression/stream.hh - ${INC_DIR}/config/applier/endpoint.hh - ${INC_DIR}/config/applier/init.hh - ${INC_DIR}/config/applier/modules.hh - ${INC_DIR}/config/applier/state.hh - ${INC_DIR}/config/endpoint.hh - ${INC_DIR}/config/parser.hh - ${INC_DIR}/config/state.hh - ${INC_DIR}/database_config.hh - ${INC_DIR}/exceptions/config.hh - ${INC_DIR}/exceptions/interrupt.hh - ${INC_DIR}/exceptions/shutdown.hh - ${INC_DIR}/exceptions/timeout.hh - ${INC_DIR}/file/cfile.hh - ${INC_DIR}/file/directory_event.hh - ${INC_DIR}/file/directory_watcher.hh - ${INC_DIR}/file/factory.hh - ${INC_DIR}/file/fifo.hh - ${INC_DIR}/file/fs_file.hh - ${INC_DIR}/file/opener.hh - ${INC_DIR}/file/splitter.hh - ${INC_DIR}/file/stream.hh - ${INC_DIR}/instance_broadcast.hh - ${INC_DIR}/io/data.hh - ${INC_DIR}/io/endpoint.hh - ${INC_DIR}/io/limit_endpoint.hh - ${INC_DIR}/io/event_info.hh - ${INC_DIR}/io/events.hh - ${INC_DIR}/io/factory.hh - ${INC_DIR}/io/protocols.hh - ${INC_DIR}/io/raw.hh - ${INC_DIR}/io/stream.hh - ${INC_DIR}/mapping/entry.hh - ${INC_DIR}/mapping/property.hh - ${INC_DIR}/mapping/source.hh - ${INC_DIR}/misc/diagnostic.hh - ${INC_DIR}/misc/filesystem.hh - ${INC_DIR}/misc/misc.hh - ${INC_DIR}/misc/perfdata.hh - ${INC_DIR}/misc/processing_speed_computer.hh - ${INC_DIR}/misc/shared_mutex.hh - ${INC_DIR}/misc/string.hh - ${INC_DIR}/misc/time.hh - ${INC_DIR}/misc/trash.hh - ${INC_DIR}/misc/variant.hh - ${INC_DIR}/modules/handle.hh - ${INC_DIR}/multiplexing/engine.hh - ${INC_DIR}/multiplexing/muxer.hh - ${INC_DIR}/multiplexing/publisher.hh - ${INC_DIR}/mysql.hh - ${INC_DIR}/pool.hh - ${INC_DIR}/database/mysql_bulk_bind.hh - ${INC_DIR}/database/mysql_column.hh - ${INC_DIR}/database/mysql_error.hh - ${INC_DIR}/mysql_manager.hh - ${INC_DIR}/database/mysql_result.hh - ${INC_DIR}/database/mysql_stmt_base.hh - ${INC_DIR}/database/mysql_stmt.hh - ${INC_DIR}/database/mysql_bulk_stmt.hh - ${INC_DIR}/database/mysql_task.hh - ${INC_DIR}/database/table_max_size.hh - ${INC_DIR}/mysql_connection.hh - ${INC_DIR}/query_preparator.hh - ${INC_DIR}/persistent_cache.hh - ${INC_DIR}/persistent_file.hh - ${INC_DIR}/processing/acceptor.hh - ${INC_DIR}/processing/failover.hh - ${INC_DIR}/processing/feeder.hh - ${INC_DIR}/processing/stat_visitable.hh - ${INC_DIR}/stats/helper.hh - ${INC_DIR}/time/daterange.hh - ${INC_DIR}/time/ptr_typedef.hh - ${INC_DIR}/time/time_info.hh - ${INC_DIR}/time/timeperiod.hh - ${INC_DIR}/time/timerange.hh - ${INC_DIR}/time/timezone_locker.hh - ${INC_DIR}/time/timezone_manager.hh - ${INC_DIR}/timestamp.hh - ${INC_DIR}/vars.hh - ${INC_DIR}/version.hh) + + # Sources. + ${SRC_DIR}/bbdo/acceptor.cc + ${SRC_DIR}/bbdo/connector.cc + ${SRC_DIR}/bbdo/factory.cc + ${SRC_DIR}/bbdo/internal.cc + ${SRC_DIR}/bbdo/stream.cc + ${SRC_DIR}/broker_impl.cc + ${SRC_DIR}/brokerrpc.cc + ${SRC_DIR}/compression/factory.cc + ${SRC_DIR}/compression/opener.cc + ${SRC_DIR}/compression/stack_array.cc + ${SRC_DIR}/compression/stream.cc + ${SRC_DIR}/compression/zlib.cc + ${SRC_DIR}/config/applier/endpoint.cc + ${SRC_DIR}/config/applier/modules.cc + ${SRC_DIR}/config/applier/state.cc + ${SRC_DIR}/config/endpoint.cc + ${SRC_DIR}/config/parser.cc + ${SRC_DIR}/config/state.cc + ${SRC_DIR}/database_config.cc + ${SRC_DIR}/file/cfile.cc + ${SRC_DIR}/file/disk_accessor.cc + ${SRC_DIR}/file/directory_event.cc + ${SRC_DIR}/file/directory_watcher.cc + ${SRC_DIR}/file/factory.cc + ${SRC_DIR}/file/fifo.cc + ${SRC_DIR}/file/opener.cc + ${SRC_DIR}/file/splitter.cc + ${SRC_DIR}/file/stream.cc + ${SRC_DIR}/instance_broadcast.cc + ${SRC_DIR}/io/data.cc + ${SRC_DIR}/io/endpoint.cc + ${SRC_DIR}/io/limit_endpoint.cc + ${SRC_DIR}/io/events.cc + ${SRC_DIR}/io/factory.cc + ${SRC_DIR}/io/protocols.cc + ${SRC_DIR}/io/raw.cc + ${SRC_DIR}/io/stream.cc + ${SRC_DIR}/mapping/entry.cc + ${SRC_DIR}/misc/diagnostic.cc + ${SRC_DIR}/misc/filesystem.cc + ${SRC_DIR}/misc/misc.cc + ${SRC_DIR}/misc/parse_perfdata.cc + ${SRC_DIR}/misc/perfdata.cc + ${SRC_DIR}/misc/processing_speed_computer.cc + ${SRC_DIR}/misc/string.cc + ${SRC_DIR}/misc/time.cc + ${SRC_DIR}/misc/uuid.cc + ${SRC_DIR}/misc/variant.cc + ${SRC_DIR}/modules/handle.cc + ${SRC_DIR}/mysql.cc + ${SRC_DIR}/pool.cc + ${SRC_DIR}/database/mysql_bind_base.cc + ${SRC_DIR}/database/mysql_bind.cc + ${SRC_DIR}/database/mysql_bind_result.cc + ${SRC_DIR}/database/mysql_bulk_bind.cc + ${SRC_DIR}/database/mysql_column.cc + ${SRC_DIR}/mysql_manager.cc + ${SRC_DIR}/database/mysql_result.cc + ${SRC_DIR}/database/mysql_stmt_base.cc + ${SRC_DIR}/database/mysql_stmt.cc + ${SRC_DIR}/database/mysql_bulk_stmt.cc + ${SRC_DIR}/mysql_connection.cc + ${SRC_DIR}/query_preparator.cc + ${SRC_DIR}/persistent_cache.cc + ${SRC_DIR}/persistent_file.cc + ${SRC_DIR}/processing/acceptor.cc + ${SRC_DIR}/processing/failover.cc + ${SRC_DIR}/processing/feeder.cc + ${SRC_DIR}/processing/stat_visitable.cc + ${SRC_DIR}/stats/center.cc + ${SRC_DIR}/stats/helper.cc + ${SRC_DIR}/time/daterange.cc + ${SRC_DIR}/time/timeperiod.cc + ${SRC_DIR}/time/timerange.cc + ${SRC_DIR}/time/timezone_locker.cc + ${SRC_DIR}/time/timezone_manager.cc + + # Headers. + ${INC_DIR}/bbdo/acceptor.hh + ${INC_DIR}/bbdo/connector.hh + ${INC_DIR}/bbdo/factory.hh + ${INC_DIR}/bbdo/internal.hh + ${INC_DIR}/bbdo/stream.hh + ${INC_DIR}/broker_impl.hh + ${INC_DIR}/brokerrpc.hh + ${INC_DIR}/compression/factory.hh + ${INC_DIR}/compression/opener.hh + ${INC_DIR}/compression/stack_array.hh + ${INC_DIR}/compression/stream.hh + ${INC_DIR}/config/applier/endpoint.hh + ${INC_DIR}/config/applier/init.hh + ${INC_DIR}/config/applier/modules.hh + ${INC_DIR}/config/applier/state.hh + ${INC_DIR}/config/endpoint.hh + ${INC_DIR}/config/parser.hh + ${INC_DIR}/config/state.hh + ${INC_DIR}/database_config.hh + ${INC_DIR}/exceptions/config.hh + ${INC_DIR}/exceptions/interrupt.hh + ${INC_DIR}/exceptions/shutdown.hh + ${INC_DIR}/exceptions/timeout.hh + ${INC_DIR}/file/cfile.hh + ${INC_DIR}/file/directory_event.hh + ${INC_DIR}/file/directory_watcher.hh + ${INC_DIR}/file/factory.hh + ${INC_DIR}/file/fifo.hh + ${INC_DIR}/file/fs_file.hh + ${INC_DIR}/file/opener.hh + ${INC_DIR}/file/splitter.hh + ${INC_DIR}/file/stream.hh + ${INC_DIR}/instance_broadcast.hh + ${INC_DIR}/io/data.hh + ${INC_DIR}/io/endpoint.hh + ${INC_DIR}/io/limit_endpoint.hh + ${INC_DIR}/io/event_info.hh + ${INC_DIR}/io/events.hh + ${INC_DIR}/io/factory.hh + ${INC_DIR}/io/protocols.hh + ${INC_DIR}/io/raw.hh + ${INC_DIR}/io/stream.hh + ${INC_DIR}/mapping/entry.hh + ${INC_DIR}/mapping/property.hh + ${INC_DIR}/mapping/source.hh + ${INC_DIR}/misc/diagnostic.hh + ${INC_DIR}/misc/filesystem.hh + ${INC_DIR}/misc/misc.hh + ${INC_DIR}/misc/perfdata.hh + ${INC_DIR}/misc/processing_speed_computer.hh + ${INC_DIR}/misc/shared_mutex.hh + ${INC_DIR}/misc/string.hh + ${INC_DIR}/misc/time.hh + ${INC_DIR}/misc/trash.hh + ${INC_DIR}/misc/variant.hh + ${INC_DIR}/modules/handle.hh + ${INC_DIR}/mysql.hh + ${INC_DIR}/pool.hh + ${INC_DIR}/database/mysql_bulk_bind.hh + ${INC_DIR}/database/mysql_column.hh + ${INC_DIR}/database/mysql_error.hh + ${INC_DIR}/mysql_manager.hh + ${INC_DIR}/database/mysql_result.hh + ${INC_DIR}/database/mysql_stmt_base.hh + ${INC_DIR}/database/mysql_stmt.hh + ${INC_DIR}/database/mysql_bulk_stmt.hh + ${INC_DIR}/database/mysql_task.hh + ${INC_DIR}/database/table_max_size.hh + ${INC_DIR}/mysql_connection.hh + ${INC_DIR}/query_preparator.hh + ${INC_DIR}/persistent_cache.hh + ${INC_DIR}/persistent_file.hh + ${INC_DIR}/processing/acceptor.hh + ${INC_DIR}/processing/failover.hh + ${INC_DIR}/processing/feeder.hh + ${INC_DIR}/processing/stat_visitable.hh + ${INC_DIR}/stats/helper.hh + ${INC_DIR}/time/daterange.hh + ${INC_DIR}/time/ptr_typedef.hh + ${INC_DIR}/time/time_info.hh + ${INC_DIR}/time/timeperiod.hh + ${INC_DIR}/time/timerange.hh + ${INC_DIR}/time/timezone_locker.hh + ${INC_DIR}/time/timezone_manager.hh + ${INC_DIR}/timestamp.hh + ${INC_DIR}/vars.hh + ${INC_DIR}/version.hh) # Static libraries. add_library(rokerlog STATIC ${SRC_DIR}/log_v2.cc) @@ -505,6 +501,7 @@ target_link_libraries(roker rokerbase dl CONAN_PKG::openssl CONAN_PKG::grpc # Standalone binary. add_executable(cbd ${SRC_DIR}/main.cc) +add_dependencies(cbd multiplexing) # Flags needed to include all symbols in binary. target_link_libraries( @@ -514,6 +511,7 @@ target_link_libraries( "-Wl,--whole-archive" rokerbase roker + multiplexing "-Wl,--no-whole-archive" CONAN_PKG::nlohmann_json CONAN_PKG::fmt @@ -552,6 +550,9 @@ add_broker_module(TLS2 OFF) add_broker_module(DUMP OFF) add_broker_module(GRPC ON) +# multiplexing library linked in final executable such as cbd or cbmod +add_subdirectory(core/multiplexing) + # Lua module. option(WITH_MODULE_LUA "Build lua module." ON) diff --git a/broker/core/multiplexing/CMakeLists.txt b/broker/core/multiplexing/CMakeLists.txt new file mode 100644 index 00000000000..7aef7f855dd --- /dev/null +++ b/broker/core/multiplexing/CMakeLists.txt @@ -0,0 +1,48 @@ +# +# Copyright 2009-2023 Centreon +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# For more information : contact@centreon.com +# + +# +# Global settings. +# + +set(SRC_DIR "src") +set(TESTS_DIR "${PROJECT_SOURCE_DIR}/core/multiplexing/test") + +# Sources. +set(SOURCES + ${SRC_DIR}/engine.cc + ${SRC_DIR}/muxer.cc + ${SRC_DIR}/publisher.cc +) + +# Static libraries. +add_library(multiplexing STATIC ${SOURCES}) +set_target_properties(multiplexing PROPERTIES COMPILE_FLAGS "-fPIC") +target_precompile_headers(multiplexing PRIVATE ../precomp_inc/precomp.hpp) +target_link_libraries(multiplexing CONAN_PKG::spdlog) + +if(WITH_TESTING) + set( + TESTS_SOURCES + ${TESTS_SOURCES} + ${TESTS_DIR}/engine/start_stop.cc + ${TESTS_DIR}/muxer/read.cc + ${TESTS_DIR}/publisher/read.cc + ${TESTS_DIR}/publisher/write.cc + ) +endif(WITH_TESTING) diff --git a/broker/core/inc/com/centreon/broker/multiplexing/engine.hh b/broker/core/multiplexing/inc/com/centreon/broker/multiplexing/engine.hh similarity index 100% rename from broker/core/inc/com/centreon/broker/multiplexing/engine.hh rename to broker/core/multiplexing/inc/com/centreon/broker/multiplexing/engine.hh diff --git a/broker/core/inc/com/centreon/broker/multiplexing/muxer.hh b/broker/core/multiplexing/inc/com/centreon/broker/multiplexing/muxer.hh similarity index 100% rename from broker/core/inc/com/centreon/broker/multiplexing/muxer.hh rename to broker/core/multiplexing/inc/com/centreon/broker/multiplexing/muxer.hh diff --git a/broker/core/inc/com/centreon/broker/multiplexing/publisher.hh b/broker/core/multiplexing/inc/com/centreon/broker/multiplexing/publisher.hh similarity index 100% rename from broker/core/inc/com/centreon/broker/multiplexing/publisher.hh rename to broker/core/multiplexing/inc/com/centreon/broker/multiplexing/publisher.hh diff --git a/broker/core/src/multiplexing/engine.cc b/broker/core/multiplexing/src/engine.cc similarity index 100% rename from broker/core/src/multiplexing/engine.cc rename to broker/core/multiplexing/src/engine.cc diff --git a/broker/core/src/multiplexing/muxer.cc b/broker/core/multiplexing/src/muxer.cc similarity index 100% rename from broker/core/src/multiplexing/muxer.cc rename to broker/core/multiplexing/src/muxer.cc diff --git a/broker/core/src/multiplexing/publisher.cc b/broker/core/multiplexing/src/publisher.cc similarity index 100% rename from broker/core/src/multiplexing/publisher.cc rename to broker/core/multiplexing/src/publisher.cc diff --git a/broker/core/test/multiplexing/engine/hooker.cc b/broker/core/multiplexing/test/engine/hooker.cc similarity index 100% rename from broker/core/test/multiplexing/engine/hooker.cc rename to broker/core/multiplexing/test/engine/hooker.cc diff --git a/broker/core/test/multiplexing/engine/start_stop.cc b/broker/core/multiplexing/test/engine/start_stop.cc similarity index 100% rename from broker/core/test/multiplexing/engine/start_stop.cc rename to broker/core/multiplexing/test/engine/start_stop.cc diff --git a/broker/core/test/multiplexing/muxer/read.cc b/broker/core/multiplexing/test/muxer/read.cc similarity index 100% rename from broker/core/test/multiplexing/muxer/read.cc rename to broker/core/multiplexing/test/muxer/read.cc diff --git a/broker/core/test/multiplexing/publisher/read.cc b/broker/core/multiplexing/test/publisher/read.cc similarity index 100% rename from broker/core/test/multiplexing/publisher/read.cc rename to broker/core/multiplexing/test/publisher/read.cc diff --git a/broker/core/test/multiplexing/publisher/write.cc b/broker/core/multiplexing/test/publisher/write.cc similarity index 100% rename from broker/core/test/multiplexing/publisher/write.cc rename to broker/core/multiplexing/test/publisher/write.cc diff --git a/broker/core/src/database/mysql_bind.cc b/broker/core/src/database/mysql_bind.cc index b8174f8a286..207c11e45c8 100644 --- a/broker/core/src/database/mysql_bind.cc +++ b/broker/core/src/database/mysql_bind.cc @@ -107,12 +107,17 @@ void mysql_bind::set_null_bool(size_t range) { _bind[range].is_unsigned = unsgn; \ } -#define VALUE(ftype, vtype, sqltype) \ - vtype mysql_bind::value_as_##ftype(size_t range) const { \ - if (_bind[range].buffer_type == sqltype) \ - return *static_cast(_bind[range].buffer); \ - else \ - assert("This field is not an " #sqltype == nullptr); \ +#define VALUE(ftype, vtype, sqltype) \ + vtype mysql_bind::value_as_##ftype(size_t range) const { \ + if (_bind[range].buffer_type == sqltype) \ + return *static_cast(_bind[range].buffer); \ + else { \ + assert("This field is not an " #sqltype == nullptr); \ + SPDLOG_LOGGER_CRITICAL(log_v2::sql(), \ + "{} This field is not an " #sqltype " but {}", \ + __FUNCTION__, _bind[range].buffer_type); \ + return 0; \ + } \ } SET_VALUE(i32, int32_t, MYSQL_TYPE_LONG, false) diff --git a/broker/core/src/database/mysql_bulk_bind.cc b/broker/core/src/database/mysql_bulk_bind.cc index 49ff137ab9d..38756b63a22 100644 --- a/broker/core/src/database/mysql_bulk_bind.cc +++ b/broker/core/src/database/mysql_bulk_bind.cc @@ -70,12 +70,17 @@ void mysql_bulk_bind::_prepare_type(size_t range, enum enum_field_types type) { _bind[range].length = _column[range].length_buffer(); \ } -#define VALUE(ftype, vtype, sqltype) \ - vtype mysql_bulk_bind::value_as_##ftype(size_t range) const { \ - if (_bind[range].buffer_type == sqltype) \ - return *static_cast(_bind[range].buffer); \ - else \ - assert("This field is not an " #sqltype == nullptr); \ +#define VALUE(ftype, vtype, sqltype) \ + vtype mysql_bulk_bind::value_as_##ftype(size_t range) const { \ + if (_bind[range].buffer_type == sqltype) \ + return *static_cast(_bind[range].buffer); \ + else { \ + assert("This field is not an " #sqltype == nullptr); \ + SPDLOG_LOGGER_CRITICAL(log_v2::sql(), \ + "{} This field is not an " #sqltype " but {}", \ + __FUNCTION__, _bind[range].buffer_type); \ + return 0; \ + } \ } SET_VALUE(i32, int32_t, MYSQL_TYPE_LONG, false) diff --git a/broker/core/src/mysql_connection.cc b/broker/core/src/mysql_connection.cc index 47d485f9a5a..29ae2bb138b 100644 --- a/broker/core/src/mysql_connection.cc +++ b/broker/core/src/mysql_connection.cc @@ -423,7 +423,7 @@ void mysql_connection::_statement(mysql_task* t) { } else { SPDLOG_LOGGER_TRACE(log_v2::sql(), "mysql_connection {:p}: success execute statement " - "{} attempt {}: {}", + "{} attempt {}", static_cast(this), task->statement_id, _stmt_query[task->statement_id]); set_need_to_commit(); diff --git a/broker/neb/CMakeLists.txt b/broker/neb/CMakeLists.txt index cb588a6e5a6..5a118318fa2 100644 --- a/broker/neb/CMakeLists.txt +++ b/broker/neb/CMakeLists.txt @@ -24,77 +24,78 @@ include_directories("${INC_DIR}") # NEB sources. set(NEB_SOURCES - # Sources. - # Headers. - ${SRC_DIR}/acknowledgement.cc - ${SRC_DIR}/check.cc - ${SRC_DIR}/comment.cc - ${SRC_DIR}/custom_variable.cc - ${SRC_DIR}/custom_variable_status.cc - ${SRC_DIR}/dependency.cc - ${SRC_DIR}/downtime.cc - ${SRC_DIR}/group.cc - ${SRC_DIR}/group_member.cc - ${SRC_DIR}/host.cc - ${SRC_DIR}/host_check.cc - ${SRC_DIR}/host_dependency.cc - ${SRC_DIR}/host_group.cc - ${SRC_DIR}/host_group_member.cc - ${SRC_DIR}/host_parent.cc - ${SRC_DIR}/host_service.cc - ${SRC_DIR}/host_service_status.cc - ${SRC_DIR}/host_status.cc - ${SRC_DIR}/instance.cc - ${SRC_DIR}/instance_configuration.cc - ${SRC_DIR}/instance_status.cc - ${SRC_DIR}/log_entry.cc - ${SRC_DIR}/responsive_instance.cc - ${SRC_DIR}/service.cc - ${SRC_DIR}/service_check.cc - ${SRC_DIR}/service_dependency.cc - ${SRC_DIR}/service_group.cc - ${SRC_DIR}/service_group_member.cc - ${SRC_DIR}/service_status.cc - ${SRC_DIR}/status.cc - ${INC_DIR}/com/centreon/broker/neb/acknowledgement.hh - ${INC_DIR}/com/centreon/broker/neb/check.hh - ${INC_DIR}/com/centreon/broker/neb/comment.hh - ${INC_DIR}/com/centreon/broker/neb/custom_variable.hh - ${INC_DIR}/com/centreon/broker/neb/custom_variable_status.hh - ${INC_DIR}/com/centreon/broker/neb/dependency.hh - ${INC_DIR}/com/centreon/broker/neb/downtime.hh - ${INC_DIR}/com/centreon/broker/neb/events.hh - ${INC_DIR}/com/centreon/broker/neb/group.hh - ${INC_DIR}/com/centreon/broker/neb/group_member.hh - ${INC_DIR}/com/centreon/broker/neb/host.hh - ${INC_DIR}/com/centreon/broker/neb/host_check.hh - ${INC_DIR}/com/centreon/broker/neb/host_dependency.hh - ${INC_DIR}/com/centreon/broker/neb/host_group.hh - ${INC_DIR}/com/centreon/broker/neb/host_group_member.hh - ${INC_DIR}/com/centreon/broker/neb/host_parent.hh - ${INC_DIR}/com/centreon/broker/neb/host_service.hh - ${INC_DIR}/com/centreon/broker/neb/host_service_status.hh - ${INC_DIR}/com/centreon/broker/neb/host_status.hh - ${INC_DIR}/com/centreon/broker/neb/instance.hh - ${INC_DIR}/com/centreon/broker/neb/instance_configuration.hh - ${INC_DIR}/com/centreon/broker/neb/instance_status.hh - ${INC_DIR}/com/centreon/broker/neb/internal.hh - ${INC_DIR}/com/centreon/broker/neb/log_entry.hh - ${INC_DIR}/com/centreon/broker/neb/responsive_instance.hh - ${INC_DIR}/com/centreon/broker/neb/service.hh - ${INC_DIR}/com/centreon/broker/neb/service_check.hh - ${INC_DIR}/com/centreon/broker/neb/service_dependency.hh - ${INC_DIR}/com/centreon/broker/neb/service_group.hh - ${INC_DIR}/com/centreon/broker/neb/service_group_member.hh - ${INC_DIR}/com/centreon/broker/neb/service_status.hh - ${INC_DIR}/com/centreon/broker/neb/status.hh) + + # Sources. + # Headers. + ${SRC_DIR}/acknowledgement.cc + ${SRC_DIR}/check.cc + ${SRC_DIR}/comment.cc + ${SRC_DIR}/custom_variable.cc + ${SRC_DIR}/custom_variable_status.cc + ${SRC_DIR}/dependency.cc + ${SRC_DIR}/downtime.cc + ${SRC_DIR}/group.cc + ${SRC_DIR}/group_member.cc + ${SRC_DIR}/host.cc + ${SRC_DIR}/host_check.cc + ${SRC_DIR}/host_dependency.cc + ${SRC_DIR}/host_group.cc + ${SRC_DIR}/host_group_member.cc + ${SRC_DIR}/host_parent.cc + ${SRC_DIR}/host_service.cc + ${SRC_DIR}/host_service_status.cc + ${SRC_DIR}/host_status.cc + ${SRC_DIR}/instance.cc + ${SRC_DIR}/instance_configuration.cc + ${SRC_DIR}/instance_status.cc + ${SRC_DIR}/log_entry.cc + ${SRC_DIR}/responsive_instance.cc + ${SRC_DIR}/service.cc + ${SRC_DIR}/service_check.cc + ${SRC_DIR}/service_dependency.cc + ${SRC_DIR}/service_group.cc + ${SRC_DIR}/service_group_member.cc + ${SRC_DIR}/service_status.cc + ${SRC_DIR}/status.cc + ${INC_DIR}/com/centreon/broker/neb/acknowledgement.hh + ${INC_DIR}/com/centreon/broker/neb/check.hh + ${INC_DIR}/com/centreon/broker/neb/comment.hh + ${INC_DIR}/com/centreon/broker/neb/custom_variable.hh + ${INC_DIR}/com/centreon/broker/neb/custom_variable_status.hh + ${INC_DIR}/com/centreon/broker/neb/dependency.hh + ${INC_DIR}/com/centreon/broker/neb/downtime.hh + ${INC_DIR}/com/centreon/broker/neb/events.hh + ${INC_DIR}/com/centreon/broker/neb/group.hh + ${INC_DIR}/com/centreon/broker/neb/group_member.hh + ${INC_DIR}/com/centreon/broker/neb/host.hh + ${INC_DIR}/com/centreon/broker/neb/host_check.hh + ${INC_DIR}/com/centreon/broker/neb/host_dependency.hh + ${INC_DIR}/com/centreon/broker/neb/host_group.hh + ${INC_DIR}/com/centreon/broker/neb/host_group_member.hh + ${INC_DIR}/com/centreon/broker/neb/host_parent.hh + ${INC_DIR}/com/centreon/broker/neb/host_service.hh + ${INC_DIR}/com/centreon/broker/neb/host_service_status.hh + ${INC_DIR}/com/centreon/broker/neb/host_status.hh + ${INC_DIR}/com/centreon/broker/neb/instance.hh + ${INC_DIR}/com/centreon/broker/neb/instance_configuration.hh + ${INC_DIR}/com/centreon/broker/neb/instance_status.hh + ${INC_DIR}/com/centreon/broker/neb/internal.hh + ${INC_DIR}/com/centreon/broker/neb/log_entry.hh + ${INC_DIR}/com/centreon/broker/neb/responsive_instance.hh + ${INC_DIR}/com/centreon/broker/neb/service.hh + ${INC_DIR}/com/centreon/broker/neb/service_check.hh + ${INC_DIR}/com/centreon/broker/neb/service_dependency.hh + ${INC_DIR}/com/centreon/broker/neb/service_group.hh + ${INC_DIR}/com/centreon/broker/neb/service_group_member.hh + ${INC_DIR}/com/centreon/broker/neb/service_status.hh + ${INC_DIR}/com/centreon/broker/neb/status.hh) # Static library. add_library(nebbase STATIC ${NEB_SOURCES}) add_dependencies(nebbase table_max_size target_neb target_severity target_tag) target_link_libraries(nebbase CONAN_PKG::protobuf pb_severity_lib pb_tag_lib - pb_neb_lib pb_header_lib) + pb_neb_lib pb_header_lib) set(NEBBASE_CXXFLAGS "${NEBBASE_CXXFLAGS} -fPIC") set_property(TARGET nebbase PROPERTY COMPILE_FLAGS ${NEBBASE_CXXFLAGS}) @@ -103,10 +104,11 @@ target_precompile_headers(nebbase PRIVATE precomp_inc/precomp.hpp) # Centreon Broker module. set(NEB "10-neb") set(NEB - "${NEB}" - PARENT_SCOPE) + "${NEB}" + PARENT_SCOPE) add_library( "${NEB}" SHARED + # Main source. "${SRC_DIR}/broker.cc" # Inc ) @@ -122,6 +124,7 @@ install(TARGETS "${NEB}" LIBRARY DESTINATION "${PREFIX_MODULES}") set(CBMOD "cbmod") add_library( "${CBMOD}" SHARED + # Sources. "${PROJECT_SOURCE_DIR}/core/src/config/applier/init.cc" "${SRC_DIR}/callback.cc" @@ -130,6 +133,7 @@ add_library( "${SRC_DIR}/internal.cc" "${SRC_DIR}/neb.cc" "${SRC_DIR}/set_log_data.cc" + # Headers. "${INC_DIR}/com/centreon/broker/neb/callback.hh" "${INC_DIR}/com/centreon/broker/neb/callbacks.hh" @@ -149,14 +153,15 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") "${CBMOD}" rokerlog "-Wl,--whole-archive" - "rokerbase" + rokerbase + multiplexing "-Wl,--no-whole-archive" CONAN_PKG::nlohmann_json CONAN_PKG::spdlog CONAN_PKG::asio) else() target_link_libraries("${CBMOD}" "rokerbase" CONAN_PKG::nlohmann_json - CONAN_PKG::spdlog CONAN_PKG::asio) + CONAN_PKG::spdlog CONAN_PKG::asio) endif() set_target_properties("${CBMOD}" PROPERTIES PREFIX "") @@ -165,30 +170,31 @@ target_precompile_headers(${CBMOD} REUSE_FROM nebbase) # Testing. if(WITH_TESTING) set(TESTS_SOURCES - ${TESTS_SOURCES} - ${SRC_DIR}/set_log_data.cc - # Actual tests - ${TEST_DIR}/custom_variable.cc - ${TEST_DIR}/custom_variable_status.cc - ${TEST_DIR}/host.cc - ${TEST_DIR}/host_check.cc - ${TEST_DIR}/host_dependency.cc - ${TEST_DIR}/host_parent.cc - ${TEST_DIR}/host_status.cc - ${TEST_DIR}/instance.cc - ${TEST_DIR}/instance_status.cc - ${TEST_DIR}/log_entry.cc - ${TEST_DIR}/randomize.cc - ${TEST_DIR}/randomize.hh - ${TEST_DIR}/service.cc - ${TEST_DIR}/service_check.cc - ${TEST_DIR}/service_dependency.cc - ${TEST_DIR}/service_status.cc - ${TEST_DIR}/set_log_data.cc - PARENT_SCOPE) + ${TESTS_SOURCES} + ${SRC_DIR}/set_log_data.cc + + # Actual tests + ${TEST_DIR}/custom_variable.cc + ${TEST_DIR}/custom_variable_status.cc + ${TEST_DIR}/host.cc + ${TEST_DIR}/host_check.cc + ${TEST_DIR}/host_dependency.cc + ${TEST_DIR}/host_parent.cc + ${TEST_DIR}/host_status.cc + ${TEST_DIR}/instance.cc + ${TEST_DIR}/instance_status.cc + ${TEST_DIR}/log_entry.cc + ${TEST_DIR}/randomize.cc + ${TEST_DIR}/randomize.hh + ${TEST_DIR}/service.cc + ${TEST_DIR}/service_check.cc + ${TEST_DIR}/service_dependency.cc + ${TEST_DIR}/service_status.cc + ${TEST_DIR}/set_log_data.cc + PARENT_SCOPE) set(TESTS_LIBRARIES - ${TESTS_LIBRARIES} ${NEB} - PARENT_SCOPE) + ${TESTS_LIBRARIES} ${NEB} + PARENT_SCOPE) endif() # Install rules. diff --git a/broker/test/CMakeLists.txt b/broker/test/CMakeLists.txt index 764a6369a14..976980bf5da 100644 --- a/broker/test/CMakeLists.txt +++ b/broker/test/CMakeLists.txt @@ -76,13 +76,14 @@ target_link_libraries( if(WITH_ASAN) set(CMAKE_BUILD_TYPE Debug) set(CMAKE_CXX_FLAGS_DEBUG - "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") + "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") set(CMAKE_LINKER_FLAGS_DEBUG - "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") + "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") endif() add_executable( ut_broker + # Core sources. ${TESTS_DIR}/bbdo/category.cc ${TESTS_DIR}/bbdo/output.cc @@ -109,10 +110,6 @@ add_executable( ${TESTS_DIR}/misc/perfdata.cc ${TESTS_DIR}/misc/string.cc ${TESTS_DIR}/modules/module.cc - ${TESTS_DIR}/multiplexing/engine/start_stop.cc - ${TESTS_DIR}/multiplexing/muxer/read.cc - ${TESTS_DIR}/multiplexing/publisher/read.cc - ${TESTS_DIR}/multiplexing/publisher/write.cc ${TESTS_DIR}/processing/acceptor.cc ${TESTS_DIR}/processing/feeder.cc ${TESTS_DIR}/time/timerange.cc @@ -121,6 +118,7 @@ add_executable( ${TESTS_DIR}/io.cc ${TESTS_DIR}/main.cc ${TESTS_DIR}/test_server.cc + # Module sources. ${TESTS_SOURCES}) @@ -130,6 +128,7 @@ target_link_libraries( roker rokerbase rokerlog + multiplexing ${TESTS_LIBRARIES} conflictmgr CONAN_PKG::nlohmann_json @@ -141,6 +140,15 @@ target_link_libraries( CONAN_PKG::openssl CONAN_PKG::grpc) +add_dependencies(ut_broker + test_util + roker + rokerbase + rokerlog + multiplexing + conflictmgr +) + set_target_properties(ut_broker PROPERTIES COMPILE_FLAGS "-fPIC") target_precompile_headers(ut_broker REUSE_FROM rokerbase) @@ -148,20 +156,20 @@ target_precompile_headers(ut_broker REUSE_FROM rokerbase) set_target_properties( ut_broker rpc_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/tests - RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/tests - RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/tests - RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/tests) + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/tests + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/tests + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/tests + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/tests) # keys used by ut_broker grpc file(COPY ${PROJECT_SOURCE_DIR}/grpc/test/grpc_test_keys - DESTINATION ${CMAKE_BINARY_DIR}/tests) + DESTINATION ${CMAKE_BINARY_DIR}/tests) add_test(NAME tests COMMAND ut_broker) if(WITH_COVERAGE) set(COVERAGE_EXCLUDES '*/main.cc' '*/test/*' '/usr/include/*' - '${CMAKE_BINARY_DIR}/*' '*/.conan/*') + '${CMAKE_BINARY_DIR}/*' '*/.conan/*') setup_target_for_coverage(NAME broker-test-coverage EXECUTABLE ut_broker - DEPENDENCIES ut_broker) + DEPENDENCIES ut_broker) endif()