Skip to content

Commit

Permalink
feat(split): add meta control split (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
hycdong authored Jan 13, 2021
1 parent ab9520d commit 20b2dfc
Show file tree
Hide file tree
Showing 12 changed files with 1,541 additions and 615 deletions.
1 change: 1 addition & 0 deletions include/dsn/dist/replication/replication.codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ MAKE_EVENT_CODE_RPC(RPC_CM_DUPLICATION_SYNC, TASK_PRIORITY_COMMON)
MAKE_EVENT_CODE_RPC(RPC_CM_UPDATE_APP_ENV, TASK_PRIORITY_COMMON)
MAKE_EVENT_CODE_RPC(RPC_CM_DDD_DIAGNOSE, TASK_PRIORITY_COMMON)
MAKE_EVENT_CODE_RPC(RPC_CM_START_PARTITION_SPLIT, TASK_PRIORITY_COMMON)
MAKE_EVENT_CODE_RPC(RPC_CM_CONTROL_PARTITION_SPLIT, TASK_PRIORITY_COMMON)
MAKE_EVENT_CODE_RPC(RPC_CM_REGISTER_CHILD_REPLICA, TASK_PRIORITY_COMMON)
MAKE_EVENT_CODE_RPC(RPC_CM_START_BULK_LOAD, TASK_PRIORITY_COMMON)
MAKE_EVENT_CODE_RPC(RPC_CM_CONTROL_BULK_LOAD, TASK_PRIORITY_COMMON)
Expand Down
11 changes: 11 additions & 0 deletions include/dsn/dist/replication/replication_ddl_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ class replication_ddl_client
// partition split
error_with<start_partition_split_response> start_partition_split(const std::string &app_name,
int partition_count);
error_with<control_split_response> pause_partition_split(const std::string &app_name,
const int32_t parent_pidx);
error_with<control_split_response> restart_partition_split(const std::string &app_name,
const int32_t parent_pidx);
error_with<control_split_response> cancel_partition_split(const std::string &app_name,
const int32_t old_partition_count);
error_with<control_split_response>
control_partition_split(const std::string &app_name,
split_control_type::type control_type,
const int32_t parent_pidx,
const int32_t old_partition_count);

private:
bool static valid_app_char(int c);
Expand Down
145 changes: 145 additions & 0 deletions include/dsn/dist/replication/replication_types.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,5 +1604,40 @@ replication_ddl_client::start_partition_split(const std::string &app_name, int n
return call_rpc_sync(start_split_rpc(std::move(req), RPC_CM_START_PARTITION_SPLIT));
}

error_with<control_split_response>
replication_ddl_client::pause_partition_split(const std::string &app_name,
const int32_t parent_pidx)
{
return control_partition_split(app_name, split_control_type::PAUSE, parent_pidx, 0);
}

error_with<control_split_response>
replication_ddl_client::restart_partition_split(const std::string &app_name,
const int32_t parent_pidx)
{
return control_partition_split(app_name, split_control_type::RESTART, parent_pidx, 0);
}

error_with<control_split_response>
replication_ddl_client::cancel_partition_split(const std::string &app_name,
const int32_t old_partition_count)
{
return control_partition_split(app_name, split_control_type::CANCEL, -1, old_partition_count);
}

error_with<control_split_response>
replication_ddl_client::control_partition_split(const std::string &app_name,
split_control_type::type control_type,
const int32_t parent_pidx,
const int32_t old_partition_count)
{
auto req = make_unique<control_split_request>();
req->__set_app_name(app_name);
req->__set_control_type(control_type);
req->__set_parent_pidx(parent_pidx);
req->__set_old_partition_count(old_partition_count);
return call_rpc_sync(control_split_rpc(std::move(req), RPC_CM_CONTROL_PARTITION_SPLIT));
}

} // namespace replication
} // namespace dsn
1 change: 1 addition & 0 deletions src/common/replication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef rpc_holder<control_bulk_load_request, control_bulk_load_response> contro
typedef rpc_holder<query_bulk_load_request, query_bulk_load_response> query_bulk_load_rpc;

typedef rpc_holder<start_partition_split_request, start_partition_split_response> start_split_rpc;
typedef rpc_holder<control_split_request, control_split_response> control_split_rpc;

class replication_options
{
Expand Down
Loading

0 comments on commit 20b2dfc

Please sign in to comment.