44 #include <boost/algorithm/string.hpp>
57 m_params(name, if_exists), m_parts(parts) {
67 const uint8_t *ptr =
event->payload;
68 size_t remaining =
event->payload_len;
161 String qualifier_index_id;
163 if (index_name ==
"/")
168 if (qualifier_index_name ==
"/")
177 HT_INFOF(
"Entering DropTable-%lld(%s, if_exists=%s, parts=%s) state=%s",
200 m_context->mml_writer->record_state(shared_from_this());
209 m_context->namemap->name_to_id(index_name, index_id)) {
210 HT_INFOF(
" Dropping index table %s (id %s)",
211 index_name.c_str(), index_id.c_str());
235 m_context->namemap->name_to_id(qualifier_index_name,
236 qualifier_index_id)) {
237 HT_INFOF(
" Dropping qualifier index table %s (id %s)",
238 qualifier_index_name.c_str(), qualifier_index_id.c_str());
262 for (StringSet::iterator iter=servers.begin(); iter!=servers.end(); ++iter) {
271 m_context->mml_writer->record_state(shared_from_this());
280 op_handler = make_shared<DispatchHandlerOperationDropTable>(
m_context, table);
282 if (!op_handler->wait_for_completion()) {
283 std::set<DispatchHandlerOperation::Result> results;
284 op_handler->get_results(results);
285 for (
const auto &result : results) {
292 HT_WARNF(
"Drop table error at %s - %s (%s)", result.location.c_str(),
302 m_context->mml_writer->record_state(shared_from_this());
305 m_context->monitoring->invalidate_id_mapping(
m_id);
318 m_context->hyperspace->unlink(filename.c_str());
330 HT_FATALF(
"Unrecognized state %d", state);
333 HT_INFOF(
"Leaving DropTable-%lld(%s) state=%s",
375 for (
size_t i=0; i<length; i++)
378 for (
size_t i=0; i<length; i++)
391 for (
size_t i=0; i<length; i++)
395 for (
size_t i=0; i<length; i++)
405 return "OperationDropTable";
std::set< String > StringSet
STL Set managing Strings.
#define HT_THROW2F(_code_, _ex_, _fmt_,...)
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
#define HT_WARNF(msg,...)
The FailureInducer simulates errors.
ContextPtr m_context
Pointer to Master context.
TableParts m_parts
Specification for which parts of table to drop.
std::string String
A String is simply a typedef to std::string.
Declarations for OperationDropTable.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
bool validate_subops()
Handles the results of sub operations.
virtual size_t encoded_length() const
Returns serialized object length.
OperationDropTable(ContextPtr &context, const String &name, bool if_exists, TableParts parts)
Constructor.
const String label() override
Returns descriptive label for operation.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
StringSet m_servers
Set of participating range servers.
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
const char * get_text(int32_t state)
bool if_exists()
Gets if exists flag.
StringSet m_completed
Range servers for which drop table operation has completed successfuly
Represents a set of table parts (sub-tables).
const string & name() const
Gets name of table to drop.
void encode_state(uint8_t **bufp) const override
Writes serialized encoding of object state.
void display_state(std::ostream &os) override
Writes human readable representation of object to output stream.
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
Declarations for ReferenceManager.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Request parameters for drop table operation.
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
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 encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
void stage_subop(std::shared_ptr< Operation > operation)
Stages a sub operation for execution.
Lib::Master::Request::Parameters::DropTable m_params
Request parmaeters.
void execute() override
Carries out the drop table operation.
Functions to serialize/deserialize primitives to/from a memory buffer.
void record_state()
Records operation state to the MML.
static String basename(String name, char separator= '/')
A posix-compliant basename() which strips directory names from a filename.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
bool primary() const
Test if primary table is included in set.
void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Decodes state from serialized object.
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.
DependencySet m_dependencies
Set of dependencies.
#define HT_INFOF(msg,...)
bool value_index() const
Test if value index is included in set.
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.
void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override
size_t encoded_length_state() const override
Returns serialized state length.
const String name() override
Returns name of operation ("OperationDropTable")
uint8_t encoding_version_state() const override
Returns version of encoding format of state.
const std::string to_string() const
Returns human readable string describing table parts.
static String dirname(String name, char separator= '/')
A posix-compliant dirname() which strips the last component from a file name.
DependencySet m_exclusivities
Set of exclusivities.
#define HT_MAYBE_FAIL(_label_)
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
uint8_t decode_byte(const uint8_t **bufp, size_t *remainp)
Decodes a single byte from the given buffer.
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.
String m_id
Table ID string
int code() const
Returns the error code.
Executes user-defined functions when leaving the current scope.
bool qualifier_index() const
Test if qualifier index is included in set.