be/src/service/http/action/peer_cache_action.h
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 | | #pragma once |
19 | | |
20 | | #include <string> |
21 | | |
22 | | #include "common/status.h" |
23 | | #include "service/http/http_handler_with_auth.h" |
24 | | |
25 | | namespace doris { |
26 | | |
27 | | class HttpRequest; |
28 | | class ExecEnv; |
29 | | class CloudStorageEngine; |
30 | | |
31 | | // HTTP action for viewing and force-setting peer cache candidates. |
32 | | // |
33 | | // GET /api/peer_cache?op=show&tablet_id=12345 |
34 | | // Show TabletPeerCandidates for a specific tablet. |
35 | | // |
36 | | // GET /api/peer_cache?op=show_all[&limit=100] |
37 | | // Show all tablets with peer candidates (default limit 1000). |
38 | | // |
39 | | // POST /api/peer_cache?op=set&tablet_id=12345 |
40 | | // Body (JSON): |
41 | | // { |
42 | | // "candidates": [ |
43 | | // {"host":"10.0.0.1","brpc_port":8060,"compute_group_id":"cg1"} |
44 | | // ], |
45 | | // "last_successful_compute_group_id": "cg1", |
46 | | // "consecutive_all_miss": 0, |
47 | | // "cooldown_until_ms": 0 |
48 | | // } |
49 | | // |
50 | | // POST /api/peer_cache?op=remove&tablet_id=12345 |
51 | | // Remove all peer candidates for a tablet. |
52 | | // |
53 | | // POST /api/peer_cache?op=reset_cooldown&tablet_id=12345 |
54 | | // Reset cooldown state for a tablet. |
55 | | class PeerCacheAction : public HttpHandlerWithAuth { |
56 | | public: |
57 | | PeerCacheAction(ExecEnv* exec_env, CloudStorageEngine& engine) |
58 | 0 | : HttpHandlerWithAuth(exec_env), _engine(engine) {} |
59 | | |
60 | 0 | ~PeerCacheAction() override = default; |
61 | | |
62 | | void handle(HttpRequest* req) override; |
63 | | |
64 | | private: |
65 | | Status _handle_show(HttpRequest* req, std::string* result); |
66 | | Status _handle_show_all(HttpRequest* req, std::string* result); |
67 | | Status _handle_set(HttpRequest* req, std::string* result); |
68 | | Status _handle_remove(HttpRequest* req, std::string* result); |
69 | | Status _handle_reset_cooldown(HttpRequest* req, std::string* result); |
70 | | |
71 | | CloudStorageEngine& _engine; |
72 | | }; |
73 | | |
74 | | } // namespace doris |