35 : m_context(context), m_new_server_added(false), m_paused(false) {
40 m_context->props->get_i32(
"Hypertable.LoadBalancer.BalanceDelay.NewServer");
42 m_enabled = context->props->get_bool(
"Hypertable.LoadBalancer.Enable");
45 m_context->props->get_f64(
"Hypertable.LoadBalancer.LoadavgThreshold");
48 m_context->props->get_i32(
"Hypertable.LoadBalancer.BalanceDelay.Initial");
52 if (
m_context->rsc_manager->exist_unbalanced_servers()) {
83 if (
m_context->rsc_manager->exist_unbalanced_servers()) {
99 std::vector <RangeServerConnectionPtr> &balanced) {
101 time_t now = time(0);
106 String algorithm_spec = plan->algorithm;
112 if (
m_context->rsc_manager->server_count() == 1) {
116 balanced.push_back(rsc);
128 boost::trim(algorithm_spec);
129 if (algorithm_spec ==
"") {
131 name =
"table_ranges";
138 char *ptr = strchr((
char *)algorithm_spec.c_str(),
' ');
140 name =
String(algorithm_spec, 0, ptr-algorithm_spec.c_str());
143 boost::trim(arguments);
147 name = algorithm_spec;
148 boost::to_lower(name);
151 HT_INFOF(
"LoadBalance(name='%s', args='%s')", name.c_str(), arguments.c_str());
153 if (name ==
"offload")
155 else if (name ==
"table_ranges")
157 else if (name ==
"load")
161 "Unrecognized algorithm - %s", name.c_str());
163 plan->algorithm = name;
166 algo->compute_plan(plan, balanced);
time_t next_event(time_t now)
Retrieves the timestamp of the next event.
std::shared_ptr< RangeServerConnection > RangeServerConnectionPtr
LoadBalancer(ContextPtr context)
std::string String
A String is simply a typedef to std::string.
std::shared_ptr< BalancePlan > BalancePlanPtr
double m_loadavg_threshold
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
time_t m_next_balance_time_new_server
void create_plan(BalancePlanPtr &plan, std::vector< RangeServerConnectionPtr > &balanced)
Tracks timing of periodic events.
time_t m_next_balance_time_load
std::shared_ptr< BalanceAlgorithm > BalanceAlgorithmPtr
Compatibility Macros for C/C++.
uint32_t m_new_server_balance_delay
Declarations for general-purpose utility functions.
#define HT_INFOF(msg,...)
#define HT_THROWF(_code_, _fmt_,...)
std::vector< RangeServerStatistics > m_statistics
void transfer_monitoring_data(vector< RangeServerStatistics > &stats)
void reenable_balancer(LoadBalancer *balancer)
#define HT_THROW(_code_, _msg_)