Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

add cluster balance indicator #214

Merged
merged 28 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions include/dsn/utility/stddev.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <vector>

namespace dsn {
namespace stddev {
namespace math {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那这里还不如改为dsn::utils 名字空间,和其他工具函数保持一致。
另外文件名改为math.h/math.cpp,这样以后有其他数学相关的函数也都放在这里。


double mean_stddev(const std::vector<unsigned> &result_set, bool partial_sample);

} // namespace stddev
} // namespace math
} // namespace dsn
4 changes: 2 additions & 2 deletions src/core/core/stddev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <dsn/utility/stddev.h>

namespace dsn {
namespace stddev {
namespace math {

double mean_stddev(const std::vector<unsigned> &result_set, bool partial_sample)
{
Expand All @@ -30,5 +30,5 @@ double mean_stddev(const std::vector<unsigned> &result_set, bool partial_sample)
return stddev;
}

} // namespace stddev
} // namespace math
} // namespace dsn
4 changes: 2 additions & 2 deletions src/dist/replication/meta_server/greedy_load_balancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ void greedy_load_balancer::score(meta_view view, double &primary_stddev, double
if (primary_count.size() <= 1 || partition_count.size() <= 1)
return;

primary_stddev = stddev::mean_stddev(primary_count, partial_sample);
total_stddev = stddev::mean_stddev(partition_count, partial_sample);
primary_stddev = math::mean_stddev(primary_count, partial_sample);
total_stddev = math::mean_stddev(partition_count, partial_sample);
}

std::shared_ptr<configuration_balancer_request>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void meta_service_test_app::balancer_validator()

// iterate 1000000 times
for (int i = 0; i < 1000000 && lb->balance({&apps, &nodes}, ml); ++i) {
dinfo("the %dth round of balancer", i);
migration_check_and_apply(apps, nodes, ml, &manager);
lb->check({&apps, &nodes}, ml);
dinfo("balance checker operation count = %d", ml.size());
Expand Down Expand Up @@ -327,6 +328,7 @@ void meta_service_test_app::balance_config_file()

// iterate 1000 times
for (int i = 0; i < 1000 && lb->balance({&apps, &nodes}, ml); ++i) {
dinfo("the %dth round of balancer", i);
migration_check_and_apply(apps, nodes, ml, nullptr);
lb->check({&apps, &nodes}, ml);
dinfo("balance checker operation count = %d", ml.size());
Expand Down