0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Hypertable::RangeLocator Class Reference

Locates containing range given a key. More...

#include <RangeLocator.h>

Collaboration diagram for Hypertable::RangeLocator:
Collaboration graph
[legend]

Public Member Functions

 RangeLocator (PropertiesPtr &cfg, ConnectionManagerPtr &conn_mgr, Hyperspace::SessionPtr &hyperspace, uint32_t timeout_ms)
 Constructor. More...
 
 ~RangeLocator ()
 Destructor. More...
 
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. More...
 
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. More...
 
bool invalidate (const TableIdentifier *table, const char *row_key)
 Invalidates the cached entry for the given row key. More...
 
void invalidate_host (const std::string &hostname)
 
void set_root_stale ()
 Sets the "root stale" flag. More...
 
LocationCachePtr location_cache ()
 Returns the location cache. More...
 
void clear_error_history ()
 Clears the error history. More...
 
void dump_error_history ()
 Displays the error history. More...
 

Private Member Functions

void initialize (Timer &timer)
 
void hyperspace_disconnected ()
 
void hyperspace_reconnected ()
 
int process_metadata_scanblocks (std::vector< ScanBlock > &scan_blocks, Timer &timer)
 
int read_root_location (Timer &timer)
 
void initialize ()
 Assumes access is serialized via m_hyperspace_mutex. More...
 
int connect (CommAddress &addr, Timer &timer)
 

Private Attributes

std::mutex m_mutex
 
ConnectionManagerPtr m_conn_manager
 
Hyperspace::SessionPtr m_hyperspace
 
LocationCachePtr m_cache
 
uint64_t m_root_file_handle
 
Hyperspace::HandleCallbackPtr m_root_handler
 
bool m_root_stale
 
RangeLocationInfo m_root_range_info
 
Lib::RangeServer::Client m_range_server
 
uint8_t m_startrow_cid
 
uint8_t m_location_cid
 
TableIdentifier m_metadata_table
 
std::deque< Exceptionm_last_errors
 
bool m_hyperspace_init
 
bool m_hyperspace_connected
 
std::mutex m_hyperspace_mutex
 
uint32_t m_timeout_ms
 
RangeLocatorHyperspaceSessionCallback m_hyperspace_session_callback
 
std::string m_toplevel_dir
 
uint32_t m_metadata_readahead_count
 
uint32_t m_max_error_queue_length
 
uint32_t m_metadata_retry_interval
 
uint32_t m_root_metadata_retry_interval
 

Friends

class RangeLocatorHyperspaceSessionCallback
 

Detailed Description

Locates containing range given a key.

This class does the METADATA range searching to find the location of the range that contains a row key.

Definition at line 67 of file RangeLocator.h.

Constructor & Destructor Documentation

RangeLocator::RangeLocator ( PropertiesPtr cfg,
ConnectionManagerPtr conn_mgr,
Hyperspace::SessionPtr hyperspace,
uint32_t  timeout_ms 
)

Constructor.

Loads the METADATA schema and the root range address from Hyperspace. Installs a RootFileHandler to handle root range location changes.

Parameters
cfgreference to config properties
conn_mgrsmart pointer to connection manager
hyperspacesmart pointer to Hyperspace session
timeout_mstimeout in milliseconds

Definition at line 112 of file RangeLocator.cc.

RangeLocator::~RangeLocator ( )

Destructor.

Closes the root file in Hyperspace

Definition at line 225 of file RangeLocator.cc.

Member Function Documentation

void Hypertable::RangeLocator::clear_error_history ( )
inline

Clears the error history.

Definition at line 146 of file RangeLocator.h.

int RangeLocator::connect ( CommAddress addr,
Timer timer 
)
private

Definition at line 671 of file RangeLocator.cc.

void Hypertable::RangeLocator::dump_error_history ( )
inline

Displays the error history.

Definition at line 154 of file RangeLocator.h.

int RangeLocator::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.

Parameters
tablepointer to table identifier structure
row_keyrow key to locate
range_loc_infopaddress of RangeLocationInfo to hold result
timerreference to timer object
harddon't consult cache
Returns
Error::OK on success or error code on failure

If key is on ROOT metadata range, return root range information

at this point, we didn't find it so we need to do a METADATA lookup

Find second level METADATA range from root

Find actual range from second-level METADATA range

Definition at line 271 of file RangeLocator.cc.

void RangeLocator::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.

Parameters
tablepointer to table identifier structure
row_keyrow key to locate
range_loc_infopaddress of RangeLocationInfo to hold result
timerreference to timer object
harddon't consult cache

Definition at line 232 of file RangeLocator.cc.

void RangeLocator::hyperspace_disconnected ( )
private

Definition at line 142 of file RangeLocator.cc.

void RangeLocator::hyperspace_reconnected ( )
private

Definition at line 149 of file RangeLocator.cc.

void Hypertable::RangeLocator::initialize ( Timer timer)
private
void RangeLocator::initialize ( )
private

Assumes access is serialized via m_hyperspace_mutex.

Definition at line 159 of file RangeLocator.cc.

bool Hypertable::RangeLocator::invalidate ( const TableIdentifier table,
const char *  row_key 
)
inline

Invalidates the cached entry for the given row key.

Parameters
tablepointer to table identifier structure
row_keyrow key to invalidate
Returns
true if invalidated, false if not cached

Definition at line 116 of file RangeLocator.h.

void Hypertable::RangeLocator::invalidate_host ( const std::string &  hostname)
inline

Definition at line 122 of file RangeLocator.h.

LocationCachePtr Hypertable::RangeLocator::location_cache ( )
inline

Returns the location cache.

Definition at line 139 of file RangeLocator.h.

int RangeLocator::process_metadata_scanblocks ( std::vector< ScanBlock > &  scan_blocks,
Timer timer 
)
private

Definition at line 470 of file RangeLocator.cc.

int RangeLocator::read_root_location ( Timer timer)
private

NOTE: This block assumes that a change of root address means the old server has died. If root changes in the future can happen even when the original root server is still alive, this will have to change.

Definition at line 612 of file RangeLocator.cc.

void Hypertable::RangeLocator::set_root_stale ( )
inline

Sets the "root stale" flag.

Causes methods to reread the root range location before doing METADATA scans.

Definition at line 134 of file RangeLocator.h.

Friends And Related Function Documentation

Definition at line 162 of file RangeLocator.h.

Member Data Documentation

LocationCachePtr Hypertable::RangeLocator::m_cache
private

Definition at line 175 of file RangeLocator.h.

ConnectionManagerPtr Hypertable::RangeLocator::m_conn_manager
private

Definition at line 173 of file RangeLocator.h.

Hyperspace::SessionPtr Hypertable::RangeLocator::m_hyperspace
private

Definition at line 174 of file RangeLocator.h.

bool Hypertable::RangeLocator::m_hyperspace_connected
private

Definition at line 186 of file RangeLocator.h.

bool Hypertable::RangeLocator::m_hyperspace_init
private

Definition at line 185 of file RangeLocator.h.

std::mutex Hypertable::RangeLocator::m_hyperspace_mutex
private

Definition at line 187 of file RangeLocator.h.

RangeLocatorHyperspaceSessionCallback Hypertable::RangeLocator::m_hyperspace_session_callback
private

Definition at line 189 of file RangeLocator.h.

std::deque<Exception> Hypertable::RangeLocator::m_last_errors
private

Definition at line 184 of file RangeLocator.h.

uint8_t Hypertable::RangeLocator::m_location_cid
private

Definition at line 182 of file RangeLocator.h.

uint32_t Hypertable::RangeLocator::m_max_error_queue_length
private

Definition at line 192 of file RangeLocator.h.

uint32_t Hypertable::RangeLocator::m_metadata_readahead_count
private

Definition at line 191 of file RangeLocator.h.

uint32_t Hypertable::RangeLocator::m_metadata_retry_interval
private

Definition at line 193 of file RangeLocator.h.

TableIdentifier Hypertable::RangeLocator::m_metadata_table
private

Definition at line 183 of file RangeLocator.h.

std::mutex Hypertable::RangeLocator::m_mutex
private

Definition at line 172 of file RangeLocator.h.

Lib::RangeServer::Client Hypertable::RangeLocator::m_range_server
private

Definition at line 180 of file RangeLocator.h.

uint64_t Hypertable::RangeLocator::m_root_file_handle
private

Definition at line 176 of file RangeLocator.h.

Hyperspace::HandleCallbackPtr Hypertable::RangeLocator::m_root_handler
private

Definition at line 177 of file RangeLocator.h.

uint32_t Hypertable::RangeLocator::m_root_metadata_retry_interval
private

Definition at line 194 of file RangeLocator.h.

RangeLocationInfo Hypertable::RangeLocator::m_root_range_info
private

Definition at line 179 of file RangeLocator.h.

bool Hypertable::RangeLocator::m_root_stale
private

Definition at line 178 of file RangeLocator.h.

uint8_t Hypertable::RangeLocator::m_startrow_cid
private

Definition at line 181 of file RangeLocator.h.

uint32_t Hypertable::RangeLocator::m_timeout_ms
private

Definition at line 188 of file RangeLocator.h.

std::string Hypertable::RangeLocator::m_toplevel_dir
private

Definition at line 190 of file RangeLocator.h.


The documentation for this class was generated from the following files: