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

Carries out an alter table operation. More...

#include <OperationAlterTable.h>

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

Public Member Functions

 OperationAlterTable (ContextPtr &context, const MetaLog::EntityHeader &header_)
 Constructor for constructing object from MetaLog entry. More...
 
 OperationAlterTable (ContextPtr &context, EventPtr &event)
 Constructor for constructing object from AsyncComm event Decodes m_params from message payload and then initializes the dependency graph state as follows: More...
 
virtual ~OperationAlterTable ()
 Destructor. More...
 
void execute () override
 Carries out the alter table operation. More...
 
const String name () override
 Returns name of operation ("OperationAlterTable") More...
 
const String label () override
 Returns descriptive 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. 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 Member Functions

bool get_schemas (SchemaPtr &original_schema, SchemaPtr &alter_schema)
 Gets schema objects. More...
 
TableParts get_drop_index_parts (SchemaPtr &original_schema, SchemaPtr &alter_schema)
 Determines which index tables to drop. More...
 
TableParts get_create_index_parts (SchemaPtr &original_schema, SchemaPtr &alter_schema)
 Determines which index tables to create. More...
 

Private Attributes

Lib::Master::Request::Parameters::AlterTable m_params
 Request parmaeters. More...
 
String m_schema
 Schema for the table More...
 
String m_id
 Table identifier More...
 
StringSet m_servers
 Set of participating range servers. More...
 
StringSet m_completed
 Set of range servers that have completed operation. More...
 
TableParts m_parts
 Index tables to be created or dropped. 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 an alter table operation.

Definition at line 42 of file OperationAlterTable.h.

Constructor & Destructor Documentation

OperationAlterTable::OperationAlterTable ( ContextPtr context,
const MetaLog::EntityHeader header_ 
)

Constructor for constructing object from MetaLog entry.

Parameters
contextMaster context
header_MetaLog header

Definition at line 57 of file OperationAlterTable.cc.

OperationAlterTable::OperationAlterTable ( ContextPtr context,
EventPtr event 
)

Constructor for constructing object from AsyncComm event Decodes m_params from message payload and then initializes the dependency graph state as follows:

  • dependencies - Dependency::INIT
  • exclusivities - Table pathname
    Parameters
    contextMaster context
    eventEvent received from AsyncComm from client request

Definition at line 62 of file OperationAlterTable.cc.

virtual Hypertable::OperationAlterTable::~OperationAlterTable ( )
inlinevirtual

Destructor.

Definition at line 62 of file OperationAlterTable.h.

Member Function Documentation

void OperationAlterTable::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. See encode() for a description of the serialized format.

Parameters
versionEncoding version
bufpAddress of source buffer pointer (advanced by call)
remainpAmount of remaining buffer pointed to by *bufp (decremented by call)

Implements Hypertable::Operation.

Definition at line 420 of file OperationAlterTable.cc.

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

Implements Hypertable::Operation.

Definition at line 433 of file OperationAlterTable.cc.

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

Writes human readable representation of object to output stream.

Parameters
osOutput stream

Implements Hypertable::Operation.

Definition at line 385 of file OperationAlterTable.cc.

void OperationAlterTable::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:

Encoding Description
vstr Pathname of table to compact
vstr New table schema
vstr Table identifier
i32 Size of m_completed
vstr Foreach server in m_completed, server name
i32 [VERSION 2] Size of m_servers
vstr [VERSION 2] Foreach server in m_servers, server name
TableParts [VERSION 3] Index tables to be created or dropped
Parameters
bufpAddress of destination buffer pointer (advanced by call)

Implements Hypertable::Operation.

Definition at line 407 of file OperationAlterTable.cc.

size_t OperationAlterTable::encoded_length_state ( ) const
overridevirtual

Returns serialized state length.

This method returns the length of the serialized representation of the object state. See encode() for a description of the serialized format.

Returns
Serialized length

Implements Hypertable::Operation.

Definition at line 393 of file OperationAlterTable.cc.

uint8_t OperationAlterTable::encoding_version_state ( ) const
overridevirtual

Returns encoding version.

Returns
Encoding version

Implements Hypertable::Operation.

Definition at line 389 of file OperationAlterTable.cc.

void OperationAlterTable::execute ( )
overridevirtual

Carries out the alter table operation.

This method carries out the operation via the following states:

State Description
INITIAL
  • Maps supplied table name to a table identifier (m_id)
  • If supplied table name not found in name map, completes with Error::TABLE_NOT_FOUND
  • If supplied table name is a directory, completes with Error::INVALID_ARGUMENT
  • Otherwise, transitions to VALIDATE_SCHEMA
VALIDATE_SCHEMA
CREATE_INDICES
  • If m_parts specifies either a value or qualifier index, creates an OperationCreateTable sub operation to create index tables and stages it with a call to stage_subop()
  • Transition state to SCAN_METADATA
  • Persists this operation to MML and then returns
SCAN_METADATA
  • Handles result of create table sub operation with a call to validate_subops(), returning on failure
  • Scans the METADATA table and populates m_servers to hold the set of servers that hold the table to be altered which are not in the m_completed set.
  • Dependencies are set to server names in m_servers
  • Transitions to the ISSUE_REQUESTS state
  • Persists operation to MML and returns
ISSUE_REQUESTS
  • Issues a alter table request to all servers in m_servers and waits for their completion
  • If there are any errors, for each server that was successful or returned with Error::TABLE_NOT_FOUND, the server name is added to m_completed. Dependencies are then set back to just Dependency::METADATA, the state is reset back to SCAN_METADATA, the operation is persisted to the MML, and the method returns
  • Otherwise state is transitioned to UPDATE_HYPERSPACE and operation is persisted to MML
UPDATE_HYPERSPACE
  • Sets m_parts to the index table that need to be dropped with a call to get_drop_index_parts()
  • Updates the schema attribute of table in hyperspace
  • If any of the index tables need to be dropped, transitions to state SUSPEND_TABLE_MAINTENANCE, records this operation to the MML, and then returns
  • Otherwise, transitions to COMPLETE and then returns
SUSPEND_TABLE_MAINTENANCE
  • Creates an OperationToggleMaintenance sub operation to turn maintenance off
  • Stages sub operation with a call to stage_subop()
  • Transition state to DROP_INDICES
  • Persists this operation to MML and then returns
DROP_INDICES
  • Handles result of toggle table maintenance sub operation with a call to validate_subops(), returning on failure
  • Creates an OperationDropTable sub operation to drop index tables
  • Stages sub operation with a call to stage_subop()
  • Transition state to RESUME_TABLE_MAINTENANCE
  • Persists this operation to MML and then returns
RESUME_TABLE_MAINTENANCE
  • Handles result of drop table sub operation with a call to validate_subops(), returning on failure
  • Creates an OperationToggleMaintenance sub operation to turn maintenance back on
  • Stages sub operation with a call to stage_subop()
  • Transition state to FINALIZE
  • Persists this operation to MML and then returns
FINALIZE
  • Handles result of the toggle maintenance sub operation with a call to fetch_and_validate_subop(), returning on failure
  • Calls complete_ok()

Implements Hypertable::Operation.

Definition at line 199 of file OperationAlterTable.cc.

TableParts OperationAlterTable::get_create_index_parts ( SchemaPtr original_schema,
SchemaPtr alter_schema 
)
private

Determines which index tables to create.

Determines if either the value or qualifier index table was not required in original_schema but is required in alter_schema. Each index type, for which this is the case, is marked in a TableParts object that is returned.

Parameters
original_schemaOriginal schema
alter_schemaNew altered schema
Returns
TableParts describing index tables to create

Definition at line 495 of file OperationAlterTable.cc.

TableParts OperationAlterTable::get_drop_index_parts ( SchemaPtr original_schema,
SchemaPtr alter_schema 
)
private

Determines which index tables to drop.

Determines if either the value or qualifier index table was required in original_schema but not in alter_schema. Each index type, for which this is the case, is marked in a TableParts object that is returned.

Parameters
original_schemaOriginal schema
alter_schemaNew altered schema
Returns
TableParts describing index tables to drop

Definition at line 483 of file OperationAlterTable.cc.

bool OperationAlterTable::get_schemas ( SchemaPtr original_schema,
SchemaPtr alter_schema 
)
private

Gets schema objects.

If either original_schema and alter_schema are are set to nullptr, this member function constructs and returns original schema object and alter schema object. The original schema is constructed from XML read from Hyperspace and the alter schema is constructed from m_schema. If any errors are encountered, the operation is terminated with a call to complete_error() and false is returned.

Parameters
original_schemaReference to original schema
alter_schemaReference to alter schema
Returns
true on success, false on error signaling operaton has been terminated.

Definition at line 465 of file OperationAlterTable.cc.

const String OperationAlterTable::label ( )
overridevirtual

Returns descriptive label for operation.

Returns
Descriptive label for operation

Implements Hypertable::Operation.

Definition at line 461 of file OperationAlterTable.cc.

const String OperationAlterTable::name ( )
overridevirtual

Returns name of operation ("OperationAlterTable")

Returns
Operation name

Implements Hypertable::Operation.

Definition at line 457 of file OperationAlterTable.cc.

Member Data Documentation

StringSet Hypertable::OperationAlterTable::m_completed
private

Set of range servers that have completed operation.

Definition at line 180 of file OperationAlterTable.h.

String Hypertable::OperationAlterTable::m_id
private

Table identifier

Definition at line 174 of file OperationAlterTable.h.

Lib::Master::Request::Parameters::AlterTable Hypertable::OperationAlterTable::m_params
private

Request parmaeters.

Definition at line 168 of file OperationAlterTable.h.

TableParts Hypertable::OperationAlterTable::m_parts
private

Index tables to be created or dropped.

Definition at line 183 of file OperationAlterTable.h.

String Hypertable::OperationAlterTable::m_schema
private

Schema for the table

Definition at line 171 of file OperationAlterTable.h.

StringSet Hypertable::OperationAlterTable::m_servers
private

Set of participating range servers.

Definition at line 177 of file OperationAlterTable.h.


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