[TransferEngine] build: add USE_TCP option to control enable tcp transport or not (#282)

Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
This commit is contained in:
Eryu Guan 2025-04-23 18:55:22 +08:00 committed by GitHub
parent 2fd8240ad7
commit 9ce2e203d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 5 deletions

View File

@ -41,6 +41,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(USE_CUDA "option for using gpu direct" OFF)
option(USE_NVMEOF "option for using NVMe over Fabric" OFF)
option(USE_TCP "option for using TCP transport" ON)
option(USE_CXL "option for using cxl protocol" OFF)
option(USE_ETCD "option for enable etcd as metadata server" ON)
option(USE_ETCD_LEGACY "option for enable etcd based on etcd-cpp-api-v3" OFF)
@ -74,6 +75,10 @@ elseif(USE_NVMEOF)
message(FATAL_ERROR "Cannot enable USE_NVMEOF without USE_CUDA")
endif()
if (USE_TCP)
add_compile_definitions(USE_TCP)
endif()
if (USE_REDIS)
add_compile_definitions(USE_REDIS)
message(STATUS "Redis as metadata server support is enabled")

View File

@ -22,6 +22,7 @@ if (NOT GLOBAL_CONFIG)
option(USE_ETCD_LEGACY "option for enable etcd based on etcd-cpp-api-v3" OFF)
option(USE_CUDA "option for using gpu direct" OFF)
option(USE_NVMEOF "option for using NVMe over Fabric" OFF)
option(USE_TCP "option for using TCP transport" ON)
option(USE_CXL "option for using cxl protocol" OFF)
option(USE_REDIS "option for enable redis as metadata server" OFF)
option(USE_HTTP "option for enable http as metadata server" ON)
@ -29,6 +30,10 @@ if (NOT GLOBAL_CONFIG)
add_definitions(-DCONFIG_ERDMA)
if (USE_TCP)
add_compile_definitions(USE_TCP)
endif()
if (USE_CUDA)
add_compile_definitions(USE_CUDA)
message(STATUS "CUDA support is enabled")

View File

@ -15,7 +15,9 @@
#include "multi_transport.h"
#include "transport/rdma_transport/rdma_transport.h"
#ifdef USE_TCP
#include "transport/tcp_transport/tcp_transport.h"
#endif
#include "transport/transport.h"
#ifdef USE_NVMEOF
#include "transport/nvmeof_transport/nvmeof_transport.h"
@ -128,9 +130,12 @@ Transport *MultiTransport::installTransport(const std::string &proto,
Transport *transport = nullptr;
if (std::string(proto) == "rdma") {
transport = new RdmaTransport();
} else if (std::string(proto) == "tcp") {
}
#ifdef USE_TCP
else if (std::string(proto) == "tcp") {
transport = new TcpTransport();
}
#endif
#ifdef USE_NVMEOF
else if (std::string(proto) == "nvmeof") {
transport = new NVMeoFTransport();
@ -179,4 +184,4 @@ std::vector<Transport *> MultiTransport::listTransports() {
return transport_list;
}
} // namespace mooncake
} // namespace mooncake

View File

@ -3,8 +3,10 @@ file(GLOB XPORT_SOURCES "*.cpp")
add_subdirectory(rdma_transport)
add_library(transport OBJECT ${XPORT_SOURCES} $<TARGET_OBJECTS:rdma_transport>)
add_subdirectory(tcp_transport)
target_sources(transport PUBLIC $<TARGET_OBJECTS:tcp_transport>)
if (USE_TCP)
add_subdirectory(tcp_transport)
target_sources(transport PUBLIC $<TARGET_OBJECTS:tcp_transport>)
endif()
if (USE_NVMEOF)
add_subdirectory(nvmeof_transport)
@ -14,4 +16,4 @@ endif()
if (USE_CXL)
add_subdirectory(cxl_transport)
target_sources(transport PUBLIC $<TARGET_OBJECTS:cxl_transport>)
endif()
endif()

View File

@ -20,9 +20,11 @@ if (USE_NVMEOF)
# add_test(NAME nvmeof_transport_test COMMAND nvmeof_transport_test)
endif()
if (USE_TCP)
add_executable(tcp_transport_test tcp_transport_test.cpp)
target_link_libraries(tcp_transport_test PUBLIC transfer_engine gtest gtest_main )
add_test(NAME tcp_transport_test COMMAND tcp_transport_test)
endif()
add_executable(transfer_metadata_test transfer_metadata_test.cpp)
target_link_libraries(transfer_metadata_test PUBLIC transfer_engine gtest gtest_main)