Skip to content

Commit

Permalink
add ddl
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Dec 5, 2024
1 parent 393c765 commit 8aa3449
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<duplication_list_response>
replication_ddl_client::list_dups(const std::string &app_name_pattern,
utils::pattern_match_type::type match_type)
{
auto req = std::make_unique<duplication_list_request>();
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)
Expand Down
4 changes: 4 additions & 0 deletions src/client/replication_ddl_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -154,6 +155,9 @@ class replication_ddl_client

error_with<duplication_query_response> query_dup(const std::string &app_name);

error_with<duplication_list_response> 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,
Expand Down
26 changes: 20 additions & 6 deletions src/meta/test/meta_duplication_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<duplication_list_request>();
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)
{
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/runtime/service_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "utils/join_point.h"
#include "utils/string_conv.h"
#include "utils/strings.h"
#include "utils_types.h"

namespace dsn {

Expand Down
3 changes: 2 additions & 1 deletion src/shell/command_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

namespace dsn {
class host_port;
}
} // namespace dsn

struct shell_context;

inline bool validate_cmd(const argh::parser &cmd,
Expand Down

0 comments on commit 8aa3449

Please sign in to comment.