Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove magic number #900

Merged
merged 1 commit into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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