33
33
#include < thread>
34
34
#include < utility>
35
35
36
+ #include " cloud/cloud_meta_mgr.h"
36
37
#include " cloud/cloud_tablet.h"
37
38
#include " cloud/cloud_tablet_mgr.h"
38
39
#include " common/logging.h"
@@ -78,8 +79,8 @@ static Status _check_param(HttpRequest* req, uint64_t* tablet_id) {
78
79
return Status::OK ();
79
80
}
80
81
81
- Status CloudDeleteBitmapAction::_handle_show_delete_bitmap_count (HttpRequest* req,
82
- std::string* json_result) {
82
+ Status CloudDeleteBitmapAction::_handle_show_local_delete_bitmap_count (HttpRequest* req,
83
+ std::string* json_result) {
83
84
uint64_t tablet_id = 0 ;
84
85
// check & retrieve tablet_id from req if it contains
85
86
RETURN_NOT_OK_STATUS_WITH_WARN (_check_param (req, &tablet_id), " check param failed" );
@@ -95,7 +96,49 @@ Status CloudDeleteBitmapAction::_handle_show_delete_bitmap_count(HttpRequest* re
95
96
auto count = tablet->tablet_meta ()->delete_bitmap ().get_delete_bitmap_count ();
96
97
auto cardinality = tablet->tablet_meta ()->delete_bitmap ().cardinality ();
97
98
auto size = tablet->tablet_meta ()->delete_bitmap ().get_size ();
98
- LOG (INFO) << " show_delete_bitmap_count,tablet_id=" << tablet_id << " ,count=" << count
99
+ LOG (INFO) << " show_local_delete_bitmap_count,tablet_id=" << tablet_id << " ,count=" << count
100
+ << " ,cardinality=" << cardinality << " ,size=" << size;
101
+
102
+ rapidjson::Document root;
103
+ root.SetObject ();
104
+ root.AddMember (" delete_bitmap_count" , count, root.GetAllocator ());
105
+ root.AddMember (" cardinality" , cardinality, root.GetAllocator ());
106
+ root.AddMember (" size" , size, root.GetAllocator ());
107
+
108
+ // to json string
109
+ rapidjson::StringBuffer strbuf;
110
+ rapidjson::PrettyWriter<rapidjson::StringBuffer> writer (strbuf);
111
+ root.Accept (writer);
112
+ *json_result = std::string (strbuf.GetString ());
113
+
114
+ return Status::OK ();
115
+ }
116
+
117
+ Status CloudDeleteBitmapAction::_handle_show_ms_delete_bitmap_count (HttpRequest* req,
118
+ std::string* json_result) {
119
+ uint64_t tablet_id = 0 ;
120
+ // check & retrieve tablet_id from req if it contains
121
+ RETURN_NOT_OK_STATUS_WITH_WARN (_check_param (req, &tablet_id), " check param failed" );
122
+ if (tablet_id == 0 ) {
123
+ return Status::InternalError (" check param failed: missing tablet_id" );
124
+ }
125
+ TabletMetaSharedPtr tablet_meta;
126
+ auto st = _engine.meta_mgr ().get_tablet_meta (tablet_id, &tablet_meta);
127
+ if (!st.ok ()) {
128
+ LOG (WARNING) << " failed to get_tablet_meta tablet=" << tablet_id
129
+ << " , st=" << st.to_string ();
130
+ return st;
131
+ }
132
+ auto tablet = std::make_shared<CloudTablet>(_engine, std::move (tablet_meta));
133
+ st = _engine.meta_mgr ().sync_tablet_rowsets (tablet.get (), false , true , true );
134
+ if (!st.ok ()) {
135
+ LOG (WARNING) << " failed to sync tablet=" << tablet_id << " , st=" << st;
136
+ return st;
137
+ }
138
+ auto count = tablet->tablet_meta ()->delete_bitmap ().get_delete_bitmap_count ();
139
+ auto cardinality = tablet->tablet_meta ()->delete_bitmap ().cardinality ();
140
+ auto size = tablet->tablet_meta ()->delete_bitmap ().get_size ();
141
+ LOG (INFO) << " show_ms_delete_bitmap_count,tablet_id=" << tablet_id << " ,count=" << count
99
142
<< " ,cardinality=" << cardinality << " ,size=" << size;
100
143
101
144
rapidjson::Document root;
@@ -115,9 +158,17 @@ Status CloudDeleteBitmapAction::_handle_show_delete_bitmap_count(HttpRequest* re
115
158
116
159
void CloudDeleteBitmapAction::handle (HttpRequest* req) {
117
160
req->add_output_header (HttpHeaders::CONTENT_TYPE, HEADER_JSON.data ());
118
- if (_delete_bitmap_action_type == DeleteBitmapActionType::COUNT_INFO) {
161
+ if (_delete_bitmap_action_type == DeleteBitmapActionType::COUNT_LOCAL) {
162
+ std::string json_result;
163
+ Status st = _handle_show_local_delete_bitmap_count (req, &json_result);
164
+ if (!st.ok ()) {
165
+ HttpChannel::send_reply (req, HttpStatus::OK, st.to_json ());
166
+ } else {
167
+ HttpChannel::send_reply (req, HttpStatus::OK, json_result);
168
+ }
169
+ } else if (_delete_bitmap_action_type == DeleteBitmapActionType::COUNT_MS) {
119
170
std::string json_result;
120
- Status st = _handle_show_delete_bitmap_count (req, &json_result);
171
+ Status st = _handle_show_ms_delete_bitmap_count (req, &json_result);
121
172
if (!st.ok ()) {
122
173
HttpChannel::send_reply (req, HttpStatus::OK, st.to_json ());
123
174
} else {
0 commit comments