0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ReplayPlan.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 
27 
28 #ifndef Hypertable_Lib_RangeServerRecovery_ReplayPlan_h
29 #define Hypertable_Lib_RangeServerRecovery_ReplayPlan_h
30 
31 #include "FragmentReplayPlan.h"
32 
33 #include <Common/Serializable.h>
34 #include <Common/StringExt.h>
35 
36 #include <vector>
37 #include <iostream>
38 
39 namespace Hypertable {
40 namespace Lib {
41 namespace RangeServerRecovery {
42 
43  using namespace boost::multi_index;
44  using namespace std;
45 
48 
53  class ReplayPlan : public Serializable {
54  public:
55 
66  void insert(int32_t fragment, const string &location);
67 
72  void remove_location(const string &location);
73 
80  void get_fragments(vector<int32_t> &fragments) const;
81 
89  void get_fragments(const string &location, vector<int32_t> &fragments) const;
90 
97  void get_locations(StringSet &locations) const;
98 
106  bool get_location(int32_t fragment, string &location) const;
107 
109  void clear() { container.clear(); }
110 
113 
114  private:
115 
118  uint8_t encoding_version() const override;
119 
123  size_t encoded_length_internal() const override;
124 
127  void encode_internal(uint8_t **bufp) const override;
128 
135  void decode_internal(uint8_t version, const uint8_t **bufp,
136  size_t *remainp) override;
137 
138  public:
139  friend ostream &operator<<(ostream &os, const ReplayPlan &plan) {
140  auto & location_index =
141  (const_cast<ReplayPlan&>(plan)).container.get<1>();
142  os << "{ReplayPlan: num_entries=" << location_index.size();
143  for (auto & entry : location_index)
144  os << entry;
145  os << "}";
146  return os;
147  }
148  };
149 
151 
152 }}}
153 
154 #endif // Hypertable_Lib_RangeServerRecovery_ReplayPlan_h
std::set< String > StringSet
STL Set managing Strings.
Definition: StringExt.h:42
friend ostream & operator<<(ostream &os, const ReplayPlan &plan)
Definition: ReplayPlan.h:139
FragmentReplayPlanContainer container
Container holding fragment replay plans.
Definition: ReplayPlan.h:112
STL namespace.
Declarations for Serializable.
Hypertable definitions
Mixin class that provides a standard serialization interface.
Definition: Serializable.h:65
Declarations for FragmentReplayPlan.
String extensions and helpers: sets, maps, append operators etc.
Holds a fragment replay plan for the recovery of a RangeServer.
Definition: ReplayPlan.h:53
boost::multi_index_container< FragmentReplayPlan, indexed_by< ordered_unique< tag< FragmentReplayPlanById >, member< FragmentReplayPlan, uint32_t,&FragmentReplayPlan::fragment > >, ordered_non_unique< tag< FragmentReplayPlanByLocation >, member< FragmentReplayPlan, string,&FragmentReplayPlan::location > > > > FragmentReplayPlanContainer