Provides the ability to mutate a table in the form of adding and deleting rows and cells. More...
#include <TableMutator.h>
Public Types | |
enum | { FLAG_NO_LOG_SYNC = Table::MUTATOR_FLAG_NO_LOG_SYNC, FLAG_NO_LOG = Table::MUTATOR_FLAG_NO_LOG } |
Public Member Functions | |
TableMutator (PropertiesPtr &props, Comm *comm, Table *table, RangeLocatorPtr &range_locator, uint32_t timeout_ms, uint32_t flags=0) | |
Constructs the TableMutator object. More... | |
virtual | ~TableMutator () |
Destructor for TableMutator object Make sure buffers are flushed and unsynced rangeservers get synced. More... | |
virtual 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... | |
virtual 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... | |
virtual void | set_cells (const Cells &cells) |
Insert a bunch of cells into the table (atomically if cells are in the same range/row) More... | |
virtual void | flush () |
Flushes the accumulated mutations to their respective range servers. More... | |
virtual bool | retry (uint32_t timeout_ms=0) |
Retries the last operation. More... | |
virtual bool | need_retry () |
Checks for failed mutations. More... | |
virtual uint64_t | memory_used () |
Returns the amount of memory used by the collected mutations. 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... | |
virtual void | get_failed (FailedMutations &failed_mutations) |
Returns the failed mutations. More... | |
std::ostream & | show_failed (const Exception &, std::ostream &=std::cout) |
Show failed mutations. More... | |
void | update_ok () |
void | update_error (int error, FailedMutations &failures) |
int32_t | get_last_error () |
Public Member Functions inherited from Hypertable::ClientObject | |
virtual | ~ClientObject () |
Destructor. More... | |
Private Types | |
enum | Operation { SET = 1, SET_CELLS, SET_DELETE, FLUSH } |
Private Member Functions | |
void | auto_flush () |
void | wait_for_flush_completion (TableMutatorAsync *mutator) |
void | set_last_error (int32_t error) |
void | save_last (const KeySpec &key, const void *value, size_t value_len) |
void | save_last (Cells::const_iterator it, Cells::const_iterator end) |
void | set_cells (Cells::const_iterator start, Cells::const_iterator end) |
void | handle_exceptions () |
void | retry_flush () |
Private Attributes | |
std::mutex | m_mutex |
std::mutex | m_queue_mutex |
std::condition_variable | m_cond |
PropertiesPtr | m_props |
Comm * | m_comm |
TablePtr | m_table |
SchemaPtr | m_schema |
RangeLocatorPtr | m_range_locator |
TableIdentifierManaged | m_table_identifier |
uint64_t | m_memory_used |
uint64_t | m_max_memory |
TableCallback | m_callback |
TableMutatorQueuePtr | m_queue |
TableMutatorAsyncPtr | m_mutator |
uint32_t | m_timeout_ms |
uint32_t | m_flags |
uint32_t | m_flush_delay |
int32_t | m_last_error |
int | m_last_op |
KeySpec | m_last_key |
const void * | m_last_value |
uint32_t | m_last_value_len |
Cells::const_iterator | m_last_cells_it |
Cells::const_iterator | m_last_cells_end |
bool | m_refresh_schema |
bool | m_unflushed_updates |
FailedMutations | m_failed_mutations |
CellsBuilderPtr | m_failed_cells |
Static Private Attributes | |
static const uint32_t | ms_max_sync_retries = 5 |
Friends | |
class | TableMutatorAsync |
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 55 of file TableMutator.h.
anonymous enum |
Enumerator | |
---|---|
FLAG_NO_LOG_SYNC | |
FLAG_NO_LOG |
Definition at line 58 of file TableMutator.h.
|
private |
Enumerator | |
---|---|
SET | |
SET_CELLS | |
SET_DELETE | |
FLUSH |
Definition at line 201 of file TableMutator.h.
TableMutator::TableMutator | ( | PropertiesPtr & | props, |
Comm * | comm, | ||
Table * | table, | ||
RangeLocatorPtr & | range_locator, | ||
uint32_t | timeout_ms, | ||
uint32_t | flags = 0 |
||
) |
Constructs the TableMutator object.
props | reference to properties smart pointer |
comm | pointer to the Comm layer |
table | pointer to the table object |
range_locator | smart pointer to range locator |
timeout_ms | maximum time in milliseconds to allow methods to execute before throwing an exception |
flags | rangeserver client update command flags |
Definition at line 59 of file TableMutator.cc.
|
virtual |
Destructor for TableMutator object Make sure buffers are flushed and unsynced rangeservers get synced.
Definition at line 74 of file TableMutator.cc.
|
private |
Definition at line 149 of file TableMutator.cc.
|
virtual |
Flushes the accumulated mutations to their respective range servers.
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 171 of file TableMutator.cc.
|
inlinevirtual |
Returns the failed mutations.
failed_mutations | reference to vector of Cell/error pairs |
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 173 of file TableMutator.h.
|
inline |
Definition at line 184 of file TableMutator.h.
|
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.
Definition at line 166 of file TableMutator.h.
|
private |
Definition at line 40 of file TableMutator.cc.
|
inlinevirtual |
Returns the amount of memory used by the collected mutations.
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 155 of file TableMutator.h.
|
inlinevirtual |
Checks for failed mutations.
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 145 of file TableMutator.h.
|
virtual |
Retries the last operation.
timeout_ms | timeout in milliseconds, 0 means use default timeout |
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 223 of file TableMutator.cc.
|
private |
Definition at line 256 of file TableMutator.cc.
|
inlineprivate |
Definition at line 208 of file TableMutator.h.
|
inlineprivate |
Definition at line 214 of file TableMutator.h.
|
virtual |
Inserts a cell into the table.
key | key of the cell being inserted |
value | pointer to the value to store in the cell |
value_len | length of data pointed to by value |
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 86 of file TableMutator.cc.
|
inline |
Convenient helper for null-terminated values.
Definition at line 96 of file TableMutator.h.
|
inline |
Convenient helper for std::string values.
Definition at line 106 of file TableMutator.h.
|
inlinevirtual |
Insert a bunch of cells into the table (atomically if cells are in the same range/row)
cells | a list of cells |
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 124 of file TableMutator.h.
|
private |
Definition at line 108 of file TableMutator.cc.
|
virtual |
Deletes an entire row, a column family in a particular row, or a specific cell within a row.
key | key of the row or cell(s) being deleted |
Reimplemented in Hypertable::TableMutatorShared.
Definition at line 129 of file TableMutator.cc.
|
inlineprivate |
Definition at line 196 of file TableMutator.h.
std::ostream & TableMutator::show_failed | ( | const Exception & | e, |
std::ostream & | out = std::cout |
||
) |
Show failed mutations.
Definition at line 278 of file TableMutator.cc.
void TableMutator::update_error | ( | int | error, |
FailedMutations & | failures | ||
) |
Definition at line 306 of file TableMutator.cc.
void TableMutator::update_ok | ( | ) |
Definition at line 298 of file TableMutator.cc.
|
private |
Definition at line 195 of file TableMutator.cc.
|
friend |
Definition at line 193 of file TableMutator.h.
|
private |
Definition at line 236 of file TableMutator.h.
|
private |
Definition at line 229 of file TableMutator.h.
|
private |
Definition at line 227 of file TableMutator.h.
|
private |
Definition at line 253 of file TableMutator.h.
|
private |
Definition at line 252 of file TableMutator.h.
|
private |
Definition at line 240 of file TableMutator.h.
|
private |
Definition at line 241 of file TableMutator.h.
|
private |
Definition at line 248 of file TableMutator.h.
|
private |
Definition at line 247 of file TableMutator.h.
|
private |
Definition at line 242 of file TableMutator.h.
|
private |
Definition at line 244 of file TableMutator.h.
|
private |
Definition at line 243 of file TableMutator.h.
|
private |
Definition at line 245 of file TableMutator.h.
|
private |
Definition at line 246 of file TableMutator.h.
|
private |
Definition at line 235 of file TableMutator.h.
|
private |
Definition at line 234 of file TableMutator.h.
|
private |
Definition at line 238 of file TableMutator.h.
|
private |
Definition at line 225 of file TableMutator.h.
|
private |
Definition at line 228 of file TableMutator.h.
|
private |
Definition at line 237 of file TableMutator.h.
|
private |
Definition at line 226 of file TableMutator.h.
|
private |
Definition at line 232 of file TableMutator.h.
|
private |
Definition at line 250 of file TableMutator.h.
|
private |
Definition at line 231 of file TableMutator.h.
|
private |
Definition at line 230 of file TableMutator.h.
|
private |
Definition at line 233 of file TableMutator.h.
|
private |
Definition at line 239 of file TableMutator.h.
|
private |
Definition at line 251 of file TableMutator.h.
|
staticprivate |
Definition at line 249 of file TableMutator.h.