Skip to content

Commit

Permalink
remove magic number (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
taotaowill authored and bluebore committed Jun 20, 2017
1 parent 51a64ba commit d540d18
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Binary file added src/.flags.cc.swo
Binary file not shown.
Binary file added src/.flags.cc.swp
Binary file not shown.
3 changes: 2 additions & 1 deletion src/flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ DEFINE_int32(chunkserver_use_root_partition, 1, "Should chunkserver use root par
DEFINE_bool(chunkserver_multi_path_on_one_disk, false, "Allow multi data path on one disk");
DEFINE_bool(chunkserver_auto_clean, true, "If namespace version mismatch, chunkserver clean itself");
DEFINE_int32(chunkserver_disk_buf_size, 100, "Base number of buffers which are in the waiting list. Used to computer disk wordload");
DEFINE_int64(chunkserver_disk_safe_space, 5120, "If space left on a disk is less then this value, the disk will be concidered full. In MB");
DEFINE_int64(chunkserver_disk_safe_space, 5120, "If space left on a disk is less than this value, the disk will be considered full. In MB");
DEFINE_int64(chunkserver_total_disk_safe_space, 5120, "If total space left of all disks on a chunkserver is less than this value, the chunkserver will be considered full. In MB");
// SDK
DEFINE_string(sdk_write_mode, "fanout", "Sdk write strategy, choose from [chains, fanout]");
DEFINE_int32(sdk_thread_num, 10, "Sdk thread num");
Expand Down
6 changes: 4 additions & 2 deletions src/nameserver/chunkserver_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ DECLARE_double(select_chunkserver_local_factor);
DECLARE_int32(blockreport_interval);
DECLARE_int32(blockreport_size);
DECLARE_int32(expect_chunkserver_num);
DECLARE_int64(chunkserver_total_disk_safe_space);

namespace baidu {
namespace bfs {
Expand Down Expand Up @@ -322,7 +323,7 @@ void ChunkServerManager::HandleHeartBeat(const HeartBeatRequest* request, HeartB
void ChunkServerManager::ListChunkServers(::google::protobuf::RepeatedPtrField<ChunkServerInfo>* chunkservers) {
MutexLock lock(&mu_, "ListChunkServers", 10);
for (ServerMap::iterator it = chunkservers_.begin();
it != chunkservers_.end(); ++it) {
it != chunkservers_.end(); ++it) {
ChunkServerInfo* src = it->second;
ChunkServerInfo* dst = chunkservers->Add();
dst->CopyFrom(*src);
Expand All @@ -335,7 +336,8 @@ double ChunkServerManager::GetChunkServerLoad(ChunkServerInfo* cs) {
double data_score = cs->data_size() * 1.0 / cs->disk_quota();
int64_t space_left = cs->disk_quota() - cs->data_size();

if (data_score > 0.95 || space_left < (5L << 30) || pending_score > 1.0) {
if (data_score > 0.95 || pending_score > 1.0
|| space_left < (FLAGS_chunkserver_total_disk_safe_space << 20)) {
return 1.0;
}
return (data_score * data_score + pending_score) / 2;
Expand Down

0 comments on commit d540d18

Please sign in to comment.