0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PhantomRange.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 
26 
27 #ifndef Hypertable_RangeServer_PhantomRange_h
28 #define Hypertable_RangeServer_PhantomRange_h
29 
33 
36 
37 #include <Common/String.h>
38 #include <Common/Filesystem.h>
39 
40 #include <map>
41 #include <memory>
42 #include <mutex>
43 #include <vector>
44 
45 namespace Hypertable {
46 
47  using namespace std;
48 
51 
53  class PhantomRange {
54 
55  public:
56  enum State {
57  LOADED = 0x00000001,
58  REPLAYED = 0x00000002,
59  PREPARED = 0x00000004,
60  COMMITTED = 0x00000008,
61  CANCELLED = 0x00000010
62  };
63 
64  PhantomRange(const QualifiedRangeSpec &spec, const RangeState &state,
65  SchemaPtr &schema, const vector<int32_t> &fragments);
73  bool add(int32_t fragment, EventPtr &event);
74  int get_state();
75  const RangeState &get_range_state() { return m_range_state; }
76 
77  void purge_incomplete_fragments();
78  void create_range(Lib::Master::ClientPtr &master_client, TableInfoPtr &table_info,
79  FilesystemPtr &log_dfs);
81  lock_guard<mutex> lock(m_mutex);
82  return m_range;
83  }
84 
85  void populate_range_and_log(FilesystemPtr &log_dfs, int64_t recovery_id,
86  bool *is_empty);
87  CommitLogReaderPtr get_phantom_log();
88  const String &get_phantom_logname();
89 
90  void set_replayed();
91  bool replayed();
92 
93  void set_prepared();
94  bool prepared();
95 
96  void set_committed();
97  bool committed();
98 
99  private:
100 
101  String create_log(FilesystemPtr &log_dfs,
102  int64_t recovery_id,
103  MetaLogEntityRangePtr &range_entity);
104 
105  typedef std::map<int32_t, FragmentDataPtr> FragmentMap;
106 
108  FragmentMap m_fragments;
116  int m_state;
117  };
118 
120  typedef std::shared_ptr<PhantomRange> PhantomRangePtr;
121 
123 
124 }
125 
126 #endif // Hypertable_RangeServer_PhantomRange_h
static std::mutex mutex
Definition: Logger.cc:43
QualifiedRangeSpec m_range_spec
Definition: PhantomRange.h:109
Declarations for FragmentData.
Abstract base class for a filesystem.
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
std::map< int32_t, FragmentDataPtr > FragmentMap
Definition: PhantomRange.h:105
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
STL namespace.
void add(const Key &key, uint8_t flag, const void *value, uint32_t value_len, TableMutatorAsync *value_index_mutator, TableMutatorAsync *qualifier_index_mutator)
Definition: IndexTables.cc:34
std::shared_ptr< CommitLogReader > CommitLogReaderPtr
Smart pointer to CommitLogReader.
std::shared_ptr< Client > ClientPtr
Definition: Client.h:156
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
Declarations for RangeState.
CommitLogReaderPtr m_phantom_log
Definition: PhantomRange.h:114
Declarations for Range.
const RangeState & get_range_state()
Definition: PhantomRange.h:75
Hypertable definitions
Declarations for TableInfo.
std::shared_ptr< MetaLogEntityRange > MetaLogEntityRangePtr
Smart pointer to MetaLogEntityRange.
std::shared_ptr< Filesystem > FilesystemPtr
Smart pointer to Filesystem.
Definition: Filesystem.h:572
std::shared_ptr< TableInfo > TableInfoPtr
Smart pointer to TableInfo.
Definition: TableInfo.h:312
std::shared_ptr< Range > RangePtr
Smart pointer to Range.
Definition: Range.h:404
std::shared_ptr< PhantomRange > PhantomRangePtr
Shared smart pointer to PhantomRange.
Definition: PhantomRange.h:120
A String class based on std::string.
Qualified (with table identifier) range specification.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
Range state.
Definition: RangeState.h:48
Represents a "phantom" range.
Definition: PhantomRange.h:53