0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
LoadBalancer.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef Hypertable_Master_LoadBalancer_h
23 #define Hypertable_Master_LoadBalancer_h
24 
25 #include "RangeServerConnection.h"
26 #include "RangeServerStatistics.h"
27 #include "Context.h"
28 
30 
31 #include <Common/Crontab.h>
32 
33 #include <ctime>
34 #include <mutex>
35 #include <vector>
36 
37 namespace Hypertable {
38 
39  class LoadBalancer {
40  public:
41  LoadBalancer(ContextPtr context);
42 
43  void signal_new_server();
44 
45  bool balance_needed();
46 
47  void unpause();
48 
49  void create_plan(BalancePlanPtr &plan,
50  std::vector <RangeServerConnectionPtr> &balanced);
51 
52  void transfer_monitoring_data(vector<RangeServerStatistics> &stats);
53 
54  private:
64  bool m_enabled;
65  bool m_paused;
66  std::vector <RangeServerStatistics> m_statistics;
67  };
68 
69  void reenable_balancer(LoadBalancer *balancer);
70 }
71 
72 #endif // Hypertable_Master_LoadBalancer_h
static std::mutex mutex
Definition: Logger.cc:43
LoadBalancer(ContextPtr context)
Definition: LoadBalancer.cc:34
std::shared_ptr< BalancePlan > BalancePlanPtr
Definition: BalancePlan.h:81
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Definition: Context.h:265
time_t m_next_balance_time_new_server
Definition: LoadBalancer.h:60
void create_plan(BalancePlanPtr &plan, std::vector< RangeServerConnectionPtr > &balanced)
Definition: LoadBalancer.cc:98
Tracks timing of periodic events.
Definition: Crontab.h:55
uint32_t m_new_server_balance_delay
Definition: LoadBalancer.h:62
Hypertable definitions
std::vector< RangeServerStatistics > m_statistics
Definition: LoadBalancer.h:66
Crontab class for periodic events.
void transfer_monitoring_data(vector< RangeServerStatistics > &stats)
Definition: LoadBalancer.cc:92
void reenable_balancer(LoadBalancer *balancer)
Declarations for Context.