-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feature](binlog) Add ingest_binlog/http_get_snapshot limit download speed && Add async ingest_binlog #26323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
425a397
f128de0
74f7795
94b45dd
51232ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -33,13 +33,20 @@ | |||||
| #include "runtime/exec_env.h" | ||||||
|
|
||||||
| namespace doris { | ||||||
|
|
||||||
| const std::string FILE_PARAMETER = "file"; | ||||||
| const std::string TOKEN_PARAMETER = "token"; | ||||||
|
|
||||||
| DownloadAction::DownloadAction(ExecEnv* exec_env, const std::vector<std::string>& allow_dirs, | ||||||
| int32_t num_workers) | ||||||
| : _exec_env(exec_env), _download_type(NORMAL), _num_workers(num_workers) { | ||||||
| namespace { | ||||||
| static const std::string FILE_PARAMETER = "file"; | ||||||
| static const std::string TOKEN_PARAMETER = "token"; | ||||||
|
Contributor
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. warning: 'TOKEN_PARAMETER' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
Suggested change
|
||||||
| static const std::string CHANNEL_PARAMETER = "channel"; | ||||||
|
Contributor
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. warning: 'CHANNEL_PARAMETER' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
Suggested change
|
||||||
| static const std::string CHANNEL_INGEST_BINLOG_TYPE = "ingest_binlog"; | ||||||
|
Contributor
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. warning: 'CHANNEL_INGEST_BINLOG_TYPE' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]
Suggested change
|
||||||
| } // namespace | ||||||
|
|
||||||
| DownloadAction::DownloadAction(ExecEnv* exec_env, | ||||||
| std::shared_ptr<bufferevent_rate_limit_group> rate_limit_group, | ||||||
| const std::vector<std::string>& allow_dirs, int32_t num_workers) | ||||||
| : _exec_env(exec_env), | ||||||
| _download_type(NORMAL), | ||||||
| _num_workers(num_workers), | ||||||
| _rate_limit_group(std::move(rate_limit_group)) { | ||||||
| for (auto& dir : allow_dirs) { | ||||||
| std::string p; | ||||||
| Status st = io::global_local_filesystem()->canonicalize(dir, &p); | ||||||
|
|
@@ -107,7 +114,13 @@ void DownloadAction::handle_normal(HttpRequest* req, const std::string& file_par | |||||
| if (is_dir) { | ||||||
| do_dir_response(file_param, req); | ||||||
| } else { | ||||||
| do_file_response(file_param, req); | ||||||
| const auto& channel = req->param(CHANNEL_PARAMETER); | ||||||
| bool ingest_binlog = (channel == CHANNEL_INGEST_BINLOG_TYPE); | ||||||
| if (ingest_binlog) { | ||||||
| do_file_response(file_param, req, _rate_limit_group.get()); | ||||||
| } else { | ||||||
| do_file_response(file_param, req); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| #include "http/http_channel.h" | ||
|
|
||
| #include <event2/buffer.h> | ||
|
Contributor
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. warning: 'event2/buffer.h' file not found [clang-diagnostic-error] #include <event2/buffer.h>
^ |
||
| #include <event2/bufferevent.h> | ||
| #include <event2/http.h> | ||
|
|
||
| #include <algorithm> | ||
|
|
@@ -69,11 +70,17 @@ void HttpChannel::send_reply(HttpRequest* request, HttpStatus status, const std: | |
| evbuffer_free(evb); | ||
| } | ||
|
|
||
| void HttpChannel::send_file(HttpRequest* request, int fd, size_t off, size_t size) { | ||
| void HttpChannel::send_file(HttpRequest* request, int fd, size_t off, size_t size, | ||
| bufferevent_rate_limit_group* rate_limit_group) { | ||
| auto evb = evbuffer_new(); | ||
| evbuffer_add_file(evb, fd, off, size); | ||
| evhttp_send_reply(request->get_evhttp_request(), HttpStatus::OK, | ||
| default_reason(HttpStatus::OK).c_str(), evb); | ||
| auto* evhttp_request = request->get_evhttp_request(); | ||
| if (rate_limit_group) { | ||
| auto* evhttp_connection = evhttp_request_get_connection(evhttp_request); | ||
| auto* buffer_event = evhttp_connection_get_bufferevent(evhttp_connection); | ||
| bufferevent_add_to_rate_limit_group(buffer_event, rate_limit_group); | ||
| } | ||
| evhttp_send_reply(evhttp_request, HttpStatus::OK, default_reason(HttpStatus::OK).c_str(), evb); | ||
| evbuffer_free(evb); | ||
| } | ||
|
|
||
|
|
||
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.
warning: 'FILE_PARAMETER' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]