Skip to content

Commit

Permalink
Merge branch 'master' into wk_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang Ce authored Oct 9, 2016
2 parents e227750 + 07150c8 commit 76ac3a2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
17 changes: 11 additions & 6 deletions src/nameserver/block_mapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions src/nameserver/chunkserver_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_++;
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/nameserver/nameserver_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,9 @@ bool NameServerImpl::WebService(const sofa::pbrpc::HTTPRequest& request,

table_str +=
"<table class=\"table\">"
"<tr><td>id</td><td>address</td><td>blocks</td><td>Data size</td>"
"<td>Disk quota</td><td>Disk used</td><td>Writing buffers</td>"
"<td>tag</td><td>status</td><td>last_check</td><tr>";
"<tr><td>ID</td><td>Address</td><td>Blocks</td><td>Size</td>"
"<td>Quota</td><td>Used</td><td>Buffers</td>"
"<td>Tag</td><td>Status</td><td>Check</td><td>Start</td><tr>";
int dead_num = 0;
int64_t total_quota = 0;
int64_t total_data = 0;
Expand Down Expand Up @@ -1216,6 +1216,8 @@ bool NameServerImpl::WebService(const sofa::pbrpc::HTTPRequest& request,
table_str += "</td><td>";
table_str += common::NumToString(
common::timer::now_time() - chunkserver.last_heartbeat());
table_str += "</td><td>";
table_str += chunkserver.start_time();
table_str += "</td></tr>";
}
table_str += "</table>";
Expand Down
1 change: 1 addition & 0 deletions src/proto/nameserver.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 76ac3a2

Please sign in to comment.