Skip to content

Commit

Permalink
add pb_instance_configuration (#1198)
Browse files Browse the repository at this point in the history
REFS:MON-24655
  • Loading branch information
jean-christophe81 authored Mar 12, 2024
1 parent 26d01bb commit f10611f
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions bbdo/events.hh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ enum data_element {
de_pb_service_group = 51,
de_pb_service_group_member = 52,
de_pb_host_parent = 53,
de_pb_instance_configuration = 54
};
} // namespace neb
namespace storage {
Expand Down
7 changes: 7 additions & 0 deletions bbdo/neb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -733,3 +733,10 @@ message HostParent {
uint64 child_id = 3;
uint64 parent_id = 4;
}

/*io::neb, neb::de_pb_instance_configuration*/
message InstanceConfiguration {
BBDOHeader header = 1;
bool loaded = 2;
uint64 poller_id = 3;
}
3 changes: 2 additions & 1 deletion broker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ add_custom_command(
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out="${SRC_DIR}"
--proto_path=${SRC_DIR} --proto_path=${CMAKE_SOURCE_DIR}/common/src
${SRC_DIR}/broker.proto)
${SRC_DIR}/broker.proto
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

add_custom_target("target_broker_message" DEPENDS "${SRC_DIR}/broker.pb.cc"
"${SRC_DIR}/broker.pb.h")
Expand Down
3 changes: 2 additions & 1 deletion broker/grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ add_custom_command(
--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
--proto_path=${MODULE_DIR} --proto_path=${CMAKE_SOURCE_DIR}/bbdo
grpc_stream.proto
VERBATIM)
VERBATIM
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

# Testing.
if(WITH_TESTING)
Expand Down
3 changes: 3 additions & 0 deletions broker/neb/inc/com/centreon/broker/neb/internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ using pb_service_group_member =
make_type(io::neb, neb::de_pb_service_group_member)>;
using pb_host_parent =
io::protobuf<HostParent, make_type(io::neb, neb::de_pb_host_parent)>;
using pb_instance_configuration =
io::protobuf<InstanceConfiguration,
make_type(io::neb, neb::de_pb_instance_configuration)>;

} // namespace neb

Expand Down
4 changes: 4 additions & 0 deletions broker/neb/src/broker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ void broker_module_init(void const* arg) {

e.register_event(neb::pb_host_parent::static_type(), "HostParent",
&neb::pb_host_parent::operations, "hosts_hosts_parents");

e.register_event(neb::pb_instance_configuration::static_type(),
"InstanceConfiguration",
&neb::pb_instance_configuration::operations, "no_table");
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions broker/neb/src/initial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,18 @@ static void send_pb_service_list() {
send_service_list(neb::callback_pb_service);
}

/**
* Send the instance configuration loaded event.
*/
static void send_pb_instance_configuration() {
log_v2::neb()->info(
"init: sending initial instance configuration loading event");
auto ic = std::make_shared<neb::pb_instance_configuration>();
ic->mut_obj().set_loaded(true);
ic->mut_obj().set_poller_id(config::applier::state::instance().poller_id());
neb::gl_publisher.write(ic);
}

/**
* Send initial configuration to the global publisher.
*/
Expand Down Expand Up @@ -535,4 +547,5 @@ void neb::send_initial_pb_configuration() {
send_pb_service_group_list();
send_pb_host_dependencies_list();
send_pb_service_dependencies_list();
send_pb_instance_configuration();
}
4 changes: 3 additions & 1 deletion broker/unified_sql/src/stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ constexpr void (stream::*const stream::neb_processing_table[])(
&stream::_process_pb_host_group_member,
&stream::_process_pb_service_group,
&stream::_process_pb_service_group_member,
&stream::_process_pb_host_parent};
&stream::_process_pb_host_parent,
nullptr // pb_instance_configuration
};

constexpr size_t neb_processing_table_size =
sizeof(stream::neb_processing_table) /
Expand Down
3 changes: 2 additions & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ add_custom_command(
COMMENT "Generating interface files of the proto file (protobuf)"
OUTPUT ${SRC_DIR}/process_stat.pb.cc ${SRC_DIR}/process_stat.pb.h
COMMAND ${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out="${SRC_DIR}"
--proto_path=${SRC_DIR} ${SRC_DIR}/process_stat.proto)
--proto_path=${SRC_DIR} ${SRC_DIR}/process_stat.proto
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

# Set sources.
set(SOURCES ${SRC_DIR}/process_stat.cc ${SRC_DIR}/process_stat.pb.cc
Expand Down
3 changes: 2 additions & 1 deletion engine/enginerpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ add_custom_command(
COMMAND
${Protobuf_PROTOC_EXECUTABLE} ARGS --cpp_out="${ENGINERPC_DIR}"
--proto_path=${ENGINERPC_DIR} --proto_path=${CMAKE_SOURCE_DIR}/common/src
${ENGINERPC_DIR}/engine.proto)
${ENGINERPC_DIR}/engine.proto
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

add_custom_target(
engine_rpc
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/specific-duplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def create_md5_list(content):
0x10027, # pb_host_check
0x10028, # pb_service_check
0x1002e, # pb_responsive_instance
0x10036 # pb_instance_configuration
]:
if md5 in lst:
lst[md5] += 1
Expand Down Expand Up @@ -219,6 +220,7 @@ def create_md5_list(content):
0x10025, # pb_custom_variable
0x10027, # pb_host_check
0x10028, # pb_service_check
0x10036 # pb_instance_configuration
]:
if md5 in lst:
lst[md5] += 1
Expand Down

2 comments on commit f10611f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
19 1 0 20 95.00 0s

Failed Tests

Name Message ⏱️ Duration Suite
BDBM1 The stats file should contain at least 1 + 1 connections to the database. 0.000 s Sql

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
3 2 0 5 60.00 0s

Failed Tests

Name Message ⏱️ Duration Suite
BRCTS1 There should not exist queue map files. 0.000 s Reverse-Connection
BRCS1 There should not exist queue map files. 0.000 s Reverse-Connection

Please sign in to comment.