Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions be/src/http/action/tablets_info_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,37 @@ void TabletsInfoAction::handle(HttpRequest *req) {
}

EasyJson TabletsInfoAction::get_tablets_info(string tablet_num_to_return) {
std::vector<TabletInfo> tablets_info;
TabletManager* tablet_manager = StorageEngine::instance()->tablet_manager();
tablet_manager->obtain_all_tablets(tablets_info);

int64_t number;
std::string msg;
if (tablet_num_to_return == "") {
number = 1000; // default
msg = "OK";
} else if (tablet_num_to_return == "all") {
number = tablets_info.size();
number = std::numeric_limits<std::int64_t>::max();
msg = "OK";
} else if (std::all_of(tablet_num_to_return.begin(), tablet_num_to_return.end(), ::isdigit)) {
int64_t tablet_num = std::atol(tablet_num_to_return.c_str());
number = tablet_num < tablets_info.size() ? tablet_num : tablets_info.size();
number = std::atol(tablet_num_to_return.c_str());
msg = "OK";
} else {
number = 0;
msg = "Parameter Error";
}
std::vector<TabletInfo> tablets_info;
TabletManager* tablet_manager = StorageEngine::instance()->tablet_manager();
tablet_manager->obtain_specific_quantity_tablets(tablets_info, number);

EasyJson tablets_info_ej;
tablets_info_ej["msg"] = msg;
tablets_info_ej["code"] = 0;
EasyJson data = tablets_info_ej.Set("data", EasyJson::kObject);
data["host"] = _host;
EasyJson tablets = data.Set("tablets", EasyJson::kArray);
for (int64_t i = 0; i < number; i++) {
for (TabletInfo tablet_info : tablets_info) {
EasyJson tablet = tablets.PushBack(EasyJson::kObject);
tablet["tablet_id"] = tablets_info[i].tablet_id;
tablet["schema_hash"] = tablets_info[i].schema_hash;
tablet["tablet_id"] = tablet_info.tablet_id;
tablet["schema_hash"] = tablet_info.schema_hash;
}
tablets_info_ej["count"] = number;
tablets_info_ej["count"] = tablets_info.size();
return tablets_info_ej;
}
} // namespace doris
Expand Down
5 changes: 4 additions & 1 deletion be/src/olap/tablet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,11 +1455,14 @@ void TabletManager::_remove_tablet_from_partition(const Tablet& tablet) {
}
}

void TabletManager::obtain_all_tablets(vector<TabletInfo> &tablets_info) {
void TabletManager::obtain_specific_quantity_tablets(vector<TabletInfo> &tablets_info, int64_t num) {
for (int32 i = 0; i < _tablet_map_lock_shard_size; i++) {
ReadLock rdlock(&_tablet_map_lock_array[i]);
for (const auto& item : _tablet_map_array[i]) {
for (TabletSharedPtr tablet : item.second.table_arr) {
if (tablets_info.size() >= num) {
return;
}
if (tablet == nullptr) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/tablet_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class TabletManager {

void do_tablet_meta_checkpoint(DataDir* data_dir);

void obtain_all_tablets(vector<TabletInfo> &tablets_info);
void obtain_specific_quantity_tablets(vector<TabletInfo> &tablets_info, int64_t num);

void register_clone_tablet(int64_t tablet_id);
void unregister_clone_tablet(int64_t tablet_id);
Expand Down