Skip to content

Commit

Permalink
enh(engine): Engine exceptions in the configuration are replaced by m…
Browse files Browse the repository at this point in the history
…sg_fmt.

* enh(engine/configuration): unused headers removed
* enh(engine/configuration): exceptions are engine independent
* cleanup(engine): comments added
* enh(engine): cleanup and fix after review
  • Loading branch information
bouda1 authored Jun 18, 2024
1 parent 56c0e9b commit 74789b9
Show file tree
Hide file tree
Showing 55 changed files with 494 additions and 544 deletions.
10 changes: 0 additions & 10 deletions bbdo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ set(protobuf_files
header
rebuild_message
remove_graph_message
severity
tag
bbdo
neb
storage
Expand Down Expand Up @@ -63,14 +61,6 @@ add_library(pb_bbdo_lib STATIC bbdo.pb.cc bbdo.pb.h)
add_dependencies(pb_bbdo_lib target_bbdo)
set_target_properties(pb_bbdo_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_severity_lib STATIC severity.pb.cc severity.pb.h)
add_dependencies(pb_severity_lib target_neb)
set_target_properties(pb_severity_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_tag_lib STATIC tag.pb.cc tag.pb.h)
add_dependencies(pb_tag_lib target_neb)
set_target_properties(pb_tag_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_library(pb_bam_lib STATIC bam.pb.cc bam.pb.h bam_state.pb.cc bam_state.pb.h)
add_dependencies(pb_bam_lib target_bam target_bam_state target_header)
set_target_properties(pb_bam_lib PROPERTIES POSITION_INDEPENDENT_CODE ON)
Expand Down
77 changes: 76 additions & 1 deletion bbdo/neb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
syntax = "proto3";

import "header.proto";
import "tag.proto";

package com.centreon.broker;

Expand Down Expand Up @@ -740,3 +739,79 @@ message InstanceConfiguration {
bool loaded = 2;
uint64 poller_id = 3;
}

/**
* @brief A severity is a way to give some importance to a resource. It has a
* level that is an integer from 1. 1 is more important than 2, than 3...
* It also has an id, a level, an icon_id and a name.
*
* Because a severity can be sent from several poller, and by moment a poller
* can say it does not need it anymore, broker needs to know from which poller
* the severity event comes from, so we have a poller_id in the message.
*
* For example, two pollers use a severity named 'foo'. Then the first one sends
* a Severity message with the action DELETE. This means this poller does not
* need it anymore but we don't know about the other poller. Then we can remove
* relations between resources of our poller and this severity. And only if the
* severity is no more used at all, we can remove it.
*/
/*io::neb, neb::de_pb_severity*/
message Severity {
uint64 id = 1;
enum Action {
ADD = 0;
DELETE = 1;
MODIFY = 2;
}
Action action = 2;
uint32 level = 3;
uint64 icon_id = 4;
string name = 5;
enum Type {
SERVICE = 0;
HOST = 1;
}
Type type = 6;
uint64 poller_id = 7;
}

/**
* @brief A tag is a generalization of a host group or a service group. It
* is a way to group resources. It has an id, a type and a name.
*
* Because a tag can be sent from several poller, and by moment a poller can
* say it does not need it anymore, broker needs to know from which poller the
* tag event comes from, so we have a poller_id in the message.
*
* For example, two pollers use a tag named 'foo'. Then the first one sends a
* Tag message with the action DELETE. This means this poller does not need it
* anymore but we don't know about the other poller. Then we can remove
* relations between resources of our poller and this tag. And only if the tag
* is no more used at all, we can remove it.
*/
enum TagType {
SERVICEGROUP = 0;
HOSTGROUP = 1;
SERVICECATEGORY = 2;
HOSTCATEGORY = 3;
}

/*io::neb, neb::de_pb_tag*/
message Tag {
uint64 id = 1;
enum Action {
ADD = 0;
DELETE = 1;
MODIFY = 2;
}

Action action = 2;
TagType type = 3;
string name = 4;
int64 poller_id = 5;
}

message TagInfo {
uint64 id = 1;
TagType type = 2;
}
56 changes: 0 additions & 56 deletions bbdo/severity.proto

This file was deleted.

62 changes: 0 additions & 62 deletions bbdo/tag.proto

This file was deleted.

2 changes: 1 addition & 1 deletion broker/core/inc/com/centreon/broker/cache/global_cache.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef CCB_GLOBAL_CACHE_HH
#define CCB_GLOBAL_CACHE_HH

#include "bbdo/tag.pb.h"
#include "bbdo/neb.pb.h"

namespace com::centreon::broker {

Expand Down
2 changes: 0 additions & 2 deletions broker/grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ target_link_libraries(
pb_neb_lib
pb_storage_lib
pb_bbdo_lib
pb_severity_lib
pb_tag_lib
pb_bam_lib
pb_extcmd_lib
pb_open_telemetry_lib
Expand Down
4 changes: 0 additions & 4 deletions broker/neb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,12 @@ add_dependencies(
nebbase
table_max_size
target_neb
target_severity
target_tag
pb_neb_lib
pb_header_lib)

target_link_libraries(nebbase
-L${PROTOBUF_LIB_DIR}
protobuf
pb_severity_lib
pb_tag_lib
pb_neb_lib
pb_header_lib
pb_open_telemetry_lib)
Expand Down
2 changes: 0 additions & 2 deletions broker/neb/inc/com/centreon/broker/neb/internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <absl/hash/hash.h>
#include "bbdo/events.hh"
#include "bbdo/neb.pb.h"
#include "bbdo/severity.pb.h"
#include "bbdo/tag.pb.h"
#include "com/centreon/broker/io/protobuf.hh"
#include "com/centreon/broker/multiplexing/publisher.hh"
#include "com/centreon/broker/neb/callback.hh"
Expand Down
1 change: 0 additions & 1 deletion broker/victoria_metrics/test/request_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ using system_clock = std::chrono::system_clock;
using time_point = system_clock::time_point;
using duration = system_clock::duration;

#include "bbdo/tag.pb.h"
#include "com/centreon/broker/cache/global_cache.hh"
#include "com/centreon/broker/file/disk_accessor.hh"
#include "com/centreon/broker/io/protocols.hh"
Expand Down
1 change: 1 addition & 0 deletions engine/enginerpc/engine_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace asio = boost::asio;
#include "com/centreon/engine/globals.hh"
#include "com/centreon/engine/hostdependency.hh"
#include "com/centreon/engine/hostgroup.hh"
#include "com/centreon/engine/logging/logger.hh"
#include "com/centreon/engine/service.hh"
#include "com/centreon/engine/servicedependency.hh"
#include "com/centreon/engine/servicegroup.hh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef CCE_CONFIGURATION_ANOMALYDETECTION_HH
#define CCE_CONFIGURATION_ANOMALYDETECTION_HH

#include "com/centreon/engine/common.hh"
#include "bbdo/neb.pb.h"
#include "com/centreon/engine/configuration/customvariable.hh"
#include "com/centreon/engine/configuration/group.hh"
#include "com/centreon/engine/configuration/object.hh"
Expand Down
16 changes: 10 additions & 6 deletions engine/inc/com/centreon/engine/configuration/file_info.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#ifndef CCE_CONFIGURATION_FILE_INFO_HH
#define CCE_CONFIGURATION_FILE_INFO_HH

#include "com/centreon/engine/exceptions/error.hh"

namespace com::centreon::engine {

namespace configuration {
Expand All @@ -47,10 +45,9 @@ class file_info {
bool operator!=(file_info const& right) const noexcept {
return !operator==(right);
}
friend exceptions::error& operator<<(exceptions::error& err,
file_info const& info) {
err << "in file '" << info.path() << "' on line " << info.line();
return err;
friend std::ostream& operator<<(std::ostream& s, file_info const& info) {
s << "in file '" << info.path() << "' on line " << info.line();
return s;
}
unsigned int line() const noexcept { return _line; }
void line(unsigned int line) noexcept { _line = line; }
Expand All @@ -61,4 +58,11 @@ class file_info {

} // namespace com::centreon::engine

namespace fmt {
// formatter specializations for fmt
template <>
struct formatter<com::centreon::engine::configuration::file_info>
: ostream_formatter {};
} // namespace fmt

#endif // !CCE_CONFIGURATION_FILE_INFO_HH
1 change: 0 additions & 1 deletion engine/inc/com/centreon/engine/configuration/host.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef CCE_CONFIGURATION_HOST_HH
#define CCE_CONFIGURATION_HOST_HH

#include "com/centreon/engine/common.hh"
#include "com/centreon/engine/configuration/customvariable.hh"
#include "com/centreon/engine/configuration/group.hh"
#include "com/centreon/engine/configuration/object.hh"
Expand Down
1 change: 0 additions & 1 deletion engine/inc/com/centreon/engine/configuration/service.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef CCE_CONFIGURATION_SERVICE_HH
#define CCE_CONFIGURATION_SERVICE_HH

#include "com/centreon/engine/common.hh"
#include "com/centreon/engine/configuration/customvariable.hh"
#include "com/centreon/engine/configuration/group.hh"
#include "com/centreon/engine/configuration/object.hh"
Expand Down
12 changes: 11 additions & 1 deletion engine/inc/com/centreon/engine/configuration/state.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "com/centreon/engine/configuration/severity.hh"
#include "com/centreon/engine/configuration/tag.hh"
#include "com/centreon/engine/configuration/timeperiod.hh"
#include "com/centreon/engine/logging/logger.hh"

namespace com::centreon::engine::configuration {

Expand All @@ -61,6 +60,17 @@ class setter_base {
* to manage configuration data.
*/
class state {
enum logger_type {
LOG_ALL = 2096895ull,
DBG_ALL = (4095ull << 32),
ALL = LOG_ALL | DBG_ALL,
};
enum logger_verbosity_level {
BASIC = 0u,
MORE = 1u,
MOST = 2u,
};

std::shared_ptr<spdlog::logger> _logger;

public:
Expand Down
Loading

0 comments on commit 74789b9

Please sign in to comment.