| 4316 | } |
| 4317 | |
| 4318 | void HandleClientGetFollower(const std::vector<std::string>& parts, |
| 4319 | ::fedb::client::TabletClient* client) { |
| 4320 | if (parts.size() < 3) { |
| 4321 | std::cout << "Bad get follower format" << std::endl; |
| 4322 | return; |
| 4323 | } |
| 4324 | uint32_t tid = 0; |
| 4325 | uint32_t pid = 0; |
| 4326 | try { |
| 4327 | tid = boost::lexical_cast<uint32_t>(parts[1]); |
| 4328 | pid = boost::lexical_cast<uint32_t>(parts[2]); |
| 4329 | } catch (std::exception const& e) { |
| 4330 | std::cout << "Invalid args" << std::endl; |
| 4331 | return; |
| 4332 | } |
| 4333 | std::map<std::string, uint64_t> info_map; |
| 4334 | uint64_t offset = 0; |
| 4335 | std::string msg; |
| 4336 | if (!client->GetTableFollower(tid, pid, offset, info_map, msg)) { |
| 4337 | std::cout << "get failed. msg: " << msg << std::endl; |
| 4338 | return; |
| 4339 | } |
| 4340 | std::vector<std::string> header; |
| 4341 | header.push_back("#"); |
| 4342 | header.push_back("tid"); |
| 4343 | header.push_back("pid"); |
| 4344 | header.push_back("leader_offset"); |
| 4345 | header.push_back("follower"); |
| 4346 | header.push_back("offset"); |
| 4347 | ::baidu::common::TPrinter tp(header.size(), FLAGS_max_col_display_length); |
| 4348 | |
| 4349 | tp.AddRow(header); |
| 4350 | int idx = 0; |
| 4351 | for (const auto& kv : info_map) { |
| 4352 | std::vector<std::string> row; |
| 4353 | row.push_back(std::to_string(idx)); |
| 4354 | idx++; |
| 4355 | row.push_back(std::to_string(tid)); |
| 4356 | row.push_back(std::to_string(pid)); |
| 4357 | row.push_back(std::to_string(offset)); |
| 4358 | row.push_back(kv.first); |
| 4359 | row.push_back(std::to_string(kv.second)); |
| 4360 | tp.AddRow(row); |
| 4361 | } |
| 4362 | tp.Print(true); |
| 4363 | } |
| 4364 | |
| 4365 | void HandleClientCount(const std::vector<std::string>& parts, |
| 4366 | ::fedb::client::TabletClient* client) { |
no test coverage detected