You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2018/12/18 01:34:48 UTC
[GitHub] imay commented on a change in pull request #441: Add HttpClient
class
imay commented on a change in pull request #441: Add HttpClient class
URL: https://github.com/apache/incubator-doris/pull/441#discussion_r242380405
##########
File path: be/src/agent/pusher.cpp
##########
@@ -169,83 +117,80 @@ void Pusher::_get_file_name_from_path(const string& file_path, string* file_name
AgentStatus Pusher::process(vector<TTabletInfo>* tablet_infos) {
AgentStatus status = DORIS_SUCCESS;
-
- if (!_is_init) {
- OLAP_LOG_WARNING("has not init yet. tablet_id: %d", _push_req.tablet_id);
- return DORIS_ERROR;
- }
-
// Remote file not empty, need to download
if (_push_req.__isset.http_file_path) {
- // Get file length
+ // Get file length and timeout
uint64_t file_size = 0;
uint64_t estimate_time_out = DEFAULT_DOWNLOAD_TIMEOUT;
if (_push_req.__isset.http_file_size) {
file_size = _push_req.http_file_size;
- estimate_time_out =
- file_size / config::download_low_speed_limit_kbps / 1024;
+ estimate_time_out = file_size / config::download_low_speed_limit_kbps / 1024;
}
if (estimate_time_out < config::download_low_speed_time) {
estimate_time_out = config::download_low_speed_time;
}
-
- // Download file from hdfs
- for (uint32_t i = 0; i < MAX_RETRY; ++i) {
+ bool is_timeout = false;
+ auto download_cb = [this, estimate_time_out, file_size, &is_timeout] (HttpClient* client) {
// Check timeout and set timeout
time_t now = time(NULL);
-
- if (_push_req.timeout > 0) {
+ if (_push_req.timeout > 0 && _push_req.timeout < now) {
+ // return status to break this callback
VLOG(3) << "check time out. time_out:" << _push_req.timeout
- << ", now:" << now;
- if (_push_req.timeout < now) {
- OLAP_LOG_WARNING("push time out");
- status = DORIS_PUSH_TIME_OUT;
- break;
- }
+ << ", now:" << now;
+ is_timeout = true;
+ return Status::OK;
}
- _downloader_param.curl_opt_timeout = estimate_time_out;
+ RETURN_IF_ERROR(client->init(_remote_file_path));
Review comment:
Yes, this is a callback function with a `HttpClient` argument, it's callback's work to initialize this input `HttpClient`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org