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

Method SplitTablet

src/master/tablet_manager.cc:849–890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847}
848
849void Table::SplitTablet(TabletPtr splited_tablet, const TabletMeta& first_half,
850 const TabletMeta& second_half, TabletPtr* first_tablet,
851 TabletPtr* second_tablet) {
852 CHECK_EQ(splited_tablet->GetKeyStart(), first_half.key_range().key_start());
853 CHECK_EQ(splited_tablet->GetKeyEnd(), second_half.key_range().key_end());
854 CHECK_EQ(first_half.key_range().key_end(), second_half.key_range().key_start());
855
856 MutexLock lock(&mutex_);
857 uint64_t tablet_num1 = leveldb::GetTabletNumFromPath(first_half.path());
858 if (max_tablet_no_ < tablet_num1) {
859 max_tablet_no_ = tablet_num1;
860 }
861 uint64_t tablet_num2 = leveldb::GetTabletNumFromPath(second_half.path());
862 if (max_tablet_no_ < tablet_num2) {
863 max_tablet_no_ = tablet_num2;
864 }
865
866 {
867 uint64_t tablet_num = leveldb::GetTabletNumFromPath(splited_tablet->GetPath());
868 (*first_tablet)->inh_files_ = splited_tablet->inh_files_;
869 (*second_tablet)->inh_files_ = splited_tablet->inh_files_;
870 std::multiset<TabletFile>::iterator it = splited_tablet->inh_files_.begin();
871 for (; it != splited_tablet->inh_files_.end(); ++it) {
872 const TabletFile& file = *it;
873 InheritedFileInfo& file_info = useful_inh_files_[file.tablet_id][file];
874 CHECK_GT(file_info.ref, 0u);
875 file_info.ref++; // ref: +2 for add child tablets, -1 for del parent tablets
876 VLOG(10) << "[gc] [" << name_ << "] file " << file << " inherited by " << tablet_num
877 << " pass to " << tablet_num1 << " and " << tablet_num2 << " ref increment to "
878 << file_info.ref;
879 }
880
881 if (splited_tablet->gc_reported_) {
882 --reported_live_tablets_num_;
883 }
884 }
885
886 MasterEnv().GetTabletAvailability()->EraseNotReadyTablet(splited_tablet->GetPath());
887 tablets_list_.erase(first_half.key_range().key_start());
888 tablets_list_[first_half.key_range().key_start()] = *first_tablet;
889 tablets_list_[second_half.key_range().key_start()] = *second_tablet;
890}
891
892void Table::GarbageCollect(const TabletInheritedFileInfo& tablet_inh_info) {
893 // sort reported files

Callers 3

UpdateMetaDoneMethod · 0.80
TestSplitMethod · 0.80
TestGarbageCollect3Method · 0.80

Calls 3

GetTabletNumFromPathFunction · 0.85
EraseNotReadyTabletMethod · 0.80
GetTabletAvailabilityMethod · 0.80

Tested by 2

TestSplitMethod · 0.64
TestGarbageCollect3Method · 0.64