0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OperationRecover.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_OperationRecover_h
23 #define Hypertable_Master_OperationRecover_h
24 
25 #include "Operation.h"
26 #include "RangeServerConnection.h"
27 
29 
31 
33 
34 #include <vector>
35 
36 namespace Hypertable {
37 
44  class OperationRecover : public Operation {
45  public:
46 
47  enum {
48  RESTART = 1
49  };
50 
64  int flags=0);
65 
66  OperationRecover(ContextPtr &context, const MetaLog::EntityHeader &header_);
67 
68  virtual ~OperationRecover();
69 
70  void execute() override;
71  const String name() override;
72  const String label() override;
73  const String& location() const { return m_location; }
74 
75  void display_state(std::ostream &os) override;
76  uint8_t encoding_version_state() const override;
77  size_t encoded_length_state() const override;
78  void encode_state(uint8_t **bufp) const override;
79  void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override;
80  void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override;
81  bool exclusive() override { return true; }
82 
83  private:
84 
85  // acquire lock on Hyperspace file; returns true if lock is acquired or
86  // false if the RangeServer is back online
87  bool acquire_server_lock();
88 
89  // creates a new recovery plan and stores it in the BalancePlanAuthority
90  void create_recovery_plan();
91 
92  // read rsml files and populate m_root_range, m_metadata_ranges etc
93  void read_rsml(std::vector<MetaLog::EntityPtr> &removable_move_ops);
94 
95  // check to see if master was notified of newly split-off range
96  void handle_split_shrunk(MetaLogEntityRange *range_entity,
97  std::vector<MetaLog::EntityPtr> &removable_move_ops);
98 
99  // cleans up after this operation is complete
100  void clear_server_state();
101 
102  // persisted state
104  vector<QualifiedRangeSpec> m_root_specs;
105  vector<RangeState> m_root_states;
106  vector<QualifiedRangeSpec> m_metadata_specs;
107  vector<RangeState> m_metadata_states;
108  vector<QualifiedRangeSpec> m_system_specs;
109  vector<RangeState> m_system_states;
110  vector<QualifiedRangeSpec> m_user_specs;
111  vector<RangeState> m_user_states;
112  // in mem state
116  uint64_t m_hyperspace_handle {};
117  bool m_restart {};
119  };
120 
123 } // namespace Hypertable
124 
125 #endif // Hypertable_Master_OperationRecover_h
void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override
vector< RangeState > m_system_states
std::shared_ptr< RangeServerConnection > RangeServerConnectionPtr
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
Declarations for MetaLogEntityRange.
vector< RangeState > m_user_states
Declarations for Operation.
PageArena memory allocator for STL classes.
Carries out recovery operaton for a range server.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Definition: Context.h:265
vector< QualifiedRangeSpec > m_root_specs
void read_rsml(std::vector< MetaLog::EntityPtr > &removable_move_ops)
const String name() override
Name of operation used for exclusivity.
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
MetaLog entity for range state persisted in RSML.
const String label() override
Human readable label for operation.
void display_state(std::ostream &os) override
Write human readable operation state to output stream.
RangeServerConnectionPtr m_rsc
void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Decode operation state.
void handle_split_shrunk(MetaLogEntityRange *range_entity, std::vector< MetaLog::EntityPtr > &removable_move_ops)
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
Definition: PageArena.h:69
void execute() override
Executes (carries out) the operation.
vector< RangeState > m_root_states
OperationRecover(ContextPtr &context, RangeServerConnectionPtr &rsc, int flags=0)
Constructor.
vector< QualifiedRangeSpec > m_system_specs
Hypertable definitions
uint8_t encoding_version_state() const override
Returns version of encoding format of state.
vector< RangeState > m_metadata_states
vector< QualifiedRangeSpec > m_metadata_specs
const String & location() const
Abstract base class for master operations.
Definition: Operation.h:124
bool exclusive() override
Indicates if operation is exclusive.
vector< QualifiedRangeSpec > m_user_specs
size_t encoded_length_state() const override
Encoded length of operation state.
void encode_state(uint8_t **bufp) const override
Encode operation state.