43 #include <boost/algorithm/string.hpp>
54 const std::string &table_name,
57 m_name(table_name), m_toggle_on(toggle_on) {
128 HT_INFOF(
"Entering ToggleTableMaintenance-%lld (table=%s %s) state=%s",
146 m_context->mml_writer->record_state(shared_from_this());
158 m_context->hyperspace->attr_del(handle,
"maintenance_disabled");
161 m_context->hyperspace->attr_set(tablefile,
"maintenance_disabled",
"1", 1);
165 HT_ERRORF(
"Problem %s 'maintenance_disabled' attr for %s (%s, %s)",
172 HT_MAYBE_FAIL(
"toggle-table-maintenance-UPDATE_HYPERSPACE-1");
180 m_context->mml_writer->record_state(shared_from_this());
181 HT_MAYBE_FAIL(
"toggle-table-maintenance-UPDATE_HYPERSPACE-2");
186 std::set<std::string> servers;
192 m_context->get_available_servers(servers);
198 for (
auto &server : servers) {
209 m_context->mml_writer->record_state(shared_from_this());
221 if (!op_handler->wait_for_completion()) {
222 std::set<DispatchHandlerOperation::Result> results;
223 op_handler->get_results(results);
224 for (
auto &result : results) {
230 HT_WARNF(
"Error at %s - %s (%s)", result.location.c_str(),
242 this_thread::sleep_for(chrono::milliseconds(5000));
243 m_context->mml_writer->record_state(shared_from_this());
252 HT_FATALF(
"Unrecognized state %d", state);
255 HT_INFOF(
"Leaving ToggleTableMaintenance-%lld (table=%s %s) state=%s",
262 os <<
" table_name=" <<
m_name <<
" table_id=" <<
m_id
303 for (
size_t i=0; i<length; i++)
306 for (
size_t i=0; i<length; i++)
311 return "OperationToggleTableMaintenance";
315 return format(
"Toggle Table Maintenance (table=%s, %s)",
std::set< std::string > m_servers
Set of range servers participating in toggle.
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
void execute() override
Carries out a toggle maintenance operation.
Declarations for OperationToggleTableMaintenance.
#define HT_WARNF(msg,...)
The FailureInducer simulates errors.
ContextPtr m_context
Pointer to Master context.
std::string m_name
Table pathname
Declarations for Canonicalize.
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...
std::set< std::string > m_completed
Set of range servers that have completed toggle.
void encode_state(uint8_t **bufp) const override
Writes serialized encoding of object state.
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
#define HT_ON_SCOPE_EXIT(...)
const String name() override
Returns name of operation ("OperationToggleTableMaintenance")
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.
size_t encoded_length_state() const override
Returns serialized state length.
const String label() override
Returns descriptive label for operation.
void set_state(int32_t state)
bool decode_bool(const uint8_t **bufp, size_t *remainp)
Decodes a boolean value from the given buffer.
const char * get_text(int error)
Returns a descriptive error message.
void add_dependency(const String &dependency)
Declarations for DispatchHandlerOperationToggleTableMaintenance.
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
OperationToggleTableMaintenance(ContextPtr &context, const std::string &table_name, bool toggle_on)
Constructor.
void close_handle_ptr(SessionPtr hyperspace, uint64_t *handlep)
bool m_toggle_on
Flag indicating if maintenance is to be toggled on or off.
Compatibility Macros for C/C++.
Functions to serialize/deserialize primitives to/from a memory buffer.
void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override
void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized encoding of object state.
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.
Declarations for general-purpose utility functions.
void encode_bool(uint8_t **bufp, bool bval)
Encodes a boolean into the given buffer.
void display_state(std::ostream &os) override
Writes human readable representation of object to output stream.
DependencySet m_dependencies
Set of dependencies.
#define HT_INFOF(msg,...)
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.
Abstract base class for master operations.
This is a generic exception class for Hypertable.
uint8_t encoding_version_state() const override
Returns version of encoding format of state.
#define HT_ERRORF(msg,...)
#define HT_MAYBE_FAIL(_label_)
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
static void table_name(std::string &name)
Canonicalizes a table name.
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.
int code() const
Returns the error code.
Executes user-defined functions when leaving the current scope.