diff --git a/src/nameserver/block_mapping.cc b/src/nameserver/block_mapping.cc index 395a2405..325d9a8f 100644 --- a/src/nameserver/block_mapping.cc +++ b/src/nameserver/block_mapping.cc @@ -816,12 +816,17 @@ void BlockMapping::TryRecover(NSBlock* block) { } int64_t block_id = block->id; if (block->replica.size() < block->expect_replica_num) { - if (block->replica.size() == 0 && block->recover_stat != kLost) { - LOG(INFO, "[TryRecover] lost block #%ld ", block_id); - lost_blocks_.insert(block_id); - SetState(block, kLost); - lo_pri_recover_.erase(block_id); - hi_pri_recover_.erase(block_id); + if (block->replica.size() == 0) { + if (block->block_size && block->recover_stat != kLost) { + LOG(INFO, "[TryRecover] lost block #%ld ", block_id); + lost_blocks_.insert(block_id); + SetState(block, kLost); + lo_pri_recover_.erase(block_id); + hi_pri_recover_.erase(block_id); + } else if (block->block_size == 0 && block->recover_stat == kLost) { + lost_blocks_.erase(block_id); + LOG(WARNING, "[TryRecover] empty block #%ld remove from lost", block_id); + } } else if (block->replica.size() == 1 && block->recover_stat != kHiRecover) { hi_pri_recover_.insert(block_id); LOG(INFO, "[TryRecover] need more recover: #%ld %s->kHiRecover", diff --git a/src/nameserver/chunkserver_manager.cc b/src/nameserver/chunkserver_manager.cc index 6c058be3..279a22aa 100644 --- a/src/nameserver/chunkserver_manager.cc +++ b/src/nameserver/chunkserver_manager.cc @@ -214,6 +214,9 @@ void ChunkServerManager::HandleHeartBeat(const HeartBeatRequest* request, HeartB } else if (info->status() == kCsOffLine) { LOG(INFO, "Dead chunkserver revival C%d %s", cs_id, address.c_str()); assert(heartbeat_list_.find(info->last_heartbeat()) == heartbeat_list_.end()); + char buf[20]; + common::timer::now_time_str(buf, 20, common::timer::kMin); + info->set_start_time(std::string(buf)); info->set_is_dead(false); info->set_status(kCsActive); chunkserver_num_++; @@ -458,6 +461,9 @@ bool ChunkServerManager::UpdateChunkServer(int cs_id, const std::string& tag, in if (!GetChunkServerPtr(cs_id, &info)) { return false; } + char buf[20]; + common::timer::now_time_str(buf, 20, common::timer::kMin); + info->set_start_time(std::string(buf)); info->set_disk_quota(quota); info->set_tag(tag); if (info->status() != kCsReadonly) { @@ -481,6 +487,9 @@ int32_t ChunkServerManager::AddChunkServer(const std::string& address, mu_.AssertHeld(); ChunkServerInfo* info = new ChunkServerInfo; int32_t id = next_chunkserver_id_++; + char buf[20]; + common::timer::now_time_str(buf, 20, common::timer::kMin); + info->set_start_time(std::string(buf)); info->set_id(id); info->set_address(address); info->set_tag(tag); diff --git a/src/nameserver/nameserver_impl.cc b/src/nameserver/nameserver_impl.cc index b2586816..8d5730fa 100644 --- a/src/nameserver/nameserver_impl.cc +++ b/src/nameserver/nameserver_impl.cc @@ -1131,9 +1131,9 @@ bool NameServerImpl::WebService(const sofa::pbrpc::HTTPRequest& request, table_str += "" - "" - "" - ""; + "" + "" + ""; int dead_num = 0; int64_t total_quota = 0; int64_t total_data = 0; @@ -1216,6 +1216,8 @@ bool NameServerImpl::WebService(const sofa::pbrpc::HTTPRequest& request, table_str += ""; } table_str += "
idaddressblocksData sizeDisk quotaDisk usedWriting bufferstagstatuslast_check
IDAddressBlocksSizeQuotaUsedBuffersTagStatusCheckStart
"; table_str += common::NumToString( common::timer::now_time() - chunkserver.last_heartbeat()); + table_str += ""; + table_str += chunkserver.start_time(); table_str += "
"; diff --git a/src/proto/nameserver.proto b/src/proto/nameserver.proto index 51e487da..31c0231a 100644 --- a/src/proto/nameserver.proto +++ b/src/proto/nameserver.proto @@ -8,6 +8,7 @@ option cc_generic_services = true; message ChunkServerInfo { optional int32 id = 1; optional string address = 2; + optional string start_time = 17; optional int32 last_heartbeat = 3; optional int64 data_size = 4; optional int64 disk_quota = 5;