0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RangeLocator.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 
22 #include <Common/Compat.h>
23 
24 #include "Hyperspace/Session.h"
25 
26 #include <Hypertable/Lib/Key.h>
32 
33 #include <Common/Error.h>
34 #include <Common/ScopeGuard.h>
35 
36 #include <boost/algorithm/string.hpp>
37 
38 #include <cassert>
39 #include <chrono>
40 #include <cstdlib>
41 #include <cstring>
42 #include <thread>
43 #include <vector>
44 
45 extern "C" {
46 #include <limits.h>
47 #include <string.h>
48 }
49 
50 // convenient local macros to record errors for debugging
51 #define SAVE_ERR(_code_, _msg_) \
52  do { \
53  lock_guard<mutex> lock(m_mutex); \
54  m_last_errors.push_back(HT_EXCEPTION(_code_, _msg_)); \
55  while (m_last_errors.size() > m_max_error_queue_length) \
56  m_last_errors.pop_front(); \
57  } while (false)
58 
59 #define SAVE_ERR2(_code_, _ex_, _msg_) \
60  do { \
61  lock_guard<mutex> lock(m_mutex); \
62  m_last_errors.push_back(HT_EXCEPTION2(_code_, _ex_, _msg_)); \
63  while (m_last_errors.size() > m_max_error_queue_length) \
64  m_last_errors.pop_front(); \
65  } while (false)
66 
67 using namespace Hypertable;
68 using namespace Hypertable::Lib;
69 using namespace std;
70 
71 namespace {
72 
73  class MetaKeyBuilder {
74  public:
75  MetaKeyBuilder() : start(buf_start), end(buf_end) { }
76  void
77  build_keys(const char *format, const char *table_name, const char *row_key) {
78  int len_end = strlen(format) + strlen(table_name) + 3;
79  int len_start = len_end;
80  if (row_key) {
81  len_start += strlen(row_key);
82  if( len_start > size ) start = new char [len_start];
83  sprintf(start, format, table_name);
84  strcat(start, row_key);
85  }
86  else {
87  if( len_start > size ) start = new char [len_start];
88  sprintf(start, format, table_name);
89  }
90  if( len_end > size ) end = new char [len_end];
91  sprintf(end, format, table_name);
92  char *ptr = end + strlen(end);
93  *ptr++ = (char)0xff;
94  *ptr++ = (char)0xff;
95  *ptr = 0;
96  }
97  ~MetaKeyBuilder() {
98  if (start != buf_start) delete [] start;
99  if (end != buf_end) delete [] end;
100  }
101  char *start;
102  char *end;
103 
104  private:
105  enum { size = 64 };
106  char buf_start[size];
107  char buf_end[size];
108  };
109 }
110 
111 
113  Hyperspace::SessionPtr &hyperspace, uint32_t timeout_ms)
114  : m_conn_manager(conn_mgr), m_hyperspace(hyperspace),
115  m_root_stale(true), m_range_server(conn_mgr->get_comm(), timeout_ms),
116  m_hyperspace_init(false), m_hyperspace_connected(true),
117  m_timeout_ms(timeout_ms) {
118 
120  = cfg->get_i32("Hypertable.RangeLocator.MetadataReadaheadCount");
122  = cfg->get_i32("Hypertable.RangeLocator.MaxErrorQueueLength");
124  = cfg->get_i32("Hypertable.RangeLocator.MetadataRetryInterval");
126  = cfg->get_i32("Hypertable.RangeLocator.RootMetadataRetryInterval");
127 
128  int cache_size = cfg->get_i64("Hypertable.LocationCache.MaxEntries");
129 
130  m_toplevel_dir = cfg->get_str("Hypertable.Directory");
131  boost::trim_if(m_toplevel_dir, boost::is_any_of("/"));
133 
134  m_cache = make_shared<LocationCache>(cache_size);
135  // register hyperspace session callback
138  // no need to serialize access in ctor
139  initialize();
140 }
141 
143 {
144  lock_guard<mutex> lock(m_hyperspace_mutex);
145  m_hyperspace_init = false;
146  m_hyperspace_connected = false;
147 }
148 
150 {
151  lock_guard<mutex> lock(m_hyperspace_mutex);
153  m_hyperspace_connected = true;
154 }
155 
160  DynamicBuffer valbuf(0);
161  uint64_t handle = 0;
162  Timer timer(m_timeout_ms, true);
163 
164  if (m_hyperspace_init)
165  return;
167 
168  m_root_handler = make_shared<RootFileHandler>(this);
169 
172 
173  while (true) {
174  string metadata_file = m_toplevel_dir + "/tables/" + TableIdentifier::METADATA_ID;
175 
176  try {
177  handle = m_hyperspace->open(metadata_file, OPEN_FLAG_READ);
178  break;
179  }
180  catch (Exception &e) {
181  if (timer.expired())
182  HT_THROW2(Error::HYPERSPACE_FILE_NOT_FOUND, e, metadata_file);
183  this_thread::sleep_for(chrono::milliseconds(3000));
184  }
185  }
186 
188 
189  while (true) {
190  try {
191  m_hyperspace->attr_get(handle, "schema", valbuf);
192  break;
193  }
194  catch (Exception &) {
195  if (timer.expired()) {
196  m_hyperspace->close_nowait(handle);
197  throw;
198  }
199  this_thread::sleep_for(chrono::milliseconds(3000));
200  }
201  }
202 
203  SchemaPtr schema( Schema::new_instance((const char *)valbuf.base) );
204 
206  m_metadata_table.generation = schema->get_generation();
207 
208  ColumnFamilySpec *cf_spec;
209 
210  if ((cf_spec = schema->get_column_family("StartRow")) == 0) {
211  HT_ERROR("Unable to find column family 'StartRow' in METADATA schema");
213  }
214  m_startrow_cid = cf_spec->get_id();
215 
216  if ((cf_spec = schema->get_column_family("Location")) == 0) {
217  HT_ERROR("Unable to find column family 'Location' in METADATA schema");
219  }
220  m_location_cid = cf_spec->get_id();
221  m_hyperspace_init = true;
222 }
223 
224 
226  m_hyperspace->close_nowait(m_root_file_handle);
227  m_hyperspace->remove_callback(&m_hyperspace_session_callback);
228 }
229 
230 
231 void
232 RangeLocator::find_loop(const TableIdentifier *table, const char *row_key,
233  RangeLocationInfo *rane_loc_infop, Timer &timer, bool hard) {
234  int error;
235  uint32_t wait_time = 1000;
236  uint32_t total_wait_time = 0;
237 
238  error = find(table, row_key, rane_loc_infop, timer, hard);
239 
240  if (error == Error::TABLE_NOT_FOUND) {
242  HT_THROWF(error, "Table '%s' is (being) dropped", table->id);
243  }
244 
245  while (error != Error::OK) {
246 
247  // check for timer expiration
248  if (timer.remaining() < wait_time) {
250  HT_THROWF(Error::REQUEST_TIMEOUT, "Locating range for table %s row='%s'", table->id, row_key);
251  }
252 
253  // wait a bit
254  this_thread::sleep_for(chrono::milliseconds(wait_time));
255  total_wait_time += wait_time;
256  wait_time = (wait_time * 3) / 2;
257 
258  // try again
259  if ((error = find(table, row_key, rane_loc_infop, timer, true))
262  HT_THROWF(error, "Table '%s' is (being) dropped", table->id);
263  }
264  }
265 
267 }
268 
269 
270 int
271 RangeLocator::find(const TableIdentifier *table, const char *row_key,
272  RangeLocationInfo *rane_loc_infop, Timer &timer, bool hard) {
273  RangeSpec range;
274  ScanSpec meta_scan_spec;
275  vector<ScanBlock> scan_blocks(1);
276  int error;
277  Key key;
278  RangeLocationInfo range_loc_info;
279  string start_row;
280  string end_row;
281  CommAddress addr;
282  RowInterval ri;
283  bool inclusive = (row_key == 0 || *row_key == 0) ? true : false;
284  bool root_lookup = table->is_metadata() && (row_key == 0 || strcmp(row_key, Key::END_ROOT_ROW) <= 0);
285 
286  //HT_DEBUG_OUT << "Trying to locate " << table->id << "[" << row_key
287  // << "]" << " hard=" << hard << " m_root_stale=" << m_root_stale << " root_addr="
288  // << m_root_range_info.addr.to_str() << HT_END;
289 
290  if (m_root_stale || (hard && root_lookup)) {
291  if ((error = read_root_location(timer)) != Error::OK)
292  return error;
293  }
294 
295  {
296  lock_guard<mutex> lock(m_mutex);
297  addr = m_root_range_info.addr;
298  }
299 
300  if (!hard && m_cache->lookup(table->id, row_key, rane_loc_infop))
301  return Error::OK;
302 
306  if (root_lookup) {
307  rane_loc_infop->start_row = "";
308  rane_loc_infop->end_row = Key::END_ROOT_ROW;
309  rane_loc_infop->addr = addr;
310  return Error::OK;
311  }
312 
315  range.start_row = 0;
316  range.end_row = Key::END_ROOT_ROW;
317 
318  MetaKeyBuilder meta_keys;
319  char *meta_key;
320 
321  if (table->is_metadata())
322  meta_keys.build_keys("%s:", TableIdentifier::METADATA_ID, row_key);
323  else {
324  char format_str[8];
325  sprintf(format_str, "%s:%%s:", TableIdentifier::METADATA_ID);
326  meta_keys.build_keys(format_str, table->id, row_key);
327  }
328 
332  meta_key = meta_keys.start + TableIdentifier::METADATA_ID_LENGTH + 1;
333  if (hard || !m_cache->lookup(TableIdentifier::METADATA_ID, meta_key,
334  rane_loc_infop, inclusive)) {
335 
336  meta_scan_spec.row_limit = m_metadata_readahead_count;
337  meta_scan_spec.max_versions = 1;
338  meta_scan_spec.columns.push_back("StartRow");
339  meta_scan_spec.columns.push_back("Location");
340 
341  ri.start = meta_keys.start;
342  ri.start_inclusive = true;
343  ri.end = 0;
344  ri.end_inclusive = false;
345  meta_scan_spec.row_intervals.push_back(ri);
346 
347  meta_scan_spec.return_deletes = false;
348  // meta_scan_spec.interval = ????;
349 
350  try {
351  //HT_DEBUG_OUT << "Trying to locate " << table->id << "[" << row_key
352  // << "]" << " hard=" << hard << " m_root_stale=" << m_root_stale << " root_addr="
353  // << m_root_range_info.addr.to_str() << " scanning metadata at addr "
354  // << addr.to_str() << " scan_spec=" << meta_scan_spec << HT_END;
355 
357  meta_scan_spec, scan_blocks.back(), timer);
358  while (!scan_blocks.back().eos()) {
359  int scanner_id = scan_blocks.back().get_scanner_id();
360  scan_blocks.resize(scan_blocks.size()+1);
361  m_range_server.fetch_scanblock(addr, scanner_id, scan_blocks.back());
362  }
363  }
364  catch (Exception &e) {
365  if (e.code() == Error::COMM_NOT_CONNECTED ||
368  invalidate_host(addr.proxy);
369 
370  m_root_stale = true;
371 
372  SAVE_ERR2(e.code(), e, format("Problem creating scanner for start row "
373  "'%s' on METADATA[..??]", meta_keys.start));
374  return e.code();
375  }
376  catch (std::exception &e) {
377  HT_INFOF("std::exception - %s", e.what());
378  SAVE_ERR(Error::COMM_SEND_ERROR, e.what());
379  return Error::COMM_SEND_ERROR;
380  }
381 
382  if ((error = process_metadata_scanblocks(scan_blocks, timer)) != Error::OK) {
383  m_root_stale = true;
384  return error;
385  }
386 
387  if (!m_cache->lookup(TableIdentifier::METADATA_ID, meta_key,
388  rane_loc_infop, inclusive)) {
389  string err_msg = format("Unable to find metadata for row '%s' row_key=%s",
390  meta_keys.start, row_key);
391  HT_INFOF("%s", err_msg.c_str());
394  }
395  }
396 
397  if (table->is_metadata())
398  return Error::OK;
399 
404  range.start_row = rane_loc_infop->start_row.c_str();
405  range.end_row = rane_loc_infop->end_row.c_str();
406 
407  addr = rane_loc_infop->addr;
408 
409  meta_scan_spec.clear();
410 
411  meta_scan_spec.row_limit = m_metadata_readahead_count;
412  meta_scan_spec.max_versions = 1;
413  meta_scan_spec.columns.push_back("StartRow");
414  meta_scan_spec.columns.push_back("Location");
415 
416  ri.start = meta_keys.start+TableIdentifier::METADATA_ID_LENGTH + 1;
417  ri.start_inclusive = true;
418  ri.end = meta_keys.end+TableIdentifier::METADATA_ID_LENGTH+1;;
419  ri.end_inclusive = true;
420  meta_scan_spec.row_intervals.push_back(ri);
421 
422  // meta_scan_spec.interval = ????;
423 
424  try {
425  scan_blocks.clear();
426  scan_blocks.resize(1);
428  meta_scan_spec, scan_blocks.back(), timer);
429 
430  while (!scan_blocks.back().eos()) {
431  int scanner_id = scan_blocks.back().get_scanner_id();
432  scan_blocks.resize(scan_blocks.size()+1);
433  m_range_server.fetch_scanblock(addr, scanner_id, scan_blocks.back());
434  }
435  }
436  catch (Exception &e) {
437  if (e.code() == Error::COMM_NOT_CONNECTED ||
440  invalidate_host(addr.proxy);
443  meta_keys.start+TableIdentifier::METADATA_ID_LENGTH+1);
444  SAVE_ERR2(e.code(), e, format("Problem creating scanner on second-level "
445  "METADATA (start row = %s)", ri.start));
446  return e.code();
447  }
448  catch (std::exception &e) {
449  HT_INFOF("std::exception - %s", e.what());
450  SAVE_ERR(Error::COMM_SEND_ERROR, e.what());
451  return Error::COMM_SEND_ERROR;
452  }
453 
454  if ((error = process_metadata_scanblocks(scan_blocks, timer)) != Error::OK)
455  return error;
456 
457  if (row_key == 0)
458  row_key = "";
459 
460  if (!m_cache->lookup(table->id, row_key, rane_loc_infop, inclusive)) {
461  SAVE_ERR(Error::METADATA_NOT_FOUND, (String)"RangeLocator failed to find "
462  "metadata for table '" + table->id + "' row '" + row_key + "'");
464  }
465 
466  return Error::OK;
467 }
468 
469 
470 int RangeLocator::process_metadata_scanblocks(vector<ScanBlock> &scan_blocks, Timer &timer) {
471  RangeLocationInfo range_loc_info;
472  SerializedKey serkey;
473  ByteString value;
474  Key key;
475  const char *stripped_key;
476  string table_name;
477  CommAddressSet connected;
478 
479  range_loc_info.start_row = "";
480  range_loc_info.end_row = "";
481  range_loc_info.addr.clear();
482 
483  bool got_start_row = false;
484  bool got_end_row = false;
485  bool got_location = false;
486 
487  for (auto & scan_block : scan_blocks) {
488 
489  while (scan_block.next(serkey, value)) {
490 
491  if (!key.load(serkey)) {
492  string err_msg = format("METADATA lookup for '%s' returned bad key",
493  serkey.str() + 1);
494  HT_ERRORF("%s", err_msg.c_str());
497  }
498 
499  if ((stripped_key = strchr(key.row, ':')) == 0) {
500  string err_msg = format("Bad row key found in METADATA - '%s'", key.row);
501  HT_ERRORF("%s", err_msg.c_str());
504  }
505  stripped_key++;
506 #if 0
507  {
508  const uint8_t *str;
509  size_t len = value.decode_length(&str);
510  string tmp_str = String((const char *)str, len);
511  HT_DEBUG_OUT << "Got key=" << key << ", stripped_key "
512  << stripped_key << ", value=" << tmp_str << " got start_row="
513  << got_start_row << ", got_end_row=" << got_end_row
514  << ", got_location=" << got_location << HT_END;
515  }
516 #endif
517  if (got_end_row) {
518  if (strcmp(stripped_key, range_loc_info.end_row.c_str())) {
519  if (got_start_row && got_location) {
520 
521  // If not already connected, connect...
522  if (connected.count(range_loc_info.addr) == 0) {
523  if (connect(range_loc_info.addr, timer) == Error::OK)
524  connected.insert(range_loc_info.addr);
525  }
526 
527  m_cache->insert(table_name.c_str(), range_loc_info);
528 
529  //HT_DEBUG_OUT << "(1) cache insert table=" << table_name << " start="
530  // << range_loc_info.start_row << " end=" << range_loc_info.end_row
531  // << " loc=" << range_loc_info.addr.to_str() << HT_END;
532 
533  }
534  else {
535  //HT_DEBUG_OUT << "Incomplete METADATA record found =" << table_name << " end="
536  // << range_loc_info.end_row << " got start_row=" << got_start_row
537  // << ", got_end_row=" << got_end_row << ", got_location=" << got_location << HT_END;
538 
539  SAVE_ERR(Error::INVALID_METADATA, format("Incomplete METADATA record "
540  "found under row key '%s' (got_location=%s)", range_loc_info
541  .end_row.c_str(), got_location ? "true" : "false"));
542  }
543  range_loc_info.start_row = "";
544  range_loc_info.end_row = "";
545  range_loc_info.addr.clear();
546  got_start_row = false;
547  got_end_row = false;
548  got_location = false;
549  }
550  }
551  else {
552  const char *colon = strchr(key.row, ':');
553  assert(colon);
554  table_name.clear();
555  table_name.append(key.row, colon-key.row);
556  range_loc_info.end_row = stripped_key;
557  got_end_row = true;
558  }
559 
560  if (key.column_family_code == m_startrow_cid) {
561  const uint8_t *str;
562  size_t len = value.decode_length(&str);
563  //cout << "TS=" << key.timestamp << endl;
564  range_loc_info.start_row = String((const char *)str, len);
565  got_start_row = true;
566  }
567  else if (key.column_family_code == m_location_cid) {
568  const uint8_t *str;
569  size_t len = value.decode_length(&str);
570  if (str[0] == '!' && len == 1)
571  return Error::TABLE_NOT_FOUND;
572  range_loc_info.addr.set_proxy( String((const char *)str, len));
573  got_location = true;
574  }
575  else {
576  HT_ERRORF("METADATA lookup on row '%s' returned incorrect column (id=%d)",
577  serkey.row(), key.column_family_code);
578  }
579  }
580 
581  }
582 
583  if (got_start_row && got_end_row && got_location) {
584 
585  // If not already connected, connect...
586  if (connected.count(range_loc_info.addr) == 0) {
587  if (connect(range_loc_info.addr, timer) == Error::OK)
588  connected.insert(range_loc_info.addr);
589  }
590 
591  m_cache->insert(table_name.c_str(), range_loc_info);
592 
593  //HT_DEBUG_OUT << "(2) cache insert table=" << table_name << " start="
594  // << range_loc_info.start_row << " end=" << range_loc_info.end_row
595  // << " loc=" << range_loc_info.addr.to_str() << HT_END;
596 
597  }
598  else if (got_end_row) {
599  //HT_DEBUG_OUT << "Incomplete METADATA record found =" << table_name << " end="
600  // << range_loc_info.end_row << " got start_row=" << got_start_row
601  // << ", got_end_row=" << got_end_row << ", got_location=" << got_location << HT_END;
602 
603  SAVE_ERR(Error::INVALID_METADATA, format("Incomplete METADATA record found "
604  "under row key '%s' (got_location=%s)", range_loc_info
605  .end_row.c_str(), got_location ? "true" : "false"));
606  }
607 
608  return Error::OK;
609 }
610 
611 
613  DynamicBuffer value(0);
614  string addr_str;
615  CommAddress addr;
616  CommAddress old_addr;
617 
618  {
619  lock_guard<mutex> lock(m_hyperspace_mutex);
620  if (m_hyperspace_init)
621  m_hyperspace->attr_get(m_root_file_handle, "Location", value);
622  else if (m_hyperspace_connected) {
623  initialize();
624  m_hyperspace->attr_get(m_root_file_handle, "Location", value);
625  }
626  else
627  HT_THROW(Error::CONNECT_ERROR_HYPERSPACE, "RangeLocator not connected to Hyperspace");
628  }
629 
630  {
631  lock_guard<mutex> lock(m_mutex);
632  old_addr = m_root_range_info.addr;
635  m_root_range_info.addr.set_proxy( (const char *)value.base );
637  addr = m_root_range_info.addr;
638  }
639 
640  if (m_conn_manager) {
641 
648  if (old_addr.is_set() && old_addr != addr) {
649  m_conn_manager->remove(old_addr);
650  invalidate_host(old_addr.proxy);
651  }
652 
654  "Root RangeServer");
655 
656  if (!m_conn_manager->wait_for_connection(addr, 10000)) {
657  if (timer.expired()) {
658  HT_ERRORF("Timeout waiting for root RangeServer connection - %s",
659  addr.to_str().c_str());
660  return Error::REQUEST_TIMEOUT;
661  }
663  }
664  }
665 
666  m_root_stale = false;
667 
668  return Error::OK;
669 }
670 
672 
673  if (m_conn_manager) {
674  m_conn_manager->add(addr, m_metadata_retry_interval, "RangeServer");
675  if (!m_conn_manager->wait_for_connection(addr, 5000)) {
676  if (timer.expired())
677  return Error::REQUEST_TIMEOUT;
679  }
680  }
681  return Error::OK;
682 }
683 
686 }
687 
690 }
691 
692 
#define SAVE_ERR2(_code_, _ex_, _msg_)
Definition: RangeLocator.cc:59
RangeLocationInfo m_root_range_info
Definition: RangeLocator.h:179
LocationCachePtr m_cache
Definition: RangeLocator.h:175
int process_metadata_scanblocks(std::vector< ScanBlock > &scan_blocks, Timer &timer)
void create_scanner(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, const ScanSpec &scan_spec, DispatchHandler *handler)
Issues a "create scanner" request asynchronously.
Definition: Client.cc:217
const char * row
Definition: Key.h:129
static const char * METADATA_ID
Range specification.
Definition: RangeSpec.h:40
uint32_t m_metadata_retry_interval
Definition: RangeLocator.h:193
String proxy
Proxy name.
Definition: CommAddress.h:175
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
const char * row() const
Definition: SerializedKey.h:53
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Definition: String.cc:37
Po::typed_value< String > * str(String *v=0)
Definition: Properties.h:166
int connect(CommAddress &addr, Timer &timer)
Column family specification.
Holds range start and end row plus location.
void dump_error_history()
Displays the error history.
Definition: RangeLocator.h:154
STL namespace.
uint32_t remaining()
Returns the remaining time till expiry.
Definition: Timer.h:101
#define HT_ON_SCOPE_EXIT(...)
Definition: ScopeGuard.h:301
bool expired()
Returns true if the timer is expired.
Definition: Timer.h:112
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
Represents a row interval.
Definition: RowInterval.h:38
Lib::RangeServer::Client m_range_server
Definition: RangeLocator.h:180
A class managing one or more serializable ByteStrings.
Definition: ByteString.h:47
#define HT_ASSERT(_e_)
Definition: Logger.h:396
TableIdentifier m_metadata_table
Definition: RangeLocator.h:183
RangeLocator(PropertiesPtr &cfg, ConnectionManagerPtr &conn_mgr, Hyperspace::SessionPtr &hyperspace, uint32_t timeout_ms)
Constructor.
Scan predicate and control specification.
Definition: ScanSpec.h:56
const char * str() const
Returns a pointer to the String's deserialized data.
Definition: ByteString.h:106
const char * end_row
Definition: RangeSpec.h:60
std::shared_ptr< Session > SessionPtr
Definition: Session.h:734
void fetch_scanblock(const CommAddress &addr, int32_t scanner_id, DispatchHandler *handler)
Issues a "fetch scanblock" request asynchronously.
Definition: Client.cc:344
uint32_t m_metadata_readahead_count
Definition: RangeLocator.h:191
void invalidate_host(const std::string &hostname)
Definition: RangeLocator.h:122
#define SAVE_ERR(_code_, _msg_)
Definition: RangeLocator.cc:51
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
void set_proxy(const String &str)
Sets address type to CommAddress::PROXY and proxy name to p.
Definition: CommAddress.h:76
Compatibility Macros for C/C++.
bool load(const SerializedKey &key)
Parses the opaque key and loads the components into the member variables.
Definition: Key.cc:158
#define HT_END
Definition: Logger.h:220
int32_t get_id() const
Gets column ID.
Hyperspace::HandleCallbackPtr m_root_handler
Definition: RangeLocator.h:177
#define HT_THROW_(_code_)
Definition: Error.h:481
String to_str() const
Returns string representation of address.
Definition: CommAddress.cc:34
void close_handle(SessionPtr hyperspace, uint64_t handle)
Definition: Session.cc:1395
bool is_set() const
Returns true if address has been initialized.
Definition: CommAddress.h:159
Hypertable library.
Definition: CellInterval.h:30
Hypertable definitions
std::set< CommAddress > CommAddressSet
Set of CommAddress objects.
Definition: CommAddress.h:212
static Schema * new_instance(const std::string &buf)
Creates schema object from XML schema string.
Definition: Schema.cc:202
Hyperspace::SessionPtr m_hyperspace
Definition: RangeLocator.h:174
const char * start_row
Definition: RangeSpec.h:59
void initialize()
Assumes access is serialized via m_hyperspace_mutex.
#define HT_ERROR(msg)
Definition: Logger.h:299
static const int METADATA_ID_LENGTH
#define HT_INFOF(msg,...)
Definition: Logger.h:272
size_t decode_length(const uint8_t **dptr) const
Retrieves the decoded length and returns a pointer to the string.
Definition: ByteString.h:83
int read_root_location(Timer &timer)
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
Provides access to internal components of opaque key.
Definition: Key.h:40
uint8_t * base
Pointer to the allocated memory buffer.
uint32_t m_root_metadata_retry_interval
Definition: RangeLocator.h:194
RowIntervals row_intervals
Definition: ScanSpec.h:275
ConnectionManagerPtr m_conn_manager
Definition: RangeLocator.h:173
int find(const TableIdentifier *table, const char *row_key, RangeLocationInfo *range_loc_infop, Timer &timer, bool hard)
Locates the range that contains the given row key.
A timer class to keep timeout states across AsyncComm related calls.
Definition: Timer.h:44
This is a generic exception class for Hypertable.
Definition: Error.h:314
~RangeLocator()
Destructor.
Declarations for ScanBlock.
static const char * END_ROOT_ROW
Definition: Key.h:50
#define HT_ERRORF(msg,...)
Definition: Logger.h:300
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
uint8_t column_family_code
Definition: Key.h:127
Open file for reading.
Definition: Session.h:71
std::shared_ptr< ConnectionManager > ConnectionManagerPtr
Smart pointer to ConnectionManager.
void find_loop(const TableIdentifier *table, const char *row_key, RangeLocationInfo *range_loc_infop, Timer &timer, bool hard)
Locates the range that contains the given row key.
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478
void clear_error_history()
Clears the error history.
Definition: RangeLocator.h:146
Address abstraction to hold either proxy name or IPv4:port address.
Definition: CommAddress.h:52
#define HT_DEBUG_OUT
Definition: Logger.h:261
void clear()
Clears address to uninitialized state.
Definition: CommAddress.h:164
RangeLocatorHyperspaceSessionCallback m_hyperspace_session_callback
Definition: RangeLocator.h:189
int code() const
Returns the error code.
Definition: Error.h:391
#define HT_THROW2(_code_, _ex_, _msg_)
Definition: Error.h:484
Executes user-defined functions when leaving the current scope.