Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make openbmp support redis subscription/population on sonic. #7

Merged
merged 48 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f3dc99b
Make openbmp support redis subscription/population on sonic.
FengPan-Frank Apr 9, 2024
d37c454
Make openbmp support redis subscription/population on sonic.
FengPan-Frank Apr 9, 2024
5130a39
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 7, 2024
c02fb34
Merge branch 'master' of https://github.com/FengPan-Frank/sonic-openb…
FengPan-Frank May 7, 2024
3e81104
Merge branch 'master' of https://github.com/FengPan-Frank/sonic-openb…
FengPan-Frank May 7, 2024
846efdd
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 8, 2024
32e46c9
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 8, 2024
3d318b0
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 9, 2024
3055ca0
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 9, 2024
8f9bcbe
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 9, 2024
306b26d
Merge branch 'master' into fenpan_openbmp_redis
FengPan-Frank May 11, 2024
18f9d20
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 9, 2024
70d036e
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 13, 2024
83edca5
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank May 13, 2024
3d1a087
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Sep 19, 2024
81f3699
Update AzurePipeline
FengPan-Frank Oct 17, 2024
fdc7809
Update AzurePipeline
FengPan-Frank Oct 17, 2024
b37ad43
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 17, 2024
c5cde33
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 17, 2024
b336f7a
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 17, 2024
1a12e1b
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 17, 2024
ea2b2e5
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 17, 2024
73f7499
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 17, 2024
d92e3ac
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 18, 2024
ebb2ba0
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 18, 2024
b7e0993
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 18, 2024
2d9436d
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 18, 2024
ab30185
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 18, 2024
6cadfc6
Fix comments
FengPan-Frank Oct 21, 2024
19eaffb
Fix comments for multiple asic
FengPan-Frank Oct 24, 2024
2d1d221
Fix comments for multiple asic
FengPan-Frank Oct 24, 2024
f096dee
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 24, 2024
46a9d86
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 24, 2024
ff7be6d
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 24, 2024
d472ae2
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 24, 2024
253e05c
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 24, 2024
1c8f4b1
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 24, 2024
18ed8d8
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Oct 24, 2024
770b83c
Fix comments
FengPan-Frank Nov 1, 2024
c9b4930
Fix comments
FengPan-Frank Nov 1, 2024
7227b99
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Nov 1, 2024
17d178d
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Nov 1, 2024
3335281
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Nov 2, 2024
76904f7
Remove initializeGlobalConfig
FengPan-Frank Nov 12, 2024
f35b88f
Remove initializeGlobalConfig
FengPan-Frank Nov 12, 2024
55593d6
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Nov 12, 2024
dc3d240
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Nov 12, 2024
cb079df
Merge branch 'fenpan_openbmp_redis' of https://github.com/FengPan-Fra…
FengPan-Frank Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 95 additions & 35 deletions Server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ else()
set(SSL_LIBS )
endif()

# cmake -DENABLE_REDIS=ON
option(ENABLE_REDIS "Enable Redis population" OFF)

# Add the compile flag
if(ENABLE_REDIS)
add_definitions(-DREDIS_ENABLED)
endif()

# Find and set the env for the mysql c++ connector
set(HINT_ROOT_DIR
Expand All @@ -33,30 +39,57 @@ find_library(LIBYAML_CPP_LIBRARY
lib64
lib)

find_path(LIBRDKAFKA_INCLUDE_DIR
librdkafka/rdkafkacpp.h
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
include)

find_library(LIBRDKAFKA_LIBRARY
NAMES
librdkafka.a rdkafka
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
lib64
lib)

find_library(LIBRDKAFKA_CPP_LIBRARY
NAMES
librdkafka++.a rdkafka++
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
lib64
lib)
if (NOT ENABLE_REDIS)
find_path(LIBRDKAFKA_INCLUDE_DIR
librdkafka/rdkafkacpp.h
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
include)

find_library(LIBRDKAFKA_LIBRARY
NAMES
librdkafka.a rdkafka
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
lib64
lib)

find_library(LIBRDKAFKA_CPP_LIBRARY
NAMES
librdkafka++.a rdkafka++
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
lib64
lib)
else ()
find_path(LIBSWSSCOMMON_INCLUDE_DIR
sonic-swss-common/common/dbconnector.h
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
include)

find_library(LIBHIREDIS_LIBRARY
NAMES
libhiredis.a hiredis
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
lib64
lib)

find_library(LIBSWSSCOMMON_LIBRARY
NAMES
libswsscommon.a libswsscommon
HINTS
${HINT_ROOT_DIR}
PATH_SUFFIXES
lib64
lib)
endif ()

find_library(LIBRT_LIBRARY
NAMES
Expand All @@ -67,10 +100,23 @@ find_library(LIBRT_LIBRARY
lib64
lib)

if (NOT LIBRDKAFKA_INCLUDE_DIR OR NOT LIBRDKAFKA_LIBRARY OR NOT LIBRDKAFKA_CPP_LIBRARY)
Message (FATAL_ERROR "Librdkafka was not found, cannot proceed. Visit https://github.com/edenhill/librdkafka for details on how to install it.")
#else ()
# Message ("lib = " ${LIBRDKAFKA_LIBRARY})
if (NOT ENABLE_REDIS)
if (NOT LIBRDKAFKA_INCLUDE_DIR OR NOT LIBRDKAFKA_LIBRARY OR NOT LIBRDKAFKA_CPP_LIBRARY)
Message (FATAL_ERROR "Librdkafka was not found, cannot proceed. Visit https://github.com/edenhill/librdkafka for details on how to install it.")
else ()
Message ("lib = " ${LIBRDKAFKA_LIBRARY})
endif()
else ()
if (NOT LIBHIREDIS_LIBRARY)
Message (FATAL_ERROR "Libhiredis was not found, cannot proceed. Visit https://github.com/redis/hiredis for details on how to install it.")
else ()
Message ("lib = " ${LIBHIREDIS_LIBRARY})
endif()
if (NOT LIBSWSSCOMMON_INCLUDE_DIR OR NOT LIBSWSSCOMMON_LIBRARY)
Message (FATAL_ERROR "swsscommon was not found, cannot proceed. Visit https://github.com/sonic-net/sonic-swss-common for details on how to install it.")
else ()
Message ("lib = " ${LIBSWSSCOMMON_LIBRARY})
endif()
endif()

if (NOT LIBYAML_CPP_INCLUDE_DIR OR NOT LIBYAML_CPP_LIBRARY)
Expand All @@ -82,19 +128,18 @@ if (NOT LIBRT_LIBRARY AND NOT MACOSX)
endif()

# Update the include dir
include_directories(${LIBRDKAFKA_INCLUDE_DIR} ${LIBYAML_CPP_INCLUDE_DIR} src/ src/bmp src/bgp src/bgp/linkstate src/kafka)
if (NOT ENABLE_REDIS)
include_directories(${LIBRDKAFKA_INCLUDE_DIR} ${LIBYAML_CPP_INCLUDE_DIR} src/ src/bmp src/bgp src/bgp/linkstate src/kafka)
else()
include_directories(${LIBSWSSCOMMON_INCLUDE_DIR} ${LIBYAML_CPP_INCLUDE_DIR} src/ src/bmp src/bgp src/bgp/linkstate src/redis)
endif()
#link_directories(${LIBRDKAFKA_LIBRARY})


# Define the source files to compile
set (SRC_FILES
src/bmp/BMPListener.cpp
src/bmp/BMPReader.cpp
src/kafka/MsgBusImpl_kafka.cpp
src/kafka/KafkaEventCallback.cpp
src/kafka/KafkaDeliveryReportCallback.cpp
src/kafka/KafkaTopicSelector.cpp
src/kafka/KafkaPeerPartitionerCallback.cpp
src/openbmp.cpp
src/bmp/parseBMP.cpp
src/md5.cpp
Expand All @@ -114,6 +159,17 @@ set (SRC_FILES
src/bgp/linkstate/MPLinkStateAttr.cpp
)

# Add specific files used
if (NOT ENABLE_REDIS)
# Add Kafka-specific source files
file(GLOB KAFKA_FILES src/kafka/MsgBusImpl_kafka.cpp src/kafka/KafkaEventCallback.cpp src/kafka/KafkaDeliveryReportCallback.cpp src/kafka/KafkaTopicSelector.cpp src/kafka/KafkaPeerPartitionerCallback.cpp)
list(APPEND SRC_FILES ${KAFKA_FILES})
else ()
# Add Redis-specific source files
file(GLOB REDIS_FILES src/RedisManager.cpp src/redis/MsgBusImpl_redis.cpp)
list(APPEND SRC_FILES ${REDIS_FILES})
endif ()

# Disable warnings
add_definitions ("-Wno-unused-result")

Expand All @@ -134,7 +190,11 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
endif()

# Set the libs to link
set (LIBS pthread ${LIBYAML_CPP_LIBRARY} ${LIBRDKAFKA_CPP_LIBRARY} ${LIBRDKAFKA_LIBRARY} z ${SSL_LIBS} dl)
if (NOT ENABLE_REDIS)
set (LIBS pthread ${LIBYAML_CPP_LIBRARY} ${LIBRDKAFKA_CPP_LIBRARY} ${LIBRDKAFKA_LIBRARY} z ${SSL_LIBS} dl)
else ()
set (LIBS pthread ${LIBYAML_CPP_LIBRARY} ${LIBHIREDIS_LIBRARY} ${LIBSWSSCOMMON_LIBRARY} z ${SSL_LIBS} dl)
endif ()

# Set the binary
add_executable (openbmpd ${SRC_FILES})
Expand Down
5 changes: 5 additions & 0 deletions Server/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
#include <boost/algorithm/string/replace.hpp>

#include "Config.h"

#ifndef REDIS_ENABLED
#include "kafka/KafkaTopicSelector.h"
#endif

/*********************************************************************//**
* Constructor for class
Expand Down Expand Up @@ -62,6 +65,7 @@ Config::Config() {
* The keys match the configuration node/vars. Topic name nodes will be ignored if
* not initialized here.
*/
#ifndef REDIS_ENABLED
topic_names_map[MSGBUS_TOPIC_VAR_COLLECTOR] = MSGBUS_TOPIC_COLLECTOR;
topic_names_map[MSGBUS_TOPIC_VAR_ROUTER] = MSGBUS_TOPIC_ROUTER;
topic_names_map[MSGBUS_TOPIC_VAR_PEER] = MSGBUS_TOPIC_PEER;
Expand All @@ -74,6 +78,7 @@ Config::Config() {
topic_names_map[MSGBUS_TOPIC_VAR_LS_PREFIX] = MSGBUS_TOPIC_LS_PREFIX;
topic_names_map[MSGBUS_TOPIC_VAR_L3VPN] = MSGBUS_TOPIC_L3VPN;
topic_names_map[MSGBUS_TOPIC_VAR_EVPN] = MSGBUS_TOPIC_EVPN;
#endif
}

/*********************************************************************//**
Expand Down
Loading