0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RangeMetrics.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2013 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; either version 3
9  * of the 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 
26 
27 #ifndef Hypertable_Lib_RS_METRICS_RangeMetrics_h
28 #define Hypertable_Lib_RS_METRICS_RangeMetrics_h
29 
30 #include <Common/String.h>
31 
32 #include <map>
33 #include <vector>
34 
35 namespace Hypertable {
36 namespace Lib {
37 namespace RS_METRICS {
38 
41 
44 
45  public:
46  RangeMeasurement(const char *measurement, size_t len);
47  RangeMeasurement() { memset(this, 0, sizeof(RangeMeasurement)); }
48  void parse_measurement(const char *measurement, size_t len);
49 
50  int version;
51  int64_t timestamp;
52  int64_t disk_used;
53  int64_t memory_used;
58  double update_rate;
59  double scan_rate;
62  }; // RangeMeasurement
63 
64 
66  class RangeMetrics {
67 
68  public:
69  RangeMetrics(const char *server, const char *table_id, const char *end_row);
70 
71  void add_measurement(const char *measurement, size_t len);
72  void set_start_row(const char *start_row, size_t len) {
73  m_start_row = String(start_row, len);
74  m_start_row_set = true;
75  }
76  void set_last_move(const char *move, size_t len);
77 
78  const String &get_server_id() const { return m_server_id; }
79  const String &get_table_id() const { return m_table_id; }
80  const String &get_start_row(bool *isset) const {
81  *isset = m_start_row_set; return m_start_row;
82  }
83  const String &get_end_row() const { return m_end_row; }
84  int64_t get_last_move(bool *isset) const {
85  *isset = m_last_move_set;
86  return m_last_move;
87  }
88  bool is_moveable() const;
89 
90  const std::vector<RangeMeasurement> &get_measurements() const { return m_measurements; }
91  void get_avg_measurement(RangeMeasurement &measurement);
92 
93  private:
94  std::vector<RangeMeasurement> m_measurements;
99  int64_t m_last_move;
102  }; // RangeMetrics
103 
104  typedef std::map<String, RangeMetrics> RangeMetricsMap;
105 
107 
108 } // namespace RS_METRICS
109 } // namespace Lib
110 } // namespace Hypertable
111 
112 #endif // Hypertable_Lib_RS_METRICS_RangeMetrics_h
const String & get_server_id() const
Definition: RangeMetrics.h:78
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
const std::vector< RangeMeasurement > & get_measurements() const
Definition: RangeMetrics.h:90
std::map< String, RangeMetrics > RangeMetricsMap
Definition: RangeMetrics.h:104
int64_t get_last_move(bool *isset) const
Definition: RangeMetrics.h:84
const String & get_start_row(bool *isset) const
Definition: RangeMetrics.h:80
void set_start_row(const char *start_row, size_t len)
Definition: RangeMetrics.h:72
void parse_measurement(const char *measurement, size_t len)
Definition: RangeMetrics.cc:49
Aggregates metrics for an individual range.
Definition: RangeMetrics.h:66
RangeMetrics(const char *server, const char *table_id, const char *end_row)
Definition: RangeMetrics.cc:87
void get_avg_measurement(RangeMeasurement &measurement)
void add_measurement(const char *measurement, size_t len)
Definition: RangeMetrics.cc:93
Hypertable definitions
Single range metrics measurement.
Definition: RangeMetrics.h:43
A String class based on std::string.
void set_last_move(const char *move, size_t len)
const String & get_table_id() const
Definition: RangeMetrics.h:79
std::vector< RangeMeasurement > m_measurements
Definition: RangeMetrics.h:94