0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BalancePlanAuthority.cc
Go to the documentation of this file.
1 /*
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 
28 #include <Common/Compat.h>
29 
30 #include "BalancePlanAuthority.h"
31 #include "Context.h"
32 #include "MetaLogEntityTypes.h"
33 #include "Utility.h"
34 
37 
38 #include <Common/Serialization.h>
39 
40 #include <sstream>
41 
42 using namespace Hypertable;
43 using namespace std;
44 
46  MetaLog::WriterPtr &mml_writer)
47  : MetaLog::Entity(MetaLog::EntityType::BALANCE_PLAN_AUTHORITY),
48  m_context(context), m_mml_writer(mml_writer), m_generation(0)
49 {
51 }
52 
54  MetaLog::WriterPtr &mml_writer, const MetaLog::EntityHeader &header)
55  : MetaLog::Entity(header), m_context(context), m_mml_writer(mml_writer),
56  m_generation(0)
57 {
58 }
59 
60 void
62 {
63  lock_guard<mutex> lock(m_mutex);
64  os << " generation " << m_generation << " ";
65  RecoveryPlanMap::iterator it = m_map.begin();
66  while (it != m_map.end()) {
67  os << it->first << ": ";
68  for (int i = 0; i < 4; i++)
69  if (it->second.plans[i])
70  os << *(it->second.plans[i]) << " ";
71  it++;
72  }
73  os << "current_set={";
74  for (const auto &move_spec : m_current_set)
75  os << *move_spec << " ";
76  os << "}";
77 }
78 
79 void BalancePlanAuthority::decode(const uint8_t **bufp, size_t *remainp,
80  uint16_t definition_version) {
81  lock_guard<mutex> lock(m_mutex);
82  if (definition_version < 4) {
83  decode_old(bufp, remainp);
84  return;
85  }
86  Entity::decode(bufp, remainp);
87 }
88 
89 void
91 {
92  lock_guard<mutex> lock(m_mutex);
93  m_mml_writer = mml_writer;
94 }
95 
96 void
98  RangeServerRecovery::Plan &out, int &generation)
99 {
100  lock_guard<mutex> lock(m_mutex);
101  HT_ASSERT(m_map.find(location) != m_map.end());
102  RangeServerRecovery::PlanPtr plan = m_map[location].plans[type];
103 
104  out.clear();
105  if (plan) {
106  HT_ASSERT(plan->type == type);
107  out.replay_plan = plan->replay_plan;
108  plan->receiver_plan.copy(out.receiver_plan);
109  }
110  out.type = type;
111 
112  generation = m_generation;
113 }
114 
115 void
117 {
118  {
119  lock_guard<mutex> lock(m_mutex);
120  RecoveryPlanMap::iterator it = m_map.find(location);
121  if (it == m_map.end())
122  return;
123  m_map.erase(it);
124  }
125  m_mml_writer->record_state(shared_from_this());
126 }
127 
128 
130  const vector<QualifiedRangeSpec> &specs) {
131  {
132  lock_guard<mutex> lock(m_mutex);
133 
134  HT_ASSERT(m_map.find(location) != m_map.end());
135 
136  RangeServerRecovery::PlanPtr plan = m_map[location].plans[type];
137 
138  HT_ASSERT(plan && plan->type == type);
139 
140  for (const auto &spec : specs)
141  plan->receiver_plan.remove(spec);
142  }
143  m_mml_writer->record_state(shared_from_this());
144 }
145 
147  lock_guard<mutex> lock(m_mutex);
148  vector<QualifiedRangeSpec> specs;
149  bool changed = false;
150 
151  for (std::map<String, RecoveryPlans>::iterator iter = m_map.begin();
152  iter != m_map.end(); ++iter) {
153  for (size_t i=0; i<4; i++) {
154  if (iter->second.plans[i]) {
155  specs.clear();
156  auto &receiver_plan = iter->second.plans[i]->receiver_plan;
157  receiver_plan.get_range_specs(specs);
158  for (auto &spec : specs) {
159  if (!strcmp(table_id.c_str(), spec.table.id)) {
160  receiver_plan.remove(spec);
161  changed = true;
162  }
163  }
164  }
165  }
166  }
167  if (changed)
168  m_generation++;
169 }
170 
172  const String &old_destination,
173  const String &new_destination) {
174  lock_guard<mutex> lock(m_mutex);
175  vector<QualifiedRangeSpec> specs;
176  vector<RangeState> states;
177  size_t start = 0;
178  size_t end = 4;
179  bool changed = false;
180 
181  if (type >= 0 && type < RangeSpec::UNKNOWN) {
182  start = type;
183  end = type+1;
184  }
185 
186  for (std::map<String, RecoveryPlans>::iterator iter = m_map.begin();
187  iter != m_map.end(); ++iter) {
188  if (location != "*" && iter->first != location)
189  continue;
190  for (size_t i=start; i<end; i++) {
191  if (iter->second.plans[i]) {
192  specs.clear();
193  states.clear();
194  auto &receiver_plan = iter->second.plans[i]->receiver_plan;
195  receiver_plan.get_range_specs_and_states(old_destination, specs, states);
196  if (!specs.empty()) {
197  HT_ASSERT(specs.size() == states.size());
198  for (size_t j=0; j<specs.size(); j++) {
199  receiver_plan.remove(specs[j]);
200  receiver_plan.insert(new_destination, specs[j], states[j]);
201  changed = true;
202  }
203  }
204  }
205  }
206  }
207  if (changed)
208  m_generation++;
209 }
210 
211 
212 void BalancePlanAuthority::get_receiver_plan_locations(const String &recovery_location, int type,
213  StringSet &locations) {
214  lock_guard<mutex> lock(m_mutex);
215  HT_ASSERT(m_map.find(recovery_location) != m_map.end());
216  RangeServerRecovery::PlanPtr plan = m_map[recovery_location].plans[type];
217 
218  if (plan)
219  plan->receiver_plan.get_locations(locations);
220 }
221 
222 
223 bool BalancePlanAuthority::recovery_complete(const String &location, int type) {
224  lock_guard<mutex> lock(m_mutex);
225  if (m_map.find(location) == m_map.end())
226  return true;
227  RangeServerRecovery::PlanPtr plan = m_map[location].plans[type];
228  if (!plan || plan->receiver_plan.empty())
229  return true;
230  return false;
231 }
232 
233 
235  lock_guard<mutex> lock(m_mutex);
236  return (m_map.empty());
237 }
238 
240  return 1;
241 }
242 
244  size_t len = 4 + 4;
245  RecoveryPlanMap::const_iterator it = m_map.begin();
246  while (it != m_map.end()) {
247  len += Serialization::encoded_length_vstr(it->first);
248  for (int i = 0; i < 4; i++) {
249  len += 1;
250  if (it->second.plans[i])
251  len += it->second.plans[i]->encoded_length();
252  }
253  it++;
254  }
255  len += 4;
256  for (const auto &move_spec : m_current_set)
257  len += move_spec->encoded_length();
258  return len;
259 }
260 
261 void BalancePlanAuthority::encode_internal(uint8_t **bufp) const {
263  Serialization::encode_i32(bufp, m_map.size());
264  RecoveryPlanMap::const_iterator it = m_map.begin();
265  while (it != m_map.end()) {
266  Serialization::encode_vstr(bufp, it->first);
267  for (int i = 0; i < 4; i++) {
268  if (it->second.plans[i]) {
269  Serialization::encode_bool(bufp, true);
270  it->second.plans[i]->encode(bufp);
271  }
272  else
273  Serialization::encode_bool(bufp, false);
274  }
275  it++;
276  }
278  for (const auto &move_spec : m_current_set)
279  move_spec->encode(bufp);
280 }
281 
282 void BalancePlanAuthority::decode_internal(uint8_t version, const uint8_t **bufp,
283  size_t *remainp) {
284  m_generation = Serialization::decode_i32(bufp, remainp);
285  int num_servers = Serialization::decode_i32(bufp, remainp);
286  for (int i = 0; i < num_servers; i++) {
287  String rs = Serialization::decode_vstr(bufp, remainp);
288  RecoveryPlans plans;
289  for (int j = 0; j < 4; j++) {
290  bool b = Serialization::decode_bool(bufp, remainp);
291  if (!b) {
292  plans.plans[j] = 0;
293  continue;
294  }
295  plans.plans[j] = make_shared<RangeServerRecovery::Plan>();
296  plans.plans[j]->decode(bufp, remainp);
297  }
298  m_map[rs] = plans;
299  }
300  if (version >= 2) {
301  size_t count = Serialization::decode_i32(bufp, remainp);
302  RangeMoveSpecPtr move_spec;
303  for (size_t i=0; i<count; i++) {
304  move_spec = make_shared<RangeMoveSpec>();
305  move_spec->decode(bufp, remainp);
306  m_current_set.insert(move_spec);
307  }
308  }
309 }
310 
311 void BalancePlanAuthority::decode_old(const uint8_t **bufp,
312  size_t *remainp) {
313  uint16_t version = Serialization::decode_i16(bufp, remainp);
314  m_generation = Serialization::decode_i32(bufp, remainp);
315  int num_servers = Serialization::decode_i32(bufp, remainp);
316  for (int i = 0; i < num_servers; i++) {
317  String rs = Serialization::decode_vstr(bufp, remainp);
318  RecoveryPlans plans;
319  for (int j = 0; j < 4; j++) {
320  bool b = Serialization::decode_bool(bufp, remainp);
321  if (!b) {
322  plans.plans[j] = 0;
323  continue;
324  }
325  plans.plans[j] = make_shared<RangeServerRecovery::Plan>();
326  legacy_decode(bufp, remainp, plans.plans[j].get());
327  }
328  m_map[rs] = plans;
329  }
330  if (version >= 2) {
331  size_t count = Serialization::decode_i32(bufp, remainp);
332  RangeMoveSpecPtr move_spec;
333  for (size_t i=0; i<count; i++) {
334  move_spec = make_shared<RangeMoveSpec>();
335  legacy_decode(bufp, remainp, move_spec.get());
336  m_current_set.insert(move_spec);
337  }
338  }
339 }
340 
341 void
343  const vector<QualifiedRangeSpec> &root_specs,
344  const vector<RangeState> &root_states,
345  const vector<QualifiedRangeSpec> &metadata_specs,
346  const vector<RangeState> &metadata_states,
347  const vector<QualifiedRangeSpec> &system_specs,
348  const vector<RangeState> &system_states,
349  const vector<QualifiedRangeSpec> &user_specs,
350  const vector<RangeState> &user_states)
351 {
352  unique_lock<mutex> lock(m_mutex);
353 
354  HT_INFOF("Creating recovery plan for %s", location.c_str());
355 
356  // check if this RangeServer was already recovered; if yes then do not add
357  // a new plan (this happens i.e. in rangeserver-failover-master-16)
358  if (m_map.find(location) != m_map.end())
359  return;
360 
361  // Update "active" server set
362  m_active.clear();
363  m_context->get_available_servers(m_active);
364  m_active_iter = m_active.begin();
365 
366  HT_ASSERT(!m_active.empty());
367 
368  // walk through the existing plans and move all ranges from that server
369  // to other servers
370  RecoveryPlanMap::iterator it;
371  for (it = m_map.begin(); it != m_map.end(); ++it) {
372  if (it->second.plans[RangeSpec::ROOT])
373  update_range_plan(it->second.plans[RangeSpec::ROOT], location, root_specs);
374  if (it->second.plans[RangeSpec::METADATA])
375  update_range_plan(it->second.plans[RangeSpec::METADATA], location, metadata_specs);
376  if (it->second.plans[RangeSpec::SYSTEM])
377  update_range_plan(it->second.plans[RangeSpec::SYSTEM], location, system_specs);
378  if (it->second.plans[RangeSpec::USER])
379  update_range_plan(it->second.plans[RangeSpec::USER], location, user_specs);
380  }
381 
382  // then create the new plan for the failed server
383  RecoveryPlans plans;
384  plans.plans[RangeSpec::ROOT]
385  = create_range_plan(location, RangeSpec::ROOT, root_specs, root_states);
387  = create_range_plan(location, RangeSpec::METADATA, metadata_specs, metadata_states);
388  plans.plans[RangeSpec::SYSTEM]
389  = create_range_plan(location, RangeSpec::SYSTEM, system_specs, system_states);
390  plans.plans[RangeSpec::USER]
391  = create_range_plan(location, RangeSpec::USER, user_specs, user_states);
392 
393  // For all active moves in the "current set" whose destination is that of
394  // the failed server, assign the destination to be the same as the one
395  // chosen in the recovery plan
396  String new_location;
397  for (MoveSetT::iterator iter = m_current_set.begin();
398  iter != m_current_set.end(); ++iter) {
399  if (location == (*iter)->dest_location) {
400  QualifiedRangeSpec spec((*iter)->table, (*iter)->range);
401  if (plans.plans[RangeSpec::ROOT] && plans.plans[RangeSpec::ROOT]->receiver_plan.get_location(spec, new_location))
402  (*iter)->dest_location = new_location;
403  else if (plans.plans[RangeSpec::METADATA] && plans.plans[RangeSpec::METADATA]->receiver_plan.get_location(spec, new_location))
404  (*iter)->dest_location = new_location;
405  else if (plans.plans[RangeSpec::SYSTEM] && plans.plans[RangeSpec::SYSTEM]->receiver_plan.get_location(spec, new_location))
406  (*iter)->dest_location = new_location;
407  else if (plans.plans[RangeSpec::USER] && plans.plans[RangeSpec::USER]->receiver_plan.get_location(spec, new_location))
408  (*iter)->dest_location = new_location;
409  else {
410  std::stringstream sout;
411  sout << "Found " << (*iter)->table << " " << (*iter)->range
412  << " in current set assigned to location "
413  << location << ", but not in recovery plan";
414  HT_INFOF("%s", sout.str().c_str());
415  if (m_active_iter == m_active.end())
416  m_active_iter = m_active.begin();
417  (*iter)->dest_location = *m_active_iter;
418  m_active_iter++;
419  continue;
420  }
421  }
422  }
423 
424  // store the new plan
425  m_generation++;
426  m_map[location] = plans;
427 
428  lock.unlock(); // otherwise operator<< will deadlock
429 
435  {
436  vector<MetaLog::EntityPtr> entities;
438  if (!m_context->rsc_manager->remove_server(location, rsc))
439  HT_FATALF("Unable to location RangeServerConnection object for %s", location.c_str());
440  m_context->recovered_servers->add(location);
441  entities.push_back(shared_from_this());
442  entities.push_back(m_context->recovered_servers);
443  entities.push_back(rsc);
444  m_mml_writer->record_state(entities);
445  }
446 
447  std::stringstream sout;
448  sout << "Global recovery plan was modified: " << *this;
449  HT_INFOF("%s", sout.str().c_str());
450 }
451 
453 BalancePlanAuthority::create_range_plan(const String &location, int type,
454  const vector<QualifiedRangeSpec> &specs,
455  const vector<RangeState> &states)
456 {
457  if (specs.empty())
459 
460  const char *type_strings[] = { "root", "metadata", "system", "user", "UNKNOWN" };
461 
462  vector<uint32_t> fragments;
463 
464  RangeServerRecovery::PlanPtr plan = make_shared<RangeServerRecovery::Plan>(type);
465 
466  // read the fragments from the commit log
467  String log_dir = m_context->toplevel_dir + "/servers/" + location
468  + "/log/" + type_strings[type];
469  CommitLogReader clr(m_context->dfs, log_dir);
470  clr.get_init_fragment_ids(fragments);
471 
472  HT_ASSERT(specs.size() == states.size());
473 
474  // round robin through the locations and assign the ranges
475  for (size_t i=0; i<specs.size(); i++) {
476  if (m_active_iter == m_active.end())
477  m_active_iter = m_active.begin();
478  plan->receiver_plan.insert(*m_active_iter, specs[i], states[i]);
479  ++m_active_iter;
480  }
481 
482  m_active_iter = m_active.begin();
483  // round robin through the locations and assign the fragments
484  for (auto fragment : fragments) {
485  if (m_active_iter == m_active.end())
486  m_active_iter = m_active.begin();
487  plan->replay_plan.insert(fragment, *m_active_iter);
488  ++m_active_iter;
489  }
490 
491  HT_INFOF("Added recovery plan with %d fragments for %d %s ranges",
492  (int)fragments.size(), (int)specs.size(), type_strings[type]);
493 
494  return plan;
495 }
496 
497 
498 void
500  const String &location,
501  const vector<QualifiedRangeSpec> &new_specs)
502 {
503 
504  HT_ASSERT(m_active.find(location) == m_active.end());
505 
506  vector<int32_t> fragments;
507  plan->replay_plan.get_fragments(location.c_str(), fragments);
508  // round robin through the locations and assign the fragments
509  for (auto fragment : fragments) {
510  if (m_active_iter == m_active.end())
511  m_active_iter = m_active.begin();
512  plan->replay_plan.insert(fragment, *m_active_iter);
513  ++m_active_iter;
514  }
515 
516  std::set<QualifiedRangeSpec> purge_ranges;
517  for (const auto spec : new_specs)
518  purge_ranges.insert(spec);
519 
520  m_active_iter = m_active.begin();
521  vector<QualifiedRangeSpec> specs;
522  vector<RangeState> states;
523  plan->receiver_plan.get_range_specs_and_states(location, specs, states);
524  // round robin through the locations and assign the ranges
525  for (size_t i=0; i<specs.size(); i++) {
526  if (purge_ranges.count(specs[i]) > 0)
527  plan->receiver_plan.remove(specs[i]);
528  else {
529  if (m_active_iter == m_active.end())
530  m_active_iter = m_active.begin();
531  plan->receiver_plan.insert(*m_active_iter, specs[i], states[i]);
532  ++m_active_iter;
533  }
534  }
535 
536  if (plan->receiver_plan.empty())
537  plan = 0;
538 }
539 
540 bool
542  std::vector<MetaLog::EntityPtr> &entities) {
543  {
544  lock_guard<mutex> lock(m_mutex);
545 
546  if (generation != m_generation)
547  return false;
548 
549  // Insert moves into current set
550  for (auto &move : plan->moves)
551  m_current_set.insert(move);
552  }
553 
554  entities.push_back(shared_from_this());
555  m_mml_writer->record_state(entities);
556 
557  std::stringstream sout;
558  sout << "Balance plan registered move " << plan->moves.size()
559  << " ranges" << ", BalancePlan = " << *plan;
560  HT_INFOF("%s", sout.str().c_str());
561 
562  return true;
563 }
564 
565 bool
567  const RangeSpec &range, String &location) {
568  bool modified = false;
569  {
570  lock_guard<mutex> lock(m_mutex);
571 
572  RangeMoveSpecPtr move_spec = make_shared<RangeMoveSpec>();
573 
574  move_spec->table = table;
575  move_spec->range = range;
576 
577  MoveSetT::iterator iter;
578 
579  if ((iter = m_current_set.find(move_spec)) != m_current_set.end())
580  location = (*iter)->dest_location;
581  else {
582  if (!Utility::next_available_server(m_context, location, true))
583  return false;
584  move_spec->dest_location = location;
585  m_current_set.insert(move_spec);
586  modified = true;
587  }
588  }
589 
590  if (modified)
591  m_mml_writer->record_state(shared_from_this());
592 
593  return true;
594 }
595 
596 void
597 BalancePlanAuthority::balance_move_complete(const TableIdentifier &table,
598  const RangeSpec &range) {
599  lock_guard<mutex> lock(m_mutex);
600  RangeMoveSpecPtr move_spec = make_shared<RangeMoveSpec>();
601  std::stringstream sout;
602 
603  sout << "balance_move_complete for " << table << " " << range;
604  HT_INFOF("%s", sout.str().c_str());
605 
606  move_spec->table = table;
607  move_spec->range = range;
608 
609  MoveSetT::iterator iter;
610 
611  if ((iter = m_current_set.find(move_spec)) != m_current_set.end()) {
612  // the 'complete' and 'error' fields currently are not in use
613  (*iter)->complete = true;
614  (*iter)->error = 0;
615  m_current_set.erase(iter);
616  }
617 
618 }
bool get_balance_destination(const TableIdentifier &table, const RangeSpec &range, String &location)
Returns the balance plan destination for a given range.
std::set< String > StringSet
STL Set managing Strings.
Definition: StringExt.h:42
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
bool next_available_server(ContextPtr &context, String &location, bool urgent)
Gets name of next available server.
Definition: Utility.cc:304
Master MetaLog entity type constants.
void change_receiver_plan_location(const String &location, int type, const String &old_destination, const String &new_destination)
Modifies all failover plans by changing moves to a given destination to a new one.
BalancePlanAuthority(ContextPtr context, MetaLog::WriterPtr &mml_writer)
Constructor.
void remove_from_receiver_plan(const String &location, int type, const vector< QualifiedRangeSpec > &ranges)
Removes ranges from a failover plan.
Range specification.
Definition: RangeSpec.h:40
std::shared_ptr< RangeServerConnection > RangeServerConnectionPtr
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
std::shared_ptr< BalancePlan > BalancePlanPtr
Definition: BalancePlan.h:81
void display(std::ostream &os) override
Writes a human-readable represenation of object to an output stream.
Declarations for CommitLogReader.
uint8_t encoding_version() const override
Returns encoding version.
std::mutex m_mutex
Mutex for serializing access to members
void copy_recovery_plan(const String &location, int type, RangeServerRecovery::Plan &out, int &plan_generation)
Copies part of a recovery plan for a failed range server.
STL namespace.
void update_range_plan(RangeServerRecovery::PlanPtr &plan, const String &location, const vector< QualifiedRangeSpec > &new_specs)
Modifies recovery plan, replacing moves to location with a new destination.
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
void decode(const uint8_t **bufp, size_t *remainp, uint16_t definition_version) override
Reads serialized encoding of object.
size_t encoded_length_internal() const override
Returns internal serialized length.
MetaLog::WriterPtr m_mml_writer
Pointer to MML writer.
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
RangeServer recovery plan.
Definition: Plan.h:49
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Definition: Context.h:265
#define HT_ASSERT(_e_)
Definition: Logger.h:396
ReplayPlan replay_plan
Replay plan.
Definition: Plan.h:70
void remove_recovery_plan(const String &location)
Removes a recovery plan for a failed range server.
void remove_table_from_receiver_plan(const String &table_id)
Removes range move specifications for a table.
bool register_balance_plan(BalancePlanPtr &plan, int generation, std::vector< MetaLog::EntityPtr > &entities)
Registers a new balance plan for load balancing purposes.
bool decode_bool(const uint8_t **bufp, size_t *remainp)
Decodes a boolean value from the given buffer.
Definition: Serialization.h:96
void get_init_fragment_ids(std::vector< uint32_t > &ids)
uint16_t decode_i16(const uint8_t **bufp, size_t *remainp)
Decode a 16-bit integer in little-endian order.
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
RangeServerRecovery::PlanPtr create_range_plan(const String &location, int type, const vector< QualifiedRangeSpec > &specs, const vector< RangeState > &states)
Creates a recovery plan for a failed server.
Functions to serialize/deserialize primitives to/from a memory buffer.
void set_mml_writer(MetaLog::WriterPtr &mml_writer)
Sets the MML writer Sets m_mml_writer to mml_writer
void decode_old(const uint8_t **bufp, size_t *remainp)
MoveSetT m_current_set
Current set of move specifications for move operations.
ContextPtr m_context
Pointer to master context.
Provides sequential access to blocks in a commit log.
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
void lock()
Locks the entity's mutex.
Definition: MetaLogEntity.h:97
void encode_vstr(uint8_t **bufp, const void *buf, size_t len)
Encode a buffer as variable length string (vint64, data, null)
Hypertable definitions
#define HT_FATALF(msg,...)
Definition: Logger.h:343
Declarations for general-purpose utility functions.
void create_recovery_plan(const String &location, const vector< QualifiedRangeSpec > &root_specs, const vector< RangeState > &root_states, const vector< QualifiedRangeSpec > &metadata_specs, const vector< RangeState > &metadata_states, const vector< QualifiedRangeSpec > &system_specs, const vector< RangeState > &system_states, const vector< QualifiedRangeSpec > &user_specs, const vector< RangeState > &user_states)
Creates a recovery plan for a failed range server.
void legacy_decode(const uint8_t **bufp, size_t *remainp, BalancePlan *plan)
void encode_bool(uint8_t **bufp, bool bval)
Encodes a boolean into the given buffer.
Definition: Serialization.h:84
std::shared_ptr< Writer > WriterPtr
Smart pointer to Writer.
std::shared_ptr< Plan > PlanPtr
Smart pointer to Plan.
Definition: Plan.h:102
#define HT_INFOF(msg,...)
Definition: Logger.h:272
bool is_empty()
Determines if there are any failover balance plans.
Qualified (with table identifier) range specification.
std::shared_ptr< RangeMoveSpec > RangeMoveSpecPtr
int m_generation
Generation number (incremented with each new failover plan)
void get_receiver_plan_locations(const String &location, int type, StringSet &locations)
Returns the list of receiver location for a recovery plan.
bool recovery_complete(const String &location, int type)
Checks if recovery plan of given type has been removed.
ReceiverPlan receiver_plan
Receiver plan.
Definition: Plan.h:73
Declarations for BalancePlanAuthority.
StringSet::iterator m_active_iter
Iterator pointing into m_active.
Declarations for Context.
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
RecoveryPlanMap m_map
Mapping from failed range server to recovery plan.
StringSet m_active
Cache of active (available) servers.