MCPcopy Create free account
hub / github.com/baidu/tera / ProcessMeta

Function ProcessMeta

src/admincli.cc:583–713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581}
582
583CliStatus ProcessMeta(const std::string& op, const TableMetaList& table_list,
584 const TabletMetaList& tablet_list, const std::string& start_key,
585 const std::string& end_key, const std::string& filename) {
586 int32_t table_num = table_list.meta_size();
587 int32_t tablet_num = tablet_list.meta_size();
588 if (table_num == 0 && tablet_num == 0) {
589 std::cout << "meta table is empty" << std::endl;
590 return CliStatus::kOk;
591 }
592
593 std::ofstream bak;
594 if (op == "backup") {
595 bak.open(filename, std::ofstream::trunc | std::ofstream::binary);
596 }
597
598 for (int32_t i = 0; i < table_num; ++i) {
599 const tera::TableMeta& meta = table_list.meta(i);
600 if (op == "show") {
601 std::cout << "table: " << meta.table_name() << std::endl;
602 int32_t lg_size = meta.schema().locality_groups_size();
603 for (int32_t lg_id = 0; lg_id < lg_size; lg_id++) {
604 const tera::LocalityGroupSchema& lg = meta.schema().locality_groups(lg_id);
605 std::cout << " lg" << lg_id << ": " << lg.name() << " (" << lg.store_type() << ", "
606 << lg.compress_type() << ", " << lg.block_size() << ")" << std::endl;
607 }
608 int32_t cf_size = meta.schema().column_families_size();
609 for (int32_t cf_id = 0; cf_id < cf_size; cf_id++) {
610 const tera::ColumnFamilySchema& cf = meta.schema().column_families(cf_id);
611 std::cout << " cf" << cf_id << ": " << cf.name() << " (" << cf.locality_group() << ", "
612 << cf.type() << ", " << cf.max_versions() << ", " << cf.time_to_live() << ")"
613 << std::endl;
614 }
615 }
616 if (op == "backup") {
617 WriteTable(meta, bak);
618 }
619 }
620
621 tera::TabletMeta last;
622 bool table_start = true;
623 for (int32_t i = 0; i < tablet_num; ++i) {
624 const tera::TabletMeta& meta = tablet_list.meta(i);
625 if (op == "show") {
626 std::string internal_startkey = meta.table_name() + "#" + meta.key_range().key_start();
627 std::string internal_endkey = meta.table_name() + "#" + meta.key_range().key_end();
628 if ((start_key == "" && end_key == "") ||
629 (start_key <= internal_startkey &&
630 (internal_startkey <= end_key || meta.table_name() + "#" == end_key))) {
631 std::cout << "tablet: " << meta.table_name() << " ["
632 << DebugString(meta.key_range().key_start()) << ","
633 << DebugString(meta.key_range().key_end()) << "], " << meta.path() << ", "
634 << meta.server_addr() << ", " << meta.size() << ", "
635 << StatusCodeToString(meta.status()) << ", "
636 << StatusCodeToString(meta.compact_status()) << std::endl;
637 }
638 }
639 if (op == "backup") {
640 WriteTablet(meta, bak);

Callers 3

MetaInternalOpFunction · 0.85
MetaShowOpFunction · 0.85
MetaHealthCheckOpFunction · 0.85

Calls 10

WriteTableFunction · 0.85
DebugStringFunction · 0.85
StatusCodeToStringFunction · 0.85
WriteTabletFunction · 0.85
openMethod · 0.80
typeMethod · 0.80
closeMethod · 0.80
sizeMethod · 0.45
statusMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected