0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ServerReceiverPlan.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_ServerReceiverPlan_h
29 #define Hypertable_Lib_RangeServerRecovery_ServerReceiverPlan_h
30 
34 
35 #include <Common/StringExt.h>
37 #include <Common/Serializable.h>
38 
39 #include <boost/multi_index_container.hpp>
40 #include <boost/multi_index/ordered_index.hpp>
41 #include <boost/multi_index/member.hpp>
42 #include <boost/multi_index/mem_fun.hpp>
43 
44 #include <iostream>
45 
46 namespace Hypertable {
47 namespace Lib {
48 namespace RangeServerRecovery {
49 
50  using namespace boost::multi_index;
51  using namespace std;
52 
55 
58  public:
59 
60  ServerReceiverPlan(CharArena &arena, const string &location_,
61  const TableIdentifier &table_, const RangeSpec &range_,
62  const RangeState &state_) {
63  location = location_;
64  spec.table.id = arena.dup(table_.id);
65  spec.table.generation = table_.generation;
66  spec.range.start_row = arena.dup(range_.start_row);
67  spec.range.end_row = arena.dup(range_.end_row);
68  state.state = state_.state;
69  state.timestamp = state_.timestamp;
70  state.soft_limit = state_.soft_limit;
71  state.transfer_log = arena.dup(state_.transfer_log);
72  state.split_point = arena.dup(state_.split_point);
73  state.old_boundary_row = arena.dup(state_.old_boundary_row);
74  }
75 
77 
78  string location;
81  friend ostream &operator<< (ostream &os, const ServerReceiverPlan &entry) {
82  os << "{ServerReceiverPlan:" << entry.spec << entry.state << ", location="
83  << entry.location << "}";
84  return os;
85  }
86 
87  private:
88 
91  uint8_t encoding_version() const override;
92 
96  size_t encoded_length_internal() const override;
97 
100  void encode_internal(uint8_t **bufp) const override;
101 
108  void decode_internal(uint8_t version, const uint8_t **bufp,
109  size_t *remainp) override;
110 
111  };
112 
115  typedef multi_index_container<
117  indexed_by<
118  ordered_unique<tag<ServerReceiverPlanByRange>, member<ServerReceiverPlan, QualifiedRangeSpec, &ServerReceiverPlan::spec> >,
119  ordered_non_unique<tag<ServerReceiverPlanByLocation>, member<ServerReceiverPlan, string, &ServerReceiverPlan::location> >
120  >
122  typedef ServerReceiverPlanContainer::index<ServerReceiverPlanByRange>::type ServerReceiverPlanRangeIndex;
123  typedef ServerReceiverPlanContainer::index<ServerReceiverPlanByLocation>::type ServerReceiverPlanLocationIndex;
124 
126 
127 }}}
128 
129 #endif // Hypertable_Lib_RangeServerRecovery_ServerReceiverPlan_h
Range specification.
Definition: RangeSpec.h:40
Declarations for TableIdentifier and TableIdentifierManaged.
uint64_t soft_limit
Soft split size limit.
Definition: RangeState.h:108
PageArena memory allocator for STL classes.
STL namespace.
const char * old_boundary_row
Original range boundary row.
Definition: RangeState.h:117
CharT * dup(const CharT *s)
Duplicate a null terminated string; memory is allocated from the pool.
Definition: PageArena.h:274
const char * end_row
Definition: RangeSpec.h:60
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
ostream & operator<<(ostream &os, const CellInterval &ci)
ServerReceiverPlan(CharArena &arena, const string &location_, const TableIdentifier &table_, const RangeSpec &range_, const RangeState &state_)
const char * transfer_log
Full pathname of transfer log.
Definition: RangeState.h:111
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
Definition: PageArena.h:69
uint8_t state
Range state value (see StateType)
Definition: RangeState.h:102
int64_t timestamp
Timestamp
Definition: RangeState.h:105
Declarations for RangeSpec and RangeSpecManaged.
Declarations for Serializable.
Hypertable definitions
const char * start_row
Definition: RangeSpec.h:59
ServerReceiverPlanContainer::index< ServerReceiverPlanByRange >::type ServerReceiverPlanRangeIndex
Mixin class that provides a standard serialization interface.
Definition: Serializable.h:65
const char * split_point
Split point (row key)
Definition: RangeState.h:114
Qualified (with table identifier) range specification.
Range state.
Definition: RangeState.h:48
ServerReceiverPlanContainer::index< ServerReceiverPlanByLocation >::type ServerReceiverPlanLocationIndex
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