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

Method Update

src/observer/executor/random_key_selector.cc:98–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void RandomKeySelector::Update() {
99 tera::ErrorCode err;
100 while (true) {
101 {
102 MutexLock locker(&quit_mutex_);
103 if (quit_) {
104 return;
105 }
106 cond_.TimeWaitInUs(FLAGS_observer_update_table_info_period_s * 1000000);
107 }
108
109 // update data first
110 std::shared_ptr<std::map<std::string, std::vector<tera::TabletInfo>>> table_update_copy(
111 new std::map<std::string, std::vector<tera::TabletInfo>>);
112
113 // updated table
114 for (uint32_t i = 0; i < observe_tables_.size(); ++i) {
115 std::string table_name = observe_tables_[i];
116
117 std::vector<tera::TabletInfo> tablets;
118 client_->GetTabletLocation(table_name, &tablets, &err);
119 if (tera::ErrorCode::kOK != err.GetType()) {
120 LOG(ERROR) << "Update table info failed, tablename:" << table_name
121 << " err:" << err.ToString();
122 continue;
123 }
124
125 table_update_copy->insert(
126 std::pair<std::string, std::vector<tera::TabletInfo>>(table_name, tablets));
127 }
128
129 // update pointer
130 MutexLock locker(&table_mutex_);
131 tables_.swap(table_update_copy);
132 }
133}
134
135} // namespace observer
136} // namespace tera

Callers

nothing calls this directly

Calls 7

TimeWaitInUsMethod · 0.80
insertMethod · 0.80
sizeMethod · 0.45
GetTabletLocationMethod · 0.45
GetTypeMethod · 0.45
ToStringMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected