This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
feat(bulk-load): bulk load download part4 - replica report download status and progress #479
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,14 +426,94 @@ void replica_bulk_loader::report_bulk_load_states_to_meta(bulk_load_status::type | |
bool report_metadata, | ||
/*out*/ bulk_load_response &response) | ||
{ | ||
// TODO(heyuchen): TBD | ||
if (status() != partition_status::PS_PRIMARY) { | ||
response.err = ERR_INVALID_STATE; | ||
return; | ||
} | ||
|
||
if (report_metadata && !_metadata.files.empty()) { | ||
response.__set_metadata(_metadata); | ||
} | ||
|
||
switch (remote_status) { | ||
case bulk_load_status::BLS_DOWNLOADING: | ||
case bulk_load_status::BLS_DOWNLOADED: | ||
report_group_download_progress(response); | ||
break; | ||
// TODO(heyuchen): add other status | ||
default: | ||
break; | ||
} | ||
|
||
response.primary_bulk_load_status = _status; | ||
} | ||
|
||
// ThreadPool: THREAD_POOL_REPLICATION | ||
void replica_bulk_loader::report_group_download_progress(/*out*/ bulk_load_response &response) | ||
{ | ||
if (status() != partition_status::PS_PRIMARY) { | ||
dwarn_replica("replica status={}, should be {}", | ||
enum_to_string(status()), | ||
enum_to_string(partition_status::PS_PRIMARY)); | ||
response.err = ERR_INVALID_STATE; | ||
return; | ||
} | ||
|
||
partition_bulk_load_state primary_state; | ||
primary_state.__set_download_progress(_download_progress.load()); | ||
primary_state.__set_download_status(_download_status.load()); | ||
response.group_bulk_load_state[_replica->_primary_states.membership.primary] = primary_state; | ||
ddebug_replica("primary = {}, download progress = {}%, status = {}", | ||
_replica->_primary_states.membership.primary.to_string(), | ||
primary_state.download_progress, | ||
primary_state.download_status); | ||
|
||
int32_t total_progress = primary_state.download_progress; | ||
for (const auto &target_address : _replica->_primary_states.membership.secondaries) { | ||
const auto &secondary_state = | ||
_replica->_primary_states.secondary_bulk_load_states[target_address]; | ||
int32_t s_progress = | ||
secondary_state.__isset.download_progress ? secondary_state.download_progress : 0; | ||
error_code s_status = | ||
secondary_state.__isset.download_status ? secondary_state.download_status : ERR_OK; | ||
ddebug_replica("secondary = {}, download progress = {}%, status={}", | ||
target_address.to_string(), | ||
s_progress, | ||
s_status); | ||
response.group_bulk_load_state[target_address] = secondary_state; | ||
total_progress += s_progress; | ||
} | ||
|
||
total_progress /= _replica->_primary_states.membership.max_replica_count; | ||
ddebug_replica("total download progress = {}%", total_progress); | ||
response.__set_total_download_progress(total_progress); | ||
} | ||
|
||
// ThreadPool: THREAD_POOL_REPLICATION | ||
void replica_bulk_loader::report_bulk_load_states_to_primary( | ||
bulk_load_status::type remote_status, | ||
/*out*/ group_bulk_load_response &response) | ||
{ | ||
// TODO(heyuchen): TBD | ||
if (status() != partition_status::PS_SECONDARY) { | ||
response.err = ERR_INVALID_STATE; | ||
return; | ||
} | ||
|
||
partition_bulk_load_state bulk_load_state; | ||
auto local_status = _status; | ||
switch (remote_status) { | ||
case bulk_load_status::BLS_DOWNLOADING: | ||
case bulk_load_status::BLS_DOWNLOADED: | ||
bulk_load_state.__set_download_progress(_download_progress.load()); | ||
bulk_load_state.__set_download_status(_download_status.load()); | ||
Comment on lines
+505
to
+508
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We always report the two type of status, so why separate to two types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean that why not combine download progress and status into one structure? I used to define a structure called |
||
break; | ||
// TODO(heyuchen): add other status | ||
default: | ||
break; | ||
} | ||
|
||
response.status = local_status; | ||
response.bulk_load_state = bulk_load_state; | ||
} | ||
|
||
} // namespace replication | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about use float type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
total_progress
will report to meta server inbulk_load_response
, defined in thrift, it seems that we don't use float in thrift before, and I think it is okay to define it as integer.