Skip to content

Commit 32513bf

Browse files
FrankielxFrankie_lx
andauthored
[Feat] add connection manager (#978)
## Purpose Add connection manager to kv asu transport ## Modifications - **ConnectionManager**: connection pool, which manages the three-layer connection model: Pool (NPU->ASU:config) → Group (IP:Endpoint) → Channel (QP) 1. As a member of AsuTransportImpl, the ConnectionManager registers the link creation/deletion interface and link parameter information with AsuTransportImpl. There is no derived class, and it is applicable to different AsuTransportImpls. 2. Provides the following external interfaces: initialization, destruction, route selection (RoundRobin/LeastLoaded), and exception reporting (marking the channel status and adding the channel to the exception list). 3. The background thread automatically re-establishes faulty channels. (It checks the exception list, checks the inflight count of the channel, and determines whether the channel can be destroyed and re-established.) ## Test connection_concurrent_test.cc、connection_manager_test.cc、connection_transport_test.cc <img width="1081" height="925" alt="img_v3_02125_ae50282f-bb62-4c6e-810b-99f2a459ce5g" src="https://github.com/user-attachments/assets/f8542fb1-4909-43d7-a08a-e51443bcc536" /> Co-authored-by: Frankie_lx <Frankie_lx@noreply.gitcode.com>
1 parent 877946d commit 32513bf

19 files changed

Lines changed: 2303 additions & 12 deletions

ucm/transport/kv/asu/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target_include_directories(asu_transport
88
${CMAKE_CURRENT_SOURCE_DIR}/trans/src
99
${UCM_ROOT_DIR}/ucm/shared/infra
1010
)
11-
target_link_libraries(asu_transport PUBLIC pthread)
11+
target_link_libraries(asu_transport PUBLIC infra_logger pthread)
1212

1313
file(GLOB ASU_CLIENT_SOURCES CONFIGURE_DEPENDS client/src/*.cpp)
1414
add_library(asu_client SHARED ${ASU_CLIENT_SOURCES})
@@ -25,15 +25,18 @@ target_include_directories(asu_client
2525
target_link_libraries(asu_client PUBLIC asu_transport kv_common pthread)
2626

2727
if(BUILD_UNIT_TESTS)
28+
target_compile_definitions(asu_transport PRIVATE ASU_BUILD_TESTS)
2829
include(GoogleTest)
2930
file(GLOB_RECURSE ASU_TEST_SOURCE_FILES CONFIGURE_DEPENDS test/case/*.cc)
3031
file(GLOB_RECURSE ASU_CLIENT_TEST_SOURCE_FILES CONFIGURE_DEPENDS client/test/*.cpp)
3132
list(APPEND ASU_TEST_SOURCE_FILES ${ASU_CLIENT_TEST_SOURCE_FILES})
3233
add_executable(asu.test ${ASU_TEST_SOURCE_FILES})
34+
target_compile_definitions(asu.test PRIVATE ASU_BUILD_TESTS)
3335
target_include_directories(asu.test PRIVATE
3436
${CMAKE_CURRENT_SOURCE_DIR}/common
3537
${CMAKE_CURRENT_SOURCE_DIR}/client/src
3638
${CMAKE_CURRENT_SOURCE_DIR}/trans/src
39+
${UCM_ROOT_DIR}/ucm/shared/infra
3740
)
3841
target_link_libraries(asu.test PRIVATE
3942
asu_client

ucm/transport/kv/asu/client/test/asu_client_impl_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ class FakeTransport : public AsuTransport {
195195
return Check(taskId, result);
196196
}
197197

198+
Status StubCheck(TaskId taskId, TaskResult& result) override { return Check(taskId, result); }
199+
200+
Status StubWait(TaskId taskId, std::uint64_t timeoutMs, TaskResult& result) override
201+
{
202+
return Wait(taskId, timeoutMs, result);
203+
}
204+
198205
Status RegisterRegions(const std::vector<MemoryRegion>& regions,
199206
std::vector<RegisterResult>& results) override
200207
{

ucm/transport/kv/asu/common/task_manager_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class TaskManagerBase {
8888
return Status::OK();
8989
}
9090

91-
private:
91+
protected:
9292
State initialState_;
9393
std::string taskName_;
9494
std::atomic<TaskId> nextTaskId_{1};

ucm/transport/kv/asu/test/case/asu_client_e2e_metrics_test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,13 @@ class InMemoryAsuTransport final : public AsuTransport {
451451
return Check(taskId, result);
452452
}
453453

454+
Status StubCheck(TaskId taskId, TaskResult& result) override { return Check(taskId, result); }
455+
456+
Status StubWait(TaskId taskId, std::uint64_t timeoutMs, TaskResult& result) override
457+
{
458+
return Wait(taskId, timeoutMs, result);
459+
}
460+
454461
Status RegisterRegions(const std::vector<MemoryRegion>& regions,
455462
std::vector<RegisterResult>& results) override
456463
{

0 commit comments

Comments
 (0)