| 326 | TabletNodeManager::~TabletNodeManager() { MutexLock lock(&mutex_); } |
| 327 | |
| 328 | TabletNodePtr TabletNodeManager::AddTabletNode(const std::string& addr, const std::string& uuid) { |
| 329 | MutexLock lock(&mutex_); |
| 330 | TabletNodePtr null_ptr; |
| 331 | std::pair<TabletNodeList::iterator, bool> ret = |
| 332 | tabletnode_list_.insert(std::pair<std::string, TabletNodePtr>(addr, null_ptr)); |
| 333 | TabletNodePtr& state = ret.first->second; |
| 334 | // already has one TS at the same IP:PORT addr, return the existing |
| 335 | // TabletNodePtr |
| 336 | if (!ret.second) { |
| 337 | TabletNodePtr existing_node = ret.first->second; |
| 338 | LOG(ERROR) << "tabletnode [" << addr << " exist, existing uuid: " << existing_node->uuid_ |
| 339 | << ", to be added uuid: " << uuid; |
| 340 | return existing_node; |
| 341 | } else { |
| 342 | LOG(INFO) << "add tabletnode : " << addr << ", id : " << uuid; |
| 343 | state.reset(new TabletNode(addr, uuid)); |
| 344 | } |
| 345 | // kReady represent heartbeat status |
| 346 | // state->SetState(kReady, NULL); |
| 347 | state->DoStateTransition(NodeEvent::kZkNodeCreated); |
| 348 | tabletnode_added_.Broadcast(); |
| 349 | return state; |
| 350 | } |
| 351 | |
| 352 | TabletNodePtr TabletNodeManager::DelTabletNode(const std::string& addr) { |
| 353 | TabletNodePtr state(nullptr); |
nothing calls this directly
no test coverage detected