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

Provides the ability to mutate a table in the form of adding and deleting rows and cells. More...

#include <TableMutatorAsync.h>

Inheritance diagram for Hypertable::TableMutatorAsync:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::TableMutatorAsync:
Collaboration graph
[legend]

Public Member Functions

 TableMutatorAsync (PropertiesPtr &props, Comm *comm, ApplicationQueueInterfacePtr &app_queue, Table *table, RangeLocatorPtr &range_locator, uint32_t timeout_ms, ResultCallback *cb, uint32_t flags=0, bool explicit_block_only=false)
 Constructs the TableMutatorAsync object. More...
 
 TableMutatorAsync (std::mutex &mutex, std::condition_variable &cond, PropertiesPtr &props, Comm *comm, ApplicationQueueInterfacePtr &app_queue, Table *table, RangeLocatorPtr &range_locator, uint32_t timeout_ms, ResultCallback *cb, uint32_t flags=0, bool explicit_block_only=false, TableMutator *mutator=0)
 
virtual ~TableMutatorAsync ()
 Destructor for TableMutatorAsync object Make sure buffers are flushed and unsynced rangeservers get synced. More...
 
virtual uint64_t memory_used ()
 Returns the amount of memory used by the collected mutations in the current buffer. More...
 
uint64_t get_resend_count ()
 There are certain circumstances when mutations get flushed to the wrong range server due to stale range location information. More...
 
void set (const KeySpec &key, const void *value, uint32_t value_len)
 Inserts a cell into the table. More...
 
void set (const KeySpec &key, const char *value)
 Convenient helper for null-terminated values. More...
 
void set (const KeySpec &key, const std::string &value)
 Convenient helper for std::string values. More...
 
void set_delete (const KeySpec &key)
 Deletes an entire row, a column family in a particular row, or a specific cell within a row. More...
 
void set_cells (const Cells &cells)
 Insert a bunch of cells into the table (atomically if cells are in the same range/row) More...
 
void set_cells (Cells::const_iterator start, Cells::const_iterator end)
 Insert a bunch of cells into the table (atomically if cells are in the same range/row) More...
 
void flush (bool sync=true)
 Flushes the current buffer accumulated mutations to their respective range servers. More...
 
void buffer_finish (uint32_t id, int error, bool retry)
 This is where buffers call back into when their outstanding operations are complete. More...
 
void cancel ()
 
bool is_cancelled ()
 
void get_unsynced_rangeservers (std::vector< CommAddress > &unsynced)
 
TableMutatorAsyncScatterBufferPtr get_outstanding_buffer (size_t id)
 
bool retry (uint32_t timeout_ms)
 
void update_outstanding (TableMutatorAsyncScatterBufferPtr &buffer)
 
void get_failed_mutations (FailedMutations &failed_mutations)
 
bool has_outstanding ()
 
bool has_outstanding_unlocked ()
 
bool needs_flush ()
 
SchemaPtr schema ()
 
- Public Member Functions inherited from Hypertable::ClientObject
virtual ~ClientObject ()
 Destructor. More...
 

Protected Member Functions

void wait_for_completion ()
 

Private Types

enum  Operation { SET = 1, SET_CELLS, SET_DELETE, FLUSH }
 
typedef std::map< uint32_t,
TableMutatorAsyncScatterBufferPtr
ScatterBufferAsyncMap
 

Private Member Functions

void flush_with_tablequeue (TableMutator *mutator, bool sync=true)
 
void initialize (PropertiesPtr &props)
 
void initialize_indices (PropertiesPtr &props)
 
void update_without_index (const Cell &cell)
 
void update_without_index (const Key &full_key, const ColumnFamilySpec *cf, const Cell &cell)
 
void update_without_index (const Key &full_key, const ColumnFamilySpec *cf, const void *value, size_t value_len)
 
void do_sync ()
 Calls sync on any unsynced rangeservers and waits for completion. More...
 
void to_full_key (const void *row, const char *cf, const void *cq, int64_t ts, int64_t rev, uint8_t flag, Key &full_key, ColumnFamilySpec **pcf=0)
 
void to_full_key (const KeySpec &key, Key &full_key, ColumnFamilySpec **cf=0)
 
void to_full_key (const Cell &cell, Key &full_key, ColumnFamilySpec **cf=0)
 
void update_unsynced_rangeservers (const CommAddressSet &unsynced)
 
void handle_send_exceptions (const String &info)
 
bool mutated ()
 
bool key_uses_index (Key &key)
 
void update_with_index (Key &key, const ColumnFamilySpec *cf, const void *value, uint32_t value_len)
 

Private Attributes

PropertiesPtr m_props
 
Commm_comm
 
ApplicationQueueInterfacePtr m_app_queue
 
Tablem_table {}
 
SchemaPtr m_schema
 
RangeLocatorPtr m_range_locator
 
TableIdentifierManaged m_table_identifier
 
uint64_t m_memory_used {}
 
uint64_t m_max_memory {}
 
ScatterBufferAsyncMap m_outstanding_buffers
 
TableMutatorAsyncScatterBufferPtr m_current_buffer
 
uint64_t m_resends {}
 
uint32_t m_timeout_ms {}
 
ResultCallbackm_cb {}
 
uint32_t m_flags {}
 
CommAddressSet m_unsynced_rangeservers
 
std::mutex m_buffer_mutex
 
std::mutex & m_mutex
 
std::mutex m_member_mutex
 
std::condition_variable m_buffer_cond
 
std::condition_variable & m_cond
 
uint32_t m_next_buffer_id {}
 
FailedMutations m_failed_mutations
 
TableMutatorAsyncPtr m_index_mutator
 
TableMutatorAsyncPtr m_qualifier_index_mutator
 
IndexMutatorCallbackPtr m_imc
 
TableMutatorm_mutator {}
 
bool m_explicit_block_only {}
 
bool m_cancelled {}
 
bool m_mutated {}
 
bool m_use_index {}
 

Static Private Attributes

static const uint32_t ms_max_sync_retries = 5
 

Friends

class TableMutator
 flush function reserved for use in TableMutator More...
 
class IndexMutatorCallback
 

Detailed Description

Provides the ability to mutate a table in the form of adding and deleting rows and cells.

Objects of this class are used to collect mutations and periodically flush them to the appropriate range servers. There is a 1 MB buffer of mutations for each range server. When one of the buffers fills up all the buffers are flushed to their respective range servers.

Definition at line 61 of file TableMutatorAsync.h.

Member Typedef Documentation

Definition at line 264 of file TableMutatorAsync.h.

Member Enumeration Documentation

Enumerator
SET 
SET_CELLS 
SET_DELETE 
FLUSH 

Definition at line 222 of file TableMutatorAsync.h.

Constructor & Destructor Documentation

TableMutatorAsync::TableMutatorAsync ( PropertiesPtr props,
Comm comm,
ApplicationQueueInterfacePtr app_queue,
Table table,
RangeLocatorPtr range_locator,
uint32_t  timeout_ms,
ResultCallback cb,
uint32_t  flags = 0,
bool  explicit_block_only = false 
)

Constructs the TableMutatorAsync object.

Parameters
propsreference to properties smart pointer
commpointer to the Comm layer
app_queuepointer to the Application Queue
tablepointer to the table object
range_locatorsmart pointer to range locator
timeout_msmaximum time in milliseconds to allow methods to execute before throwing an exception
cbcallback for this mutator
flagsrangeserver client update command flags
explicit_block_onlyif true TableMutatorAsync will not auto_flush or wait_for_completion unless explicitly told to do so by caller

Definition at line 63 of file TableMutatorAsync.cc.

TableMutatorAsync::TableMutatorAsync ( std::mutex &  mutex,
std::condition_variable &  cond,
PropertiesPtr props,
Comm comm,
ApplicationQueueInterfacePtr app_queue,
Table table,
RangeLocatorPtr range_locator,
uint32_t  timeout_ms,
ResultCallback cb,
uint32_t  flags = 0,
bool  explicit_block_only = false,
TableMutator mutator = 0 
)

Definition at line 75 of file TableMutatorAsync.cc.

TableMutatorAsync::~TableMutatorAsync ( )
virtual

Destructor for TableMutatorAsync object Make sure buffers are flushed and unsynced rangeservers get synced.

Definition at line 106 of file TableMutatorAsync.cc.

Member Function Documentation

void TableMutatorAsync::buffer_finish ( uint32_t  id,
int  error,
bool  retry 
)

This is where buffers call back into when their outstanding operations are complete.

Parameters
idid of the buffer
errorerror code for finished buffer
retrytrue if buffer has retries

Definition at line 643 of file TableMutatorAsync.cc.

void TableMutatorAsync::cancel ( )

Definition at line 449 of file TableMutatorAsync.cc.

void TableMutatorAsync::do_sync ( )
private

Calls sync on any unsynced rangeservers and waits for completion.

Commit log sync failed

Definition at line 543 of file TableMutatorAsync.cc.

void TableMutatorAsync::flush ( bool  sync = true)

Flushes the current buffer accumulated mutations to their respective range servers.

Parameters
syncif false then theres no guarantee that the data is synced disk

Definition at line 468 of file TableMutatorAsync.cc.

void TableMutatorAsync::flush_with_tablequeue ( TableMutator mutator,
bool  sync = true 
)
private

Definition at line 472 of file TableMutatorAsync.cc.

void Hypertable::TableMutatorAsync::get_failed_mutations ( FailedMutations failed_mutations)
inline

Definition at line 187 of file TableMutatorAsync.h.

TableMutatorAsyncScatterBufferPtr TableMutatorAsync::get_outstanding_buffer ( size_t  id)

Definition at line 619 of file TableMutatorAsync.cc.

uint64_t Hypertable::TableMutatorAsync::get_resend_count ( )
inline

There are certain circumstances when mutations get flushed to the wrong range server due to stale range location information.

When the correct location information is discovered, these mutations get resent to the proper range server. This method returns the number of mutations that were resent.

Returns
number of mutations that were resent

Definition at line 113 of file TableMutatorAsync.h.

void TableMutatorAsync::get_unsynced_rangeservers ( std::vector< CommAddress > &  unsynced)

Definition at line 536 of file TableMutatorAsync.cc.

void TableMutatorAsync::handle_send_exceptions ( const String info)
private

Definition at line 42 of file TableMutatorAsync.cc.

bool Hypertable::TableMutatorAsync::has_outstanding ( )
inline

Definition at line 191 of file TableMutatorAsync.h.

bool Hypertable::TableMutatorAsync::has_outstanding_unlocked ( )
inline

Definition at line 195 of file TableMutatorAsync.h.

void TableMutatorAsync::initialize ( PropertiesPtr props)
private

Definition at line 87 of file TableMutatorAsync.cc.

void TableMutatorAsync::initialize_indices ( PropertiesPtr props)
private

Definition at line 127 of file TableMutatorAsync.cc.

bool TableMutatorAsync::is_cancelled ( )

Definition at line 454 of file TableMutatorAsync.cc.

bool Hypertable::TableMutatorAsync::key_uses_index ( Key key)
private
virtual uint64_t Hypertable::TableMutatorAsync::memory_used ( )
inlinevirtual

Returns the amount of memory used by the collected mutations in the current buffer.

Returns
amount of memory used by the collected mutations.

Definition at line 102 of file TableMutatorAsync.h.

bool Hypertable::TableMutatorAsync::mutated ( )
inlineprivate

Definition at line 254 of file TableMutatorAsync.h.

bool TableMutatorAsync::needs_flush ( )

Definition at line 459 of file TableMutatorAsync.cc.

bool Hypertable::TableMutatorAsync::retry ( uint32_t  timeout_ms)
SchemaPtr Hypertable::TableMutatorAsync::schema ( )
inline

Definition at line 200 of file TableMutatorAsync.h.

void TableMutatorAsync::set ( const KeySpec key,
const void *  value,
uint32_t  value_len 
)

Inserts a cell into the table.

Parameters
keykey of the cell being inserted
valuepointer to the value to store in the cell
value_lenlength of data pointed to by value

Definition at line 192 of file TableMutatorAsync.cc.

void Hypertable::TableMutatorAsync::set ( const KeySpec key,
const char *  value 
)
inline

Convenient helper for null-terminated values.

Definition at line 127 of file TableMutatorAsync.h.

void Hypertable::TableMutatorAsync::set ( const KeySpec key,
const std::string &  value 
)
inline

Convenient helper for std::string values.

Definition at line 137 of file TableMutatorAsync.h.

void Hypertable::TableMutatorAsync::set_cells ( const Cells cells)
inline

Insert a bunch of cells into the table (atomically if cells are in the same range/row)

Parameters
cellsa list of cells

Definition at line 155 of file TableMutatorAsync.h.

void TableMutatorAsync::set_cells ( Cells::const_iterator  start,
Cells::const_iterator  end 
)

Insert a bunch of cells into the table (atomically if cells are in the same range/row)

Parameters
startIterator pointing to start of cells to be inserted
endIterator pointing to end of cells to be inserted

Definition at line 294 of file TableMutatorAsync.cc.

void TableMutatorAsync::set_delete ( const KeySpec key)

Deletes an entire row, a column family in a particular row, or a specific cell within a row.

Parameters
keykey of the row or cell(s) being deleted

Definition at line 350 of file TableMutatorAsync.cc.

void TableMutatorAsync::to_full_key ( const void *  row,
const char *  cf,
const void *  cq,
int64_t  ts,
int64_t  rev,
uint8_t  flag,
Key full_key,
ColumnFamilySpec **  pcf = 0 
)
private

Definition at line 401 of file TableMutatorAsync.cc.

void Hypertable::TableMutatorAsync::to_full_key ( const KeySpec key,
Key full_key,
ColumnFamilySpec **  cf = 0 
)
inlineprivate

Definition at line 238 of file TableMutatorAsync.h.

void Hypertable::TableMutatorAsync::to_full_key ( const Cell cell,
Key full_key,
ColumnFamilySpec **  cf = 0 
)
inlineprivate

Definition at line 244 of file TableMutatorAsync.h.

void TableMutatorAsync::update_outstanding ( TableMutatorAsyncScatterBufferPtr buffer)

Definition at line 633 of file TableMutatorAsync.cc.

void TableMutatorAsync::update_unsynced_rangeservers ( const CommAddressSet unsynced)
private

Definition at line 628 of file TableMutatorAsync.cc.

void TableMutatorAsync::update_with_index ( Key key,
const ColumnFamilySpec cf,
const void *  value,
uint32_t  value_len 
)
private

Definition at line 161 of file TableMutatorAsync.cc.

void TableMutatorAsync::update_without_index ( const Cell cell)
private

Definition at line 237 of file TableMutatorAsync.cc.

void TableMutatorAsync::update_without_index ( const Key full_key,
const ColumnFamilySpec cf,
const Cell cell 
)
private

Definition at line 270 of file TableMutatorAsync.cc.

void TableMutatorAsync::update_without_index ( const Key full_key,
const ColumnFamilySpec cf,
const void *  value,
size_t  value_len 
)
private

Definition at line 277 of file TableMutatorAsync.cc.

void TableMutatorAsync::wait_for_completion ( )
protected

Definition at line 155 of file TableMutatorAsync.cc.

Friends And Related Function Documentation

friend class IndexMutatorCallback
friend

Definition at line 214 of file TableMutatorAsync.h.

friend class TableMutator
friend

flush function reserved for use in TableMutator

Definition at line 207 of file TableMutatorAsync.h.

Member Data Documentation

ApplicationQueueInterfacePtr Hypertable::TableMutatorAsync::m_app_queue
private

Definition at line 270 of file TableMutatorAsync.h.

std::condition_variable Hypertable::TableMutatorAsync::m_buffer_cond
private

Definition at line 287 of file TableMutatorAsync.h.

std::mutex Hypertable::TableMutatorAsync::m_buffer_mutex
private

Definition at line 284 of file TableMutatorAsync.h.

bool Hypertable::TableMutatorAsync::m_cancelled {}
private

Definition at line 296 of file TableMutatorAsync.h.

ResultCallback* Hypertable::TableMutatorAsync::m_cb {}
private

Definition at line 281 of file TableMutatorAsync.h.

Comm* Hypertable::TableMutatorAsync::m_comm
private

Definition at line 269 of file TableMutatorAsync.h.

std::condition_variable& Hypertable::TableMutatorAsync::m_cond
private

Definition at line 288 of file TableMutatorAsync.h.

TableMutatorAsyncScatterBufferPtr Hypertable::TableMutatorAsync::m_current_buffer
private

Definition at line 278 of file TableMutatorAsync.h.

bool Hypertable::TableMutatorAsync::m_explicit_block_only {}
private

Definition at line 295 of file TableMutatorAsync.h.

FailedMutations Hypertable::TableMutatorAsync::m_failed_mutations
private

Definition at line 290 of file TableMutatorAsync.h.

uint32_t Hypertable::TableMutatorAsync::m_flags {}
private

Definition at line 282 of file TableMutatorAsync.h.

IndexMutatorCallbackPtr Hypertable::TableMutatorAsync::m_imc
private

Definition at line 293 of file TableMutatorAsync.h.

TableMutatorAsyncPtr Hypertable::TableMutatorAsync::m_index_mutator
private

Definition at line 291 of file TableMutatorAsync.h.

uint64_t Hypertable::TableMutatorAsync::m_max_memory {}
private

Definition at line 276 of file TableMutatorAsync.h.

std::mutex Hypertable::TableMutatorAsync::m_member_mutex
private

Definition at line 286 of file TableMutatorAsync.h.

uint64_t Hypertable::TableMutatorAsync::m_memory_used {}
private

Definition at line 275 of file TableMutatorAsync.h.

bool Hypertable::TableMutatorAsync::m_mutated {}
private

Definition at line 297 of file TableMutatorAsync.h.

TableMutator* Hypertable::TableMutatorAsync::m_mutator {}
private

Definition at line 294 of file TableMutatorAsync.h.

std::mutex& Hypertable::TableMutatorAsync::m_mutex
private

Definition at line 285 of file TableMutatorAsync.h.

uint32_t Hypertable::TableMutatorAsync::m_next_buffer_id {}
private

Definition at line 289 of file TableMutatorAsync.h.

ScatterBufferAsyncMap Hypertable::TableMutatorAsync::m_outstanding_buffers
private

Definition at line 277 of file TableMutatorAsync.h.

PropertiesPtr Hypertable::TableMutatorAsync::m_props
private

Definition at line 268 of file TableMutatorAsync.h.

TableMutatorAsyncPtr Hypertable::TableMutatorAsync::m_qualifier_index_mutator
private

Definition at line 292 of file TableMutatorAsync.h.

RangeLocatorPtr Hypertable::TableMutatorAsync::m_range_locator
private

Definition at line 273 of file TableMutatorAsync.h.

uint64_t Hypertable::TableMutatorAsync::m_resends {}
private

Definition at line 279 of file TableMutatorAsync.h.

SchemaPtr Hypertable::TableMutatorAsync::m_schema
private

Definition at line 272 of file TableMutatorAsync.h.

Table* Hypertable::TableMutatorAsync::m_table {}
private

Definition at line 271 of file TableMutatorAsync.h.

TableIdentifierManaged Hypertable::TableMutatorAsync::m_table_identifier
private

Definition at line 274 of file TableMutatorAsync.h.

uint32_t Hypertable::TableMutatorAsync::m_timeout_ms {}
private

Definition at line 280 of file TableMutatorAsync.h.

CommAddressSet Hypertable::TableMutatorAsync::m_unsynced_rangeservers
private

Definition at line 283 of file TableMutatorAsync.h.

bool Hypertable::TableMutatorAsync::m_use_index {}
private

Definition at line 298 of file TableMutatorAsync.h.

const uint32_t Hypertable::TableMutatorAsync::ms_max_sync_retries = 5
staticprivate

Definition at line 266 of file TableMutatorAsync.h.


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