46 #include <boost/algorithm/string.hpp>
61 m_params(name, schema), m_parts(parts) {
66 const uint8_t *ptr =
event->payload;
67 size_t remaining =
event->payload_len;
70 if (!boost::algorithm::starts_with(
m_params.
name(),
"/sys/"))
200 RangeSpec range, index_range, qualifier_index_range;
201 std::string range_name;
205 HT_INFOF(
"Entering CreateTable-%lld(%s, location=%s, parts=%s) state=%s",
224 schema->update_generation(generation);
225 m_schema = schema->render_xml(
true);
230 m_context->mml_writer->record_state(shared_from_this());
274 false, index_name, index_schema);
310 true, index_name, index_schema);
363 if (range_name.empty())
374 m_context->mml_writer->record_state(shared_from_this());
387 this_thread::sleep_for(chrono::milliseconds(5000));
393 m_context->mml_writer->record_state(shared_from_this());
405 if (range_name.empty())
408 HT_INFOF(
"Problem acknowledging load range %s: %s - %s (dest %s)",
411 this_thread::sleep_for(chrono::milliseconds(5000));
424 m_context->get_balance_plan_authority()->balance_move_complete(
m_table, range);
427 m_context->hyperspace->attr_set(tablefile,
"x",
"", 0);
430 m_context->get_balance_plan_authority(bpa_entity);
436 HT_FATALF(
"Unrecognized state %d", state);
439 HT_INFOF(
"Leaving CreateTable-%lld(%s, id=%s, generation=%u) state=%s",
496 return "OperationCreateTable";
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
size_t encoded_length_state() const override
Returns serialized state length.
void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized encoding of object state.
void prepare_index(ContextPtr &context, const String &name, const String &schema_str, bool qualifier, String &index_name, String &index_schema_str)
Prepares index schema and table name.
The FailureInducer simulates errors.
void display_state(std::ostream &os) override
Writes human readable representation of object to output stream.
Lib::Master::Request::Parameters::CreateTable m_params
Request parmaeters.
ContextPtr m_context
Pointer to Master context.
const string & name() const
Gets name of table to create.
std::string String
A String is simply a typedef to std::string.
std::shared_ptr< Entity > EntityPtr
Smart pointer to Entity.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Request parameters for create table operation.
bool validate_subops()
Handles the results of sub operations.
virtual size_t encoded_length() const
Returns serialized object length.
Declarations for TableIdentifier and TableIdentifierManaged.
Declarations for OperationCreateTable.
void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override
OperationCreateTable(ContextPtr &context, const String &name, const String &schema, TableParts parts)
Constructor.
void create_table_load_range(ContextPtr &context, const String &location, TableIdentifier &table, RangeSpec &range, bool needs_compaction)
Loads a table's initial range.
void create_table_acknowledge_range(ContextPtr &context, const String &location, TableIdentifier &table, RangeSpec &range)
Calls RangeServer::acknowledge_load for a range.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
const String label() override
Returns label for operation Returns string "CreateTable
" Label for operation.
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
TableParts m_parts
Which parts of table to create.
const char * get_text(int32_t state)
const string & schema() const
Gets table schema.
Represents a set of table parts (sub-tables).
String m_schema
Schema for the table
Declarations for ReferenceManager.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
void set_state(int32_t state)
const char * get_text(int error)
Returns a descriptive error message.
Compatibility Macros for C/C++.
void stage_subop(std::shared_ptr< Operation > operation)
Stages a sub operation for execution.
const String name() override
Returns name of operation Returns name of operation (OperationCreateTable)
Functions to serialize/deserialize primitives to/from a memory buffer.
void record_state()
Records operation state to the MML.
Time related declarations.
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.
String m_location
Proxy name of server to hold initial range
void encode_vstr(uint8_t **bufp, const void *buf, size_t len)
Encode a buffer as variable length string (vint64, data, null)
static Schema * new_instance(const std::string &buf)
Creates schema object from XML schema string.
TableIdentifierManaged m_table
Table identifier
#define HT_FATALF(msg,...)
long long int Lld
Shortcut for printf formats.
DependencySet m_obstructions
Set of obstructions.
uint8_t encoding_version_state() const override
Returns encoding version of serialization format.
Declarations for general-purpose utility functions.
void legacy_decode(const uint8_t **bufp, size_t *remainp, BalancePlan *plan)
void execute() override
Carries out the create table operation.
void create_table_in_hyperspace(ContextPtr &context, const String &name, const String &schema_str, TableIdentifierManaged *table)
Creates a table in Hyperspace.
DependencySet m_dependencies
Set of dependencies.
#define HT_INFOF(msg,...)
void create_table_write_metadata(ContextPtr &context, TableIdentifier *table)
Creates initial METADATA table entry for table.
bool value_index() const
Test if value index is included in set.
Abstract base class for master operations.
void encode_state(uint8_t **bufp) const override
Writes serialized encoding of object state.
This is a generic exception class for Hypertable.
const std::string to_string() const
Returns human readable string describing table parts.
DependencySet m_exclusivities
Set of exclusivities.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
TableParts get_index_parts(const std::string &schema)
Gets index parts specified in schema.
#define HT_MAYBE_FAIL(_label_)
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
Declarations for BalancePlanAuthority.
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.
static const char * END_ROW_MARKER
void complete_error(int error, const String &msg, std::vector< MetaLog::EntityPtr > &additional)
Completes operation with error.
int64_t get_ts64()
Returns the current time in nanoseconds as a 64bit number.
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.