44 #include <boost/algorithm/string.hpp>
60 const uint8_t *ptr =
event->payload;
61 size_t remaining =
event->payload_len;
121 HT_INFOF(
"Entering Compact-%lld (table=%s, row=%s) state=%s",
153 m_context->get_available_servers(servers);
158 for (StringSet::iterator iter=servers.begin(); iter!=servers.end(); ++iter) {
166 m_context->mml_writer->record_state(shared_from_this());
174 if (!op_handler->wait_for_completion()) {
175 std::set<DispatchHandlerOperation::Result> results;
176 op_handler->get_results(results);
177 for (
const auto &result : results) {
184 HT_WARNF(
"Compact error at %s - %s (%s)", result.location.c_str(),
196 this_thread::sleep_for(chrono::milliseconds(5000));
197 m_context->mml_writer->record_state(shared_from_this());
204 HT_FATALF(
"Unrecognized state %d", state);
207 HT_INFOF(
"Leaving Compact-%lld (table=%s, row=%s) state=%s",
251 for (
size_t i=0; i<length; i++)
254 for (
size_t i=0; i<length; i++)
268 for (
size_t i=0; i<length; i++)
272 for (
size_t i=0; i<length; i++)
278 return "OperationCompact";
std::set< String > StringSet
STL Set managing Strings.
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
void execute() override
Carries out the manual compaction operation.
#define HT_WARNF(msg,...)
The FailureInducer simulates errors.
void encode_state(uint8_t **bufp) const override
Writes serialized encoding of object state.
ContextPtr m_context
Pointer to Master context.
Declarations for DispatchHandlerOperationCompact.
std::string String
A String is simply a typedef to std::string.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
virtual size_t encoded_length() const
Returns serialized object length.
OperationCompact(ContextPtr &context, const MetaLog::EntityHeader &header_)
Constructor for constructing object from MetaLog entry.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
StringSet m_completed
Set of range servers that have completed operation.
Request parameters for compact operation.
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
size_t encoded_length_state() const override
Returns serialized state length.
const std::string & row() const
Gets row identifying range to be compacted.
const char * get_text(int32_t state)
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
std::string m_id
Table identifier
Lib::Master::Request::Parameters::Compact m_params
Request parmaeters.
Declarations for RangeServerProtocol.
Declarations for OperationCompact.
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
StringSet m_servers
Set of participating range servers.
void set_state(int32_t state)
const char * get_text(int error)
Returns a descriptive error message.
void add_dependency(const String &dependency)
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
Functions to serialize/deserialize primitives to/from a memory buffer.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
void encode_vstr(uint8_t **bufp, const void *buf, size_t len)
Encode a buffer as variable length string (vint64, data, null)
#define HT_FATALF(msg,...)
long long int Lld
Shortcut for printf formats.
void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Declarations for general-purpose utility functions.
const std::string label() override
Returns descriptive label for operation.
DependencySet m_dependencies
Set of dependencies.
#define HT_INFOF(msg,...)
const std::string & table_name() const
Gets name of table to compact.
void get_table_server_set(ContextPtr &context, const String &id, const String &row, StringSet &servers)
Gets set of servers holding ranges for a given table.
uint8_t encoding_version_state() const override
Returns version of encoding format of state.
Abstract base class for master operations.
DependencySet m_exclusivities
Set of exclusivities.
void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized encoding of object state.
const std::string name() override
Returns name of operation ("OperationCompact")
#define HT_MAYBE_FAIL(_label_)
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
void display_state(std::ostream &os) override
Writes human readable representation of object to output stream.
Error codes, Exception handling, error logging.
void complete_error(int error, const String &msg, std::vector< MetaLog::EntityPtr > &additional)
Completes operation with error.
std::shared_ptr< DispatchHandlerOperation > DispatchHandlerOperationPtr
Smart pointer to DispatchHandlerOperation.
int32_t range_types()
Gets range types to be compacted.
Executes user-defined functions when leaving the current scope.