| 480 | } |
| 481 | |
| 482 | bool TabletNodeImpl::UnloadTablet(const std::string& tablet_name, const std::string& start, |
| 483 | const std::string& end, StatusCode* status) { |
| 484 | io::TabletIO* tablet_io = tablet_manager_->GetTablet(tablet_name, start, end, status); |
| 485 | if (tablet_io == NULL) { |
| 486 | LOG(WARNING) << "unload fail to get tablet: " << tablet_name << " [" << DebugString(start) |
| 487 | << ", " << DebugString(end) << "], status: " << StatusCodeToString(*status); |
| 488 | *status = kKeyNotInRange; |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | if (!tablet_io->Unload(status)) { |
| 493 | io::TabletIO::TabletStatus tablet_status = tablet_io->GetStatus(); |
| 494 | if (tablet_status == io::TabletIO::TabletStatus::kUnloading || |
| 495 | tablet_status == io::TabletIO::TabletStatus::kUnloading2) { |
| 496 | VLOG(6) << "ignore this unload tablet request: " << tablet_io->GetTablePath() << "[" |
| 497 | << DebugString(start) << "," << DebugString(end) |
| 498 | << "], status: " << StatusCodeToString((StatusCode)tablet_status); |
| 499 | } else { |
| 500 | LOG(ERROR) << "fail to unload tablet: " << tablet_io->GetTablePath() << " [" |
| 501 | << DebugString(start) << ", " << DebugString(end) |
| 502 | << "], status: " << StatusCodeToString(*status); |
| 503 | } |
| 504 | *status = (StatusCode)tablet_status; |
| 505 | tablet_io->DecRef(); |
| 506 | return false; |
| 507 | } |
| 508 | LOG(INFO) << "unload tablet: " << tablet_io->GetTablePath() << " [" << DebugString(start) << ", " |
| 509 | << DebugString(end) << "]"; |
| 510 | tablet_io->DecRef(); |
| 511 | |
| 512 | if (!tablet_manager_->RemoveTablet(tablet_name, start, end, status)) { |
| 513 | LOG(ERROR) << "fail to remove tablet: " << tablet_name << " [" << DebugString(start) << ", " |
| 514 | << DebugString(end) << "], status: " << StatusCodeToString(*status); |
| 515 | } |
| 516 | *status = kTabletNodeOk; |
| 517 | return true; |
| 518 | } |
| 519 | |
| 520 | void TabletNodeImpl::UnloadTablet(const UnloadTabletRequest* request, |
| 521 | UnloadTabletResponse* response) { |