| 46 | } |
| 47 | |
| 48 | void TabletAvailability::AddNotReadyTablet(const std::string& path, |
| 49 | const TabletMeta::TabletStatus& tablet_status) { |
| 50 | if (tablet_status == TabletMeta::kTabletReady || tablet_status == TabletMeta::kTabletDisable) { |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | MutexLock lock(&mutex_); |
| 55 | int64_t ts = get_micros(); |
| 56 | tablets_.insert(std::pair<std::string, int64_t>(path, ts)); |
| 57 | auto iter = not_ready_tablet_metrics_.emplace( |
| 58 | path, MetricCounter{metric_name_, |
| 59 | "table:" + GetNameFromPath(path) + ",tablet:" + path, |
| 60 | {SubscriberType::LATEST}, |
| 61 | false}); |
| 62 | |
| 63 | if (iter.second) { |
| 64 | VLOG(12) << "[Add NotReady To Metric]: " << static_cast<int64_t>(TabletErrorStatus::kNotReady); |
| 65 | iter.first->second.Set(static_cast<int64_t>(TabletErrorStatus::kNotReady)); |
| 66 | } else { |
| 67 | VLOG(12) << "[Add NotReady To Metric Failed]: " |
| 68 | << static_cast<int64_t>(TabletErrorStatus::kNotReady); |
| 69 | } |
| 70 | |
| 71 | if (tablets_hist_cost_[path].start_ts > 0) { |
| 72 | VLOG(10) << "notready again " << path; |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | tablets_hist_cost_[path].start_ts = ts; |
| 77 | tablets_hist_cost_[path].notready_num++; |
| 78 | VLOG(10) << "addnotready " << path << ", total_cost " << tablets_hist_cost_[path].total |
| 79 | << ", start_ts " << tablets_hist_cost_[path].start_ts << ", notready " |
| 80 | << tablets_hist_cost_[path].notready_num << ", reready " |
| 81 | << tablets_hist_cost_[path].reready_num; |
| 82 | } |
| 83 | |
| 84 | void TabletAvailability::EraseNotReadyTablet(const std::string& path) { |
| 85 | MutexLock lock(&mutex_); |
no test coverage detected