| 251 | } |
| 252 | |
| 253 | __attribute__((unused)) static void PrintTableInfo( |
| 254 | const std::vector<::fedb::nameserver::TableInfo>& tables) { |
| 255 | std::vector<std::string> row; |
| 256 | row.push_back("name"); |
| 257 | row.push_back("tid"); |
| 258 | row.push_back("pid"); |
| 259 | row.push_back("endpoint"); |
| 260 | row.push_back("role"); |
| 261 | row.push_back("is_alive"); |
| 262 | row.push_back("offset"); |
| 263 | row.push_back("record_cnt"); |
| 264 | row.push_back("memused"); |
| 265 | row.push_back("diskused"); |
| 266 | ::baidu::common::TPrinter tp(row.size(), FLAGS_max_col_display_length); |
| 267 | tp.AddRow(row); |
| 268 | int32_t row_width = row.size(); |
| 269 | for (const auto& value : tables) { |
| 270 | if (value.table_partition_size() == 0) { |
| 271 | row.clear(); |
| 272 | row.push_back(value.name()); |
| 273 | row.push_back(std::to_string(value.tid())); |
| 274 | for (int i = row.size(); i < row_width; i++) { |
| 275 | row.push_back("-"); |
| 276 | } |
| 277 | tp.AddRow(row); |
| 278 | continue; |
| 279 | } |
| 280 | for (int idx = 0; idx < value.table_partition_size(); idx++) { |
| 281 | if (value.table_partition(idx).partition_meta_size() == 0) { |
| 282 | row.clear(); |
| 283 | row.push_back(value.name()); |
| 284 | row.push_back(std::to_string(value.tid())); |
| 285 | row.push_back(std::to_string(value.table_partition(idx).pid())); |
| 286 | for (int i = row.size(); i < row_width; i++) { |
| 287 | row.push_back("-"); |
| 288 | } |
| 289 | tp.AddRow(row); |
| 290 | continue; |
| 291 | } |
| 292 | for (int meta_idx = 0; |
| 293 | meta_idx < value.table_partition(idx).partition_meta_size(); |
| 294 | meta_idx++) { |
| 295 | row.clear(); |
| 296 | row.push_back(value.name()); |
| 297 | row.push_back(std::to_string(value.tid())); |
| 298 | row.push_back(std::to_string(value.table_partition(idx).pid())); |
| 299 | row.push_back(value.table_partition(idx) |
| 300 | .partition_meta(meta_idx) |
| 301 | .endpoint()); |
| 302 | if (value.table_partition(idx) |
| 303 | .partition_meta(meta_idx) |
| 304 | .is_leader()) { |
| 305 | row.push_back("leader"); |
| 306 | } else { |
| 307 | row.push_back("follower"); |
| 308 | } |
| 309 | if (value.table_partition(idx) |
| 310 | .partition_meta(meta_idx) |
no test coverage detected