0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BalanceAlgorithmLoad.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_BalanceAlgorithmLoad_h
23 #define Hypertable_Master_BalanceAlgorithmLoad_h
24 
25 
28 
29 #include <set>
30 #include <map>
31 #include <iostream>
32 #include <vector>
33 
34 #include "BalanceAlgorithm.h"
35 #include "RangeServerStatistics.h"
36 #include "Context.h"
37 
38 
39 namespace Hypertable {
40 
42  public:
43 
45  std::vector<RangeServerStatistics> &statistics);
46 
47  virtual void compute_plan(BalancePlanPtr &plan,
48  std::vector<RangeServerConnectionPtr> &balanced);
49 
50  public:
52  public:
54 
55  void clear() {
57  server_id = 0;
58  disk_full = false;
59  }
60 
61  double loadavg;
63  const char *server_id;
64  bool disk_full;
65  };
66 
69  const ServerMetricSummary &y) const {
70  return x.loadavg > y.loadavg;
71  }
72  };
73 
74  typedef std::multiset<ServerMetricSummary, GtServerMetricSummary> ServerSetDescLoad;
75 
77  public:
79  void clear() { loadestimate = 0; table_id = start_row = end_row = 0; }
80 
81  double loadestimate;
82  const char *table_id;
83  const char *start_row;
84  const char *end_row;
85  };
88  const RangeMetricSummary &y) const {
89  return x.loadestimate > y.loadestimate;
90  }
91  };
92  typedef std::multiset<RangeMetricSummary, GtRangeMetricSummary> RangeSetDescLoad;
93 
94  private:
95 
96  void
98  ServerMetricSummary &summary);
99 
101  RangeMetricSummary &summary);
102 
104  RangeSetDescLoad &ranges_desc_load);
105 
106  bool check_move(const ServerMetricSummary &source,
107  const ServerMetricSummary &destination,
108  double range_loadestimate, double mean_loadavg);
109 
110  typedef std::map<String, RangeServerStatistics> StatisticsSet;
111  StatisticsSet m_rsstats;
114  };
115 
116  std::ostream &operator<<(std::ostream &out,
118  std::ostream &operator<<(std::ostream &out,
120 } // namespace Hypertable
121 
122 #endif // Hypertable_Master_BalanceAlgorithmLoad_h
bool check_move(const ServerMetricSummary &source, const ServerMetricSummary &destination, double range_loadestimate, double mean_loadavg)
void calculate_range_summary(const Lib::RS_METRICS::RangeMetrics &metrics, RangeMetricSummary &summary)
std::shared_ptr< BalancePlan > BalancePlanPtr
Definition: BalancePlan.h:81
std::map< String, RangeMetrics > RangeMetricsMap
Definition: RangeMetrics.h:104
Declarations for ServerMetrics.
Declarations for RangeMetrics.
virtual void compute_plan(BalancePlanPtr &plan, std::vector< RangeServerConnectionPtr > &balanced)
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Definition: Context.h:265
std::multiset< RangeMetricSummary, GtRangeMetricSummary > RangeSetDescLoad
void calculate_server_summary(const Lib::RS_METRICS::ServerMetrics &metrics, ServerMetricSummary &summary)
std::multiset< ServerMetricSummary, GtServerMetricSummary > ServerSetDescLoad
std::ostream & operator<<(std::ostream &os, const crontab_entry &entry)
Helper function to write crontab_entry to an ostream.
Definition: Crontab.cc:301
Aggregates metrics for an individual range.
Definition: RangeMetrics.h:66
std::map< String, RangeServerStatistics > StatisticsSet
BalanceAlgorithmLoad(ContextPtr &context, std::vector< RangeServerStatistics > &statistics)
Hypertable definitions
bool operator()(const RangeMetricSummary &x, const RangeMetricSummary &y) const
Aggregates metrics for an individual RangeServer.
Definition: ServerMetrics.h:68
bool operator()(const ServerMetricSummary &x, const ServerMetricSummary &y) const
Declarations for Context.
void populate_range_load_set(const Lib::RS_METRICS::RangeMetricsMap &range_metrics, RangeSetDescLoad &ranges_desc_load)