0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BalancePlan.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_Lib_BalancePlan_h
23 #define Hypertable_Lib_BalancePlan_h
24 
26 
27 #include <Common/Serializable.h>
28 
29 #include <memory>
30 #include <vector>
31 
32 namespace Hypertable {
33 
36 
38  class BalancePlan : public Serializable {
39  public:
40  BalancePlan(const std::string &algorithm_ = std::string()) : algorithm(algorithm_) { }
41 
42  BalancePlan(const BalancePlan &other);
43 
44  bool empty() { return moves.empty(); }
45 
46  void clear() {
47  moves.clear();
48  duration_millis = 0;
49  }
50 
51  std::vector<RangeMoveSpecPtr> moves;
52  std::string algorithm;
53  int32_t duration_millis {};
54 
55  private:
56 
59  uint8_t encoding_version() const override;
60 
64  size_t encoded_length_internal() const override;
65 
68  void encode_internal(uint8_t **bufp) const override;
69 
76  void decode_internal(uint8_t version, const uint8_t **bufp,
77  size_t *remainp) override;
78 
79  };
80 
81  typedef std::shared_ptr<BalancePlan> BalancePlanPtr;
82 
83  std::ostream &operator<<(std::ostream &os, const BalancePlan &plan);
84 
86 
87 } // namespace Hypertable
88 
89 #endif // HYPERTABLE_BALANCEPLAN_H
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
Definition: BalancePlan.cc:79
BalancePlan(const std::string &algorithm_=std::string())
Definition: BalancePlan.h:40
Balance plan.
Definition: BalancePlan.h:38
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
Definition: BalancePlan.cc:87
std::shared_ptr< BalancePlan > BalancePlanPtr
Definition: BalancePlan.h:81
size_t encoded_length_internal() const override
Returns internal serialized length.
Definition: BalancePlan.cc:44
std::ostream & operator<<(std::ostream &os, const crontab_entry &entry)
Helper function to write crontab_entry to an ostream.
Definition: Crontab.cc:301
Declarations for RangeMoveSpec.
Declarations for Serializable.
Hypertable definitions
Mixin class that provides a standard serialization interface.
Definition: Serializable.h:65
std::vector< RangeMoveSpecPtr > moves
Definition: BalancePlan.h:51
uint8_t encoding_version() const override
Returns encoding version.
Definition: BalancePlan.cc:40