0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ReceiverPlan.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 2 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_RangeServerRecovery_ReceiverPlan_h
23 #define Hypertable_Lib_RangeServerRecovery_ReceiverPlan_h
24 
25 #include "ServerReceiverPlan.h"
26 
30 
32 #include <Common/Serializable.h>
33 #include <Common/StringExt.h>
34 
35 #include <vector>
36 #include <iostream>
37 
38 namespace Hypertable {
39 namespace Lib {
40 namespace RangeServerRecovery {
41 
42  using namespace std;
43 
46 
48  class ReceiverPlan : public Serializable {
49  public:
51 
52  ReceiverPlan(const ReceiverPlan &other);
53 
54  void insert(const String &location, const TableIdentifier &table,
55  const RangeSpec &range, const RangeState &state);
56 
57  void insert(const String &location, const QualifiedRangeSpec &qrs,
58  const RangeState &state) {
59  insert(location, qrs.table, qrs.range, state);
60  }
61 
62  void remove(const QualifiedRangeSpec &qrs);
63 
64  void get_locations(StringSet &locations) const;
65 
66  bool get_location(const QualifiedRangeSpec &spec, String &location) const;
67 
68  void get_range_specs(vector<QualifiedRangeSpec> &specs) const;
69 
70  void get_range_specs(const String &location, vector<QualifiedRangeSpec> &specs) const;
71 
72  void get_range_specs_and_states(vector<QualifiedRangeSpec> &specs,
73  vector<RangeState> &states) const;
74 
75  void get_range_specs_and_states(const String &location,
76  vector<QualifiedRangeSpec> &specs,
77  vector<RangeState> &states) const;
78 
79  bool get_range_spec(const TableIdentifier &table, const char *row,
80  QualifiedRangeSpec &spec) const;
81 
82  void clear() { container.clear(); }
83  size_t size() const { return container.size(); }
84  bool empty() const { return container.empty(); }
85  void copy(ReceiverPlan &other) const;
86 
89 
90  private:
91 
94  uint8_t encoding_version() const override;
95 
99  size_t encoded_length_internal() const override;
100 
103  void encode_internal(uint8_t **bufp) const override;
104 
111  void decode_internal(uint8_t version, const uint8_t **bufp,
112  size_t *remainp) override;
113 
114  public:
115 
116  friend ostream &operator<<(ostream &os, const ReceiverPlan &plan) {
117  auto &location_index = (const_cast<ReceiverPlan&>(plan)).container.get<1>();
118  os << "{ReceiverPlan: num_entries=" << location_index.size();
119  for (auto & entry : location_index)
120  os << entry;
121  os << "}";
122  return os;
123  }
124  };
125 
127 
128 }}}
129 
130 
131 #endif // Hypertable_Lib_RangeServerRecovery_ReceiverPlan_h
std::set< String > StringSet
STL Set managing Strings.
Definition: StringExt.h:42
Range specification.
Definition: RangeSpec.h:40
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
Declarations for TableIdentifier and TableIdentifierManaged.
Declarations for ServerReceiverPlan.
PageArena memory allocator for STL classes.
STL namespace.
friend ostream & operator<<(ostream &os, const ReceiverPlan &plan)
Definition: ReceiverPlan.h:116
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
Definition: PageArena.h:69
Declarations for RangeSpec and RangeSpecManaged.
Declarations for Serializable.
Hypertable definitions
void copy(TableDumper &, CellsBuilder &)
Definition: TableDumper.cc:129
Mixin class that provides a standard serialization interface.
Definition: Serializable.h:65
void insert(const String &location, const QualifiedRangeSpec &qrs, const RangeState &state)
Definition: ReceiverPlan.h:57
Qualified (with table identifier) range specification.
Range state.
Definition: RangeState.h:48
String extensions and helpers: sets, maps, append operators etc.
multi_index_container< ServerReceiverPlan, indexed_by< ordered_unique< tag< ServerReceiverPlanByRange >, member< ServerReceiverPlan, QualifiedRangeSpec,&ServerReceiverPlan::spec > >, ordered_non_unique< tag< ServerReceiverPlanByLocation >, member< ServerReceiverPlan, string,&ServerReceiverPlan::location > > > > ServerReceiverPlanContainer
RangeServer recovery receiver plan.
Definition: ReceiverPlan.h:48