be/src/service/http/action/pipeline_task_action.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #include "service/http/action/pipeline_task_action.h" |
19 | | |
20 | | #include <sstream> |
21 | | #include <string> |
22 | | |
23 | | #include "exec/pipeline/pipeline_fragment_context.h" |
24 | | #include "runtime/exec_env.h" |
25 | | #include "runtime/fragment_mgr.h" |
26 | | #include "service/http/http_channel.h" |
27 | | #include "service/http/http_headers.h" |
28 | | #include "service/http/http_request.h" |
29 | | #include "service/http/http_status.h" |
30 | | |
31 | | namespace doris { |
32 | | |
33 | 0 | void PipelineTaskAction::handle(HttpRequest* req) { |
34 | 0 | req->add_output_header(HttpHeaders::CONTENT_TYPE, "text/plain; version=0.0.4"); |
35 | 0 | HttpChannel::send_reply(req, HttpStatus::OK, |
36 | 0 | ExecEnv::GetInstance()->fragment_mgr()->dump_pipeline_tasks()); |
37 | 0 | } |
38 | | |
39 | 0 | void LongPipelineTaskAction::handle(HttpRequest* req) { |
40 | 0 | req->add_output_header(HttpHeaders::CONTENT_TYPE, "text/plain; version=0.0.4"); |
41 | 0 | int64_t duration = 0; |
42 | 0 | try { |
43 | 0 | duration = std::stoll(req->param("duration")); |
44 | 0 | } catch (const std::exception& e) { |
45 | 0 | fmt::memory_buffer debug_string_buffer; |
46 | 0 | fmt::format_to(debug_string_buffer, "invalid argument.duration: {}, meet error: {}", |
47 | 0 | req->param("duration"), e.what()); |
48 | 0 | LOG(WARNING) << fmt::to_string(debug_string_buffer); |
49 | 0 | HttpChannel::send_reply(req, HttpStatus::INTERNAL_SERVER_ERROR, |
50 | 0 | fmt::to_string(debug_string_buffer)); |
51 | 0 | return; |
52 | 0 | } |
53 | 0 | HttpChannel::send_reply(req, HttpStatus::OK, |
54 | 0 | ExecEnv::GetInstance()->fragment_mgr()->dump_pipeline_tasks(duration)); |
55 | 0 | } |
56 | | |
57 | 0 | void QueryPipelineTaskAction::handle(HttpRequest* req) { |
58 | 0 | req->add_output_header(HttpHeaders::CONTENT_TYPE, "text/plain; version=0.0.4"); |
59 | 0 | int64_t high = 0; |
60 | 0 | int64_t low = 0; |
61 | 0 | try { |
62 | 0 | auto& query_id_str = req->param("query_id"); |
63 | 0 | if (query_id_str.length() != 16 * 2 + 1) { |
64 | 0 | HttpChannel::send_reply( |
65 | 0 | req, HttpStatus::INTERNAL_SERVER_ERROR, |
66 | 0 | "Invalid query id! Query id should be {hi}-{lo} which is a hexadecimal. \n"); |
67 | 0 | return; |
68 | 0 | } |
69 | 0 | from_hex(&high, query_id_str.substr(0, 16)); |
70 | 0 | from_hex(&low, query_id_str.substr(17)); |
71 | 0 | } catch (const std::exception& e) { |
72 | 0 | fmt::memory_buffer debug_string_buffer; |
73 | 0 | fmt::format_to(debug_string_buffer, "invalid argument.query_id: {}, meet error: {}. \n", |
74 | 0 | req->param("query_id"), e.what()); |
75 | 0 | LOG(WARNING) << fmt::to_string(debug_string_buffer); |
76 | 0 | HttpChannel::send_reply(req, HttpStatus::INTERNAL_SERVER_ERROR, |
77 | 0 | fmt::to_string(debug_string_buffer)); |
78 | 0 | return; |
79 | 0 | } |
80 | 0 | TUniqueId query_id; |
81 | 0 | query_id.hi = high; |
82 | 0 | query_id.lo = low; |
83 | 0 | HttpChannel::send_reply(req, HttpStatus::OK, |
84 | 0 | ExecEnv::GetInstance()->fragment_mgr()->dump_pipeline_tasks(query_id)); |
85 | 0 | } |
86 | | |
87 | | } // end namespace doris |