From 8aa34493c971f9ce681589d6f2f65c598a31122c Mon Sep 17 00:00:00 2001 From: Dan Wang Date: Thu, 5 Dec 2024 14:06:34 +0800 Subject: [PATCH] add ddl --- src/client/replication_ddl_client.cpp | 10 +++++++ src/client/replication_ddl_client.h | 4 +++ .../test/meta_duplication_service_test.cpp | 26 ++++++++++++++----- src/runtime/service_engine.cpp | 1 - src/shell/command_utils.h | 3 ++- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/client/replication_ddl_client.cpp b/src/client/replication_ddl_client.cpp index 3a0fc3a9c5..e993b35684 100644 --- a/src/client/replication_ddl_client.cpp +++ b/src/client/replication_ddl_client.cpp @@ -1416,6 +1416,16 @@ replication_ddl_client::query_dup(const std::string &app_name) return call_rpc_sync(duplication_query_rpc(std::move(req), RPC_CM_QUERY_DUPLICATION)); } +error_with +replication_ddl_client::list_dups(const std::string &app_name_pattern, + utils::pattern_match_type::type match_type) +{ + auto req = std::make_unique(); + req->app_name_pattern = app_name_pattern; + req->match_type = match_type; + return call_rpc_sync(duplication_list_rpc(std::move(req), RPC_CM_LIST_DUPLICATION)); +} + namespace { bool need_retry(uint32_t attempt_count, const dsn::error_code &err) diff --git a/src/client/replication_ddl_client.h b/src/client/replication_ddl_client.h index 2f891da2ec..4aab2ae7c4 100644 --- a/src/client/replication_ddl_client.h +++ b/src/client/replication_ddl_client.h @@ -60,6 +60,7 @@ #include "utils/flags.h" #include "utils/fmt_logging.h" #include "utils/ports.h" +#include "utils_types.h" DSN_DECLARE_uint32(ddl_client_max_attempt_count); DSN_DECLARE_uint32(ddl_client_retry_interval_ms); @@ -154,6 +155,9 @@ class replication_ddl_client error_with query_dup(const std::string &app_name); + error_with list_dups(const std::string &app_name_pattern, + utils::pattern_match_type::type match_type); + dsn::error_code do_restore(const std::string &backup_provider_name, const std::string &cluster_name, const std::string &policy_name, diff --git a/src/meta/test/meta_duplication_service_test.cpp b/src/meta/test/meta_duplication_service_test.cpp index 5e0ebe6b19..0fd6b6359a 100644 --- a/src/meta/test/meta_duplication_service_test.cpp +++ b/src/meta/test/meta_duplication_service_test.cpp @@ -65,6 +65,7 @@ #include "utils/error_code.h" #include "utils/fail_point.h" #include "utils/time_utils.h" +#include "utils_types.h" namespace dsn { namespace replication { @@ -142,6 +143,19 @@ class meta_duplication_service_test : public meta_test_base return rpc.response(); } + duplication_list_response list_dup_info(const std::string &app_name_pattern, + utils::pattern_match_type::type match_type) + { + auto req = std::make_unique(); + req->app_name_pattern = app_name_pattern; + req->match_type = match_type; + + duplication_list_rpc rpc(std::move(req), RPC_CM_LIST_DUPLICATION); + dup_svc().list_duplication_info(rpc.request(), rpc.response()); + + return rpc.response(); + } + duplication_modify_response change_dup_status(const std::string &app_name, dupid_t dupid, duplication_status::type status) { @@ -797,15 +811,15 @@ TEST_F(meta_duplication_service_test, query_duplication_info) auto resp = query_dup_info(kTestAppName); ASSERT_EQ(resp.err, ERR_OK); - ASSERT_EQ(resp.entry_list.size(), 1); - ASSERT_EQ(resp.entry_list.back().status, duplication_status::DS_PREPARE); - ASSERT_EQ(resp.entry_list.back().dupid, test_dup); - ASSERT_EQ(resp.appid, app->app_id); + ASSERT_EQ(1, resp.entry_list.size()); + ASSERT_EQ(duplication_status::DS_PREPARE, resp.entry_list.back().status); + ASSERT_EQ(test_dup, resp.entry_list.back().dupid); + ASSERT_EQ(app->app_id, resp.appid); change_dup_status(kTestAppName, test_dup, duplication_status::DS_REMOVED); resp = query_dup_info(kTestAppName); - ASSERT_EQ(resp.err, ERR_OK); - ASSERT_EQ(resp.entry_list.size(), 0); + ASSERT_EQ(ERR_OK, resp.err); + ASSERT_TRUE(resp.entry_list.empty()); } TEST_F(meta_duplication_service_test, re_add_duplication) diff --git a/src/runtime/service_engine.cpp b/src/runtime/service_engine.cpp index 12a7daa1ed..ed9e4b7a92 100644 --- a/src/runtime/service_engine.cpp +++ b/src/runtime/service_engine.cpp @@ -48,7 +48,6 @@ #include "utils/join_point.h" #include "utils/string_conv.h" #include "utils/strings.h" -#include "utils_types.h" namespace dsn { diff --git a/src/shell/command_utils.h b/src/shell/command_utils.h index 2e7f0783fb..2f254a8c9d 100644 --- a/src/shell/command_utils.h +++ b/src/shell/command_utils.h @@ -32,7 +32,8 @@ namespace dsn { class host_port; -} +} // namespace dsn + struct shell_context; inline bool validate_cmd(const argh::parser &cmd,