0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
Hypertable::OperationCreateTable Class Reference

Carries out a create table operation. More...

#include <OperationCreateTable.h>

Inheritance diagram for Hypertable::OperationCreateTable:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::OperationCreateTable:
Collaboration graph
[legend]

Public Member Functions

 OperationCreateTable (ContextPtr &context, const String &name, const String &schema, TableParts parts)
 Constructor. More...
 
 OperationCreateTable (ContextPtr &context, const MetaLog::EntityHeader &header)
 Constructor with MML entity. More...
 
 OperationCreateTable (ContextPtr &context, EventPtr &event)
 Constructor with client request. More...
 
virtual ~OperationCreateTable ()
 Destructor. More...
 
void execute () override
 Carries out the create table operation. More...
 
const String name () override
 Returns name of operation Returns name of operation (OperationCreateTable) More...
 
const String label () override
 Returns label for operation Returns string "CreateTable <tablename>" Label for operation. More...
 
void display_state (std::ostream &os) override
 Writes human readable representation of object to output stream. More...
 
uint8_t encoding_version_state () const override
 Returns encoding version of serialization format. More...
 
size_t encoded_length_state () const override
 Returns serialized state length. More...
 
void encode_state (uint8_t **bufp) const override
 Writes serialized encoding of object state. More...
 
void decode_state (uint8_t version, const uint8_t **bufp, size_t *remainp) override
 Reads serialized encoding of object state. More...
 
void decode_state_old (uint8_t version, const uint8_t **bufp, size_t *remainp) override
 
- Public Member Functions inherited from Hypertable::Operation
 Operation (ContextPtr &context, int32_t type)
 Constructor with operation type specifier. More...
 
 Operation (ContextPtr &context, EventPtr &event, int32_t type)
 Constructor with request Event and operation type specifier. More...
 
 Operation (ContextPtr &context, const MetaLog::EntityHeader &header_)
 Constructor with MetaLog::EntityHeader. More...
 
virtual ~Operation ()
 Destructor. More...
 
virtual const String graphviz_label ()
 Human readable operation label used in graphviz output. More...
 
virtual bool exclusive ()
 Indicates if operation is exclusive. More...
 
virtual size_t encoded_result_length () const
 Length of encoded operation result. More...
 
virtual void encode_result (uint8_t **bufp) const
 Encode operation result. More...
 
virtual void decode_result (const uint8_t **bufp, size_t *remainp)
 Decode operation result. More...
 
void decode (const uint8_t **bufp, size_t *remainp, uint16_t definition_version) override
 Decode operation. More...
 
void display (std::ostream &os) override
 Write human readable string represenation of operation to output stream. More...
 
int64_t id ()
 Operation identifier. More...
 
ClockT::time_point expiration_time ()
 Returns operation expiration time. More...
 
void set_remove_approval_mask (uint16_t mask)
 Sets the remove approvals bit mask. More...
 
uint16_t get_remove_approval_mask ()
 Gets the remove approvals bit mask. More...
 
bool remove_approval_add (uint16_t approval)
 Sets remove approval bits. More...
 
bool removal_approved ()
 Checks if all remove approvals have been received. More...
 
void record_state (std::vector< MetaLog::EntityPtr > &additional)
 Records operation state and additional entities to the MML. More...
 
void record_state ()
 Records operation state to the MML. More...
 
void complete_error (int error, const String &msg, std::vector< MetaLog::EntityPtr > &additional)
 Completes operation with error. More...
 
void complete_error (int error, const String &msg, MetaLog::EntityPtr additional=MetaLog::EntityPtr())
 Completes operation with error. More...
 
void complete_error (Exception &e, std::vector< MetaLog::EntityPtr > &additional)
 Completes operation with exception. More...
 
void complete_error (Exception &e, MetaLog::EntityPtr additional=MetaLog::EntityPtr())
 Completes operation with exception. More...
 
void complete_ok (std::vector< MetaLog::EntityPtr > &additional)
 
void complete_ok (MetaLog::EntityPtr additional=MetaLog::EntityPtr())
 
virtual int64_t hash_code () const
 
virtual void exclusivities (DependencySet &exclusivities)
 
virtual void dependencies (DependencySet &dependencies)
 
virtual void obstructions (DependencySet &obstructions)
 
void add_exclusivity (const String &exclusivity)
 
void add_dependency (const String &dependency)
 
void add_obstruction (const String &obstruction)
 
void add_obstruction_permanent (const String &obstruction)
 
void fetch_sub_operations (std::vector< std::shared_ptr< Operation > > &sub_ops)
 
void pre_run ()
 
void post_run ()
 
int32_t get_state ()
 
void set_state (int32_t state)
 
virtual bool is_perpetual ()
 
bool block ()
 
bool unblock ()
 
bool is_blocked ()
 
bool is_complete ()
 
int32_t get_original_type ()
 
void set_original_type (int32_t original_type)
 
void set_ephemeral ()
 Sets the ephemeral flag to true. More...
 
bool ephemeral ()
 Gets the ephemeral flag. More...
 
int32_t get_error ()
 Get error code. More...
 
String get_error_msg ()
 Get error message. More...
 
- Public Member Functions inherited from Hypertable::MetaLog::Entity
 Entity (int32_t type)
 Constructor from entity type. More...
 
 Entity (const EntityHeader &header_)
 Constructor from entity header. More...
 
virtual ~Entity ()
 Destructor. More...
 
void lock ()
 Locks the entity's mutex. More...
 
void unlock ()
 Unlocks the entity's mutex. More...
 
void mark_for_removal ()
 Marks entity for removal. More...
 
bool marked_for_removal ()
 Checks if entity is marked for removal. More...
 
int64_t id () const
 Returns the entity ID. More...
 
- Public Member Functions inherited from Hypertable::Serializable
virtual size_t encoded_length () const
 Returns serialized object length. More...
 
virtual void encode (uint8_t **bufp) const
 Writes serialized representation of object to a buffer. More...
 
virtual void decode (const uint8_t **bufp, size_t *remainp)
 Reads serialized representation of object from a buffer. More...
 

Private Attributes

Lib::Master::Request::Parameters::CreateTable m_params
 Request parmaeters. More...
 
TableIdentifierManaged m_table
 Table identifier More...
 
String m_schema
 Schema for the table More...
 
String m_location
 Proxy name of server to hold initial range More...
 
TableParts m_parts {TableParts::ALL}
 Which parts of table to create. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Hypertable::Operation
uint8_t encoding_version () const override
 Returns encoding version. More...
 
size_t encoded_length_internal () const override
 Returns internal serialized length. More...
 
void encode_internal (uint8_t **bufp) const override
 Writes serialized representation of object to a buffer. More...
 
void decode_internal (uint8_t version, const uint8_t **bufp, size_t *remainp) override
 Reads serialized representation of object from a buffer. More...
 
void decode_old (const uint8_t **bufp, size_t *remainp, uint16_t definition_version)
 
bool validate_subops ()
 Handles the results of sub operations. More...
 
void stage_subop (std::shared_ptr< Operation > operation)
 Stages a sub operation for execution. More...
 
- Protected Member Functions inherited from Hypertable::MetaLog::Entity
void encode_entry (uint8_t **bufp)
 Encodes entity header plus serialized state. More...
 
- Protected Attributes inherited from Hypertable::Operation
ContextPtr m_context
 Pointer to Master context. More...
 
EventPtr m_event
 Pointer to client event (if any) that originated the operation. More...
 
uint16_t m_remove_approvals {}
 Remove approvals received. More...
 
uint16_t m_remove_approval_mask {}
 Remove approval mask. More...
 
int32_t m_original_type {}
 Original entity type read from MML (prior to conversion) More...
 
int32_t m_error {}
 Result error code. More...
 
String m_error_msg
 Result error message. More...
 
bool m_unblock_on_exit {}
 Flag to signal operation to be unblocked on exit (post_run()) More...
 
bool m_blocked {}
 Flag indicating if operation is blocked. More...
 
bool m_ephemeral {}
 Indicates if operation is ephemeral and does not get persisted to MML. More...
 
ClockT::time_point m_expiration_time
 Expiration time (used by ResponseManager) More...
 
int64_t m_hash_code
 Hash code uniqely identifying operation. More...
 
DependencySet m_exclusivities
 Set of exclusivities. More...
 
DependencySet m_dependencies
 Set of dependencies. More...
 
DependencySet m_obstructions
 Set of obstructions. More...
 
DependencySet m_obstructions_permanent
 Set of permanent obstructions. More...
 
std::vector< int64_t > m_sub_ops
 Vector of sub operations IDs. More...
 
- Protected Attributes inherited from Hypertable::MetaLog::Entity
std::mutex m_mutex
 Mutex for serializing access to members More...
 
EntityHeader header
 Entity header More...
 

Detailed Description

Carries out a create table operation.

This class is responsible for creating a new table, which involves, creating the table in Hyperspace, loading the initial range for the table, and optionally creating the associated value and qualifier index tables if required.

Definition at line 45 of file OperationCreateTable.h.

Constructor & Destructor Documentation

OperationCreateTable::OperationCreateTable ( ContextPtr context,
const String name,
const String schema,
TableParts  parts 
)

Constructor.

Initializes m_params with name and schema, and initializes m_parts with parts.

Parameters
contextMaster context
nameFull pathname of table to create
schemaTable schema
partsWhich parts of the table to create

Definition at line 56 of file OperationCreateTable.cc.

Hypertable::OperationCreateTable::OperationCreateTable ( ContextPtr context,
const MetaLog::EntityHeader header 
)
inline

Constructor with MML entity.

Parameters
contextMaster context
headerMetaLog header

Definition at line 61 of file OperationCreateTable.h.

OperationCreateTable::OperationCreateTable ( ContextPtr context,
EventPtr event 
)

Constructor with client request.

Initializes base class constructor, and then initializes the member variables as follows:

  • Decodes request parameters
  • Table name is added as an exclusivity
  • Adds METADATA and SYSTEM as dependencies
  • If table is a system table, INIT is added as a dependency
    Parameters
    contextMaster context
    eventEvent received from AsyncComm from client request

Definition at line 64 of file OperationCreateTable.cc.

virtual Hypertable::OperationCreateTable::~OperationCreateTable ( )
inlinevirtual

Destructor.

Definition at line 77 of file OperationCreateTable.h.

Member Function Documentation

void OperationCreateTable::decode_state ( uint8_t  version,
const uint8_t **  bufp,
size_t *  remainp 
)
overridevirtual

Reads serialized encoding of object state.

This method restores the state of the object by decoding a serialized representation of the state from the memory location pointed to by *bufp.

Parameters
versionEncoding version
bufpAddress of source buffer pointer (advanced by call)
remainpAmount of remaining buffer pointed to by *bufp (decremented by call)
See also
encode() for a description of the serialized format.

Implements Hypertable::Operation.

Definition at line 473 of file OperationCreateTable.cc.

void OperationCreateTable::decode_state_old ( uint8_t  version,
const uint8_t **  bufp,
size_t *  remainp 
)
overridevirtual

Implements Hypertable::Operation.

Definition at line 481 of file OperationCreateTable.cc.

void OperationCreateTable::display_state ( std::ostream &  os)
overridevirtual

Writes human readable representation of object to output stream.

Parameters
osOutput stream

Implements Hypertable::Operation.

Definition at line 447 of file OperationCreateTable.cc.

void OperationCreateTable::encode_state ( uint8_t **  bufp) const
overridevirtual

Writes serialized encoding of object state.

This method writes a serialized encoding of object state to the memory location pointed to by *bufp. The encoding has the following format:

EncodingDescription
vstrTable name
vstrTable schema (m_schema)
TableIdentifierTable identifier (m_table)
vstrProxy name of server to hold initial range (m_location)
TableParts[VERSION 2] Table parts to create (m_parts)
Parameters
bufpAddress of destination buffer pointer (advanced by call)

Implements Hypertable::Operation.

Definition at line 465 of file OperationCreateTable.cc.

size_t OperationCreateTable::encoded_length_state ( ) const
overridevirtual

Returns serialized state length.

This method returns the length of the serialized representation of the object state.

Returns
Serialized length
See also
encode() for a description of the serialized format.

Implements Hypertable::Operation.

Definition at line 458 of file OperationCreateTable.cc.

uint8_t OperationCreateTable::encoding_version_state ( ) const
overridevirtual

Returns encoding version of serialization format.

Returns
Encoding version of serialization format.

Implements Hypertable::Operation.

Definition at line 454 of file OperationCreateTable.cc.

void OperationCreateTable::execute ( )
overridevirtual

Carries out the create table operation.

This method carries out the operation via the states described below.

If m_parts indicates that the primary table is not being created and the entry state is INITIAL, the state is set to CREATE_INDEX.

State Description
INITIAL
  • Verifies that a table with the same name does not already exist in Hyperspace and completes with error Error::NAME_ALREADY_IN_USE if it does.
  • Obtains current timestamp and uses it as the schema generation number.
  • Transitions to state ASSIGN_ID
  • Persists operation to MML and returns
ASSIGN_ID
  • Creates table in Hyperspace
  • Updates m_parts to reflect indices that actually exist in the schema
  • Transitions to the CREATE_INDEX
CREATE_INDEX
CREATE_QUALIFIER_INDEX
  • Handles result of value index sub operation with a call to validate_subops(), returning if it failed
  • If qualifier index not specified in m_parts, state is transitioned to WRITE_METADATA, the operation is persisted to the MML, and drops through to the next state.
    ... otherwise ...
  • Prepares the qualifier index with call to Utility::prepare_index()
  • Creates OperationCreateTable sub operation for qualifier index table
  • Stages sub operation with call to stage_subop()
  • Transitions to state WRITE_METADATA
  • Persists operation with a call to record_state() and returns
WRITE_METADATA
  • Handles result of qualifier index sub operation with a call to validate_subops(), returning on failure
  • If primary table is not specified in m_parts, complete_ok() is called and the function returns
  • Utility::create_table_write_metadata() is called
  • The operation's dependencies are set to SERVERS, METADATA, and SYSTEM and an obstruction ("OperationMove " + range) is added.
  • Transitions to state ASSIGN_LOCATION
  • Persists operation with a call to record_state() and returns
ASSIGN_LOCATION
LOAD_RANGE
  • Initial range is loaded with a call to Utility::create_table_load_range()
  • If an Exception is thrown during the loading of the range, it is caught, the operation sleeps for 5 seconds, the state is transitioned to ASSIGN_LOCATION, and the function returns
  • Otherwise, on success the state is transitioned to ACKNOWLEDGE
  • Operation is persisted to MML and function returns
ACKNOWLEDGE
FINALIZE

Implements Hypertable::Operation.

Definition at line 199 of file OperationCreateTable.cc.

const String OperationCreateTable::label ( )
overridevirtual

Returns label for operation Returns string "CreateTable <tablename>" Label for operation.

Implements Hypertable::Operation.

Definition at line 499 of file OperationCreateTable.cc.

const String OperationCreateTable::name ( )
overridevirtual

Returns name of operation Returns name of operation (OperationCreateTable)

Returns
Name of operation

Implements Hypertable::Operation.

Definition at line 495 of file OperationCreateTable.cc.

Member Data Documentation

String Hypertable::OperationCreateTable::m_location
private

Proxy name of server to hold initial range

Definition at line 163 of file OperationCreateTable.h.

Lib::Master::Request::Parameters::CreateTable Hypertable::OperationCreateTable::m_params
private

Request parmaeters.

Definition at line 154 of file OperationCreateTable.h.

TableParts Hypertable::OperationCreateTable::m_parts {TableParts::ALL}
private

Which parts of table to create.

Definition at line 166 of file OperationCreateTable.h.

String Hypertable::OperationCreateTable::m_schema
private

Schema for the table

Definition at line 160 of file OperationCreateTable.h.

TableIdentifierManaged Hypertable::OperationCreateTable::m_table
private

Table identifier

Definition at line 157 of file OperationCreateTable.h.


The documentation for this class was generated from the following files: