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

Abstract base class for master operations. More...

#include <Operation.h>

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

Public Member Functions

 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 void execute ()=0
 Executes (carries out) the operation. More...
 
const String name () override=0
 Name of operation used for exclusivity. More...
 
virtual const String label ()=0
 Human readable label for operation. 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...
 
virtual uint8_t encoding_version_state () const =0
 Returns version of encoding format of state. More...
 
virtual size_t encoded_length_state () const =0
 Encoded length of operation state. More...
 
virtual void encode_state (uint8_t **bufp) const =0
 Encode operation state. More...
 
virtual void decode_state (uint8_t version, const uint8_t **bufp, size_t *remainp)=0
 Decode operation state. More...
 
virtual void decode_state_old (uint8_t version, const uint8_t **bufp, size_t *remainp)=0
 
virtual void display_state (std::ostream &os)=0
 Write human readable operation state to output stream. 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...
 

Protected Member Functions

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

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

Abstract base class for master operations.

The master is implemented as a dependency graph of operations that are executed by the OperationProcessor. Each operation is implemented as a state machine and has a dependency relationship with other operations. This class is the base class for all operations and defines a common interface. The execute() method is called by the OperationProcessor to run the operation's state machine and the dependency relationship is defined by sets of dependency strings returned by the following methods:

See OperationProcessor for details on how the operation dependency graph is setup and how operations are carried out.

Definition at line 124 of file Operation.h.

Constructor & Destructor Documentation

Operation::Operation ( ContextPtr context,
int32_t  type 
)

Constructor with operation type specifier.

Initializes state to OperationState::INITIAL, initializes m_expiration_time to number of milliseconds in the future as specified by the Hypertable.Request.Timeout property, and initializes m_hash_code to the id field of MetaLog::Entity::header.

Parameters
contextMaster context
typeOperation type

Definition at line 61 of file Operation.cc.

Operation::Operation ( ContextPtr context,
EventPtr event,
int32_t  type 
)

Constructor with request Event and operation type specifier.

Constructs an operation from a client request read off the wire. Derived class constructor should call decode_request() to decode request parameters from event. Initializes m_expiration_time to number of milliseconds in the future as specified by the Hypertable.Request.Timeout property and initializes m_hash_code to the id field of MetaLog::Entity::header.

Parameters
contextMaster context
eventEvent object
typeOperation type

Definition at line 68 of file Operation.cc.

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

Constructor with MetaLog::EntityHeader.

Constructs an operation from header_ read from a MetaLog. After object has been constructed, the MetaLogReader class will read the rest of the MetaLog entry and will reconstruct the object state with a call to decode(). This constructor initializes m_hash_code to the id field of MetaLog::Entity::header.

Note
Object initialization wont be complete until after the call to decode(), so any post-initialization setup should be performed at the end of the decode() method.
Parameters
contextMaster context
header_MetaLog header

Definition at line 74 of file Operation.cc.

virtual Hypertable::Operation::~Operation ( )
inlinevirtual

Destructor.

Definition at line 165 of file Operation.h.

Member Function Documentation

void Hypertable::Operation::add_dependency ( const String dependency)
inline

Definition at line 462 of file Operation.h.

void Hypertable::Operation::add_exclusivity ( const String exclusivity)
inline

Definition at line 461 of file Operation.h.

void Hypertable::Operation::add_obstruction ( const String obstruction)
inline

Definition at line 463 of file Operation.h.

void Hypertable::Operation::add_obstruction_permanent ( const String obstruction)
inline

Definition at line 464 of file Operation.h.

bool Operation::block ( )

Definition at line 495 of file Operation.cc.

void Operation::complete_error ( int  error,
const String msg,
std::vector< MetaLog::EntityPtr > &  additional 
)

Completes operation with error.

This member function does the following:

  • Sets state to OperationState::COMPLETE
  • Sets m_error to error
  • Sets m_error_msg to msg
  • Clears dependency, obstruction, and exclusivity sets
  • Each sub operation has all of its remove approvals set.
  • Persists state along with additional with a call to record_state()
    Parameters
    errorError code of operation result
    msgError message of operation result
    additionalVector of additional entities to persist to MML

Definition at line 400 of file Operation.cc.

void Operation::complete_error ( int  error,
const String msg,
MetaLog::EntityPtr  additional = MetaLog::EntityPtr() 
)

Completes operation with error.

This member function wraps additional into a vector and chains the call to complete_error

Parameters
errorError code of operation result
msgError message of operation result
additionalAdditional entity to persist to MML

Definition at line 428 of file Operation.cc.

void Hypertable::Operation::complete_error ( Exception e,
std::vector< MetaLog::EntityPtr > &  additional 
)
inline

Completes operation with exception.

This method chains the call to complete_error with e.code() and e.what() as the error code and message, respectively.

Parameters
eException precipitating the operation completion
additionalVector of additional entities to persist to MML

Definition at line 437 of file Operation.h.

void Hypertable::Operation::complete_error ( Exception e,
MetaLog::EntityPtr  additional = MetaLog::EntityPtr() 
)
inline

Completes operation with exception.

This method chains the call to complete_error with e.code() and e.what() as the error code and message, respectively.

Parameters
eException precipitating the operation completion
additionalVector of additional entity to persist to MML

Definition at line 448 of file Operation.h.

void Operation::complete_ok ( std::vector< MetaLog::EntityPtr > &  additional)

Definition at line 436 of file Operation.cc.

void Operation::complete_ok ( MetaLog::EntityPtr  additional = MetaLog::EntityPtr())

Definition at line 452 of file Operation.cc.

void Operation::decode ( const uint8_t **  bufp,
size_t *  remainp,
uint16_t  definition_version 
)
overridevirtual

Decode operation.

Decodes operation. See encode() for description of encoding format. Upon successful decode, this method will modify *bufp to point to the first byte past the encoded result and will decrement *remainp by the length of the encoded result.

Parameters
bufpAddress of source buffer pointer (advanced by call)
remainpAmount of remaining buffer pointed to by *bufp (decremented by call).
definition_versionVersion of DefinitionMaster

Reimplemented from Hypertable::MetaLog::Entity.

Definition at line 275 of file Operation.cc.

void Operation::decode_internal ( uint8_t  version,
const uint8_t **  bufp,
size_t *  remainp 
)
overrideprotectedvirtual

Reads serialized representation of object from a buffer.

This function is to be overridden by derived classes and should decode the object per-se as encoded with encode_internal().

Parameters
versionEncoding version
bufpAddress of destination buffer pointer (advanced by call)
remainpAddress of integer holding amount of serialized encoding remaining
See also
encode_internal() for encoding format

Implements Hypertable::Serializable.

Definition at line 205 of file Operation.cc.

void Operation::decode_old ( const uint8_t **  bufp,
size_t *  remainp,
uint16_t  definition_version 
)
protected

Definition at line 283 of file Operation.cc.

void Operation::decode_result ( const uint8_t **  bufp,
size_t *  remainp 
)
virtual

Decode operation result.

This method is called by decode() to handle decoding of the operation result.

Parameters
bufpAddress of pointer to encoded result
remainpAddress of integer holding amount of remaining buffer
See also
encode_result() for encoding format.

Reimplemented in Hypertable::OperationMoveRange, and Hypertable::OperationInitialize.

Definition at line 356 of file Operation.cc.

virtual void Hypertable::Operation::decode_state ( uint8_t  version,
const uint8_t **  bufp,
size_t *  remainp 
)
pure virtual

Decode operation state.

This method is called by decode() to decode state that is specific to the operation. The encoded state should start at the memory location pointed to by *bufp, and if successfully decoded, will be modified to point to the first byte past the encoded state. The remainp parameter is a pointer to an integer holding the number of valid/readable bytes pointed to by *bufp and if decoding is sucessful, will be decremented by the length of the encoded state.

Parameters
versionEncoding version
bufpAddress of pointer to destination buffer
remainpAddress of integer holding amount of remaining buffer

Implemented in Hypertable::OperationDropTable, Hypertable::OperationCreateTable, Hypertable::OperationCompact, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationRecreateIndexTables, Hypertable::OperationAlterTable, Hypertable::OperationSetState, Hypertable::OperationEphemeral, Hypertable::OperationRecover, Hypertable::OperationMoveRange, Hypertable::OperationRecoverRanges, Hypertable::OperationBalance, Hypertable::OperationRenameTable, Hypertable::OperationCreateNamespace, Hypertable::OperationDropNamespace, and Hypertable::OperationInitialize.

virtual void Hypertable::Operation::decode_state_old ( uint8_t  version,
const uint8_t **  bufp,
size_t *  remainp 
)
pure virtual
void Operation::dependencies ( DependencySet dependencies)
virtual

Definition at line 464 of file Operation.cc.

void Operation::display ( std::ostream &  os)
overridevirtual

Write human readable string represenation of operation to output stream.

Parameters
osOutput stream to which string is written

Reimplemented from Hypertable::MetaLog::Entity.

Definition at line 79 of file Operation.cc.

virtual void Hypertable::Operation::display_state ( std::ostream &  os)
pure virtual
void Operation::encode_internal ( uint8_t **  bufp) const
overrideprotectedvirtual

Writes serialized representation of object to a buffer.

This function is to be overridden by derived classes and should encode the object per-se.

Parameters
bufpAddress of destination buffer pointer (advanced by call)

Implements Hypertable::Serializable.

Definition at line 172 of file Operation.cc.

void Operation::encode_result ( uint8_t **  bufp) const
virtual

Encode operation result.

This method is called by encode() to encode the result of the operation when it is in the OperationState::COMPLETE state. The result is encoded in the following format:

EncodingDescription
i32Error code
vstrError message (if error code != Error::OK)
Parameters
bufpAddress of pointer to destination buffer

Reimplemented in Hypertable::OperationSystemStatus, and Hypertable::OperationStatus.

Definition at line 350 of file Operation.cc.

virtual void Hypertable::Operation::encode_state ( uint8_t **  bufp) const
pure virtual

Encode operation state.

This method is called by encode() to encode state that is specific to the operation. The encoded state is written to the memory location pointed to by *bufp, which is modified to point to the first byte after the encoded state.

Parameters
bufpAddress of pointer to destination buffer (modified by call)

Implemented in Hypertable::OperationDropTable, Hypertable::OperationCreateTable, Hypertable::OperationCompact, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationRecreateIndexTables, Hypertable::OperationSetState, Hypertable::OperationAlterTable, Hypertable::OperationEphemeral, Hypertable::OperationRecover, Hypertable::OperationMoveRange, Hypertable::OperationRecoverRanges, Hypertable::OperationBalance, Hypertable::OperationRenameTable, Hypertable::OperationCreateNamespace, Hypertable::OperationDropNamespace, and Hypertable::OperationInitialize.

size_t Operation::encoded_length_internal ( ) const
overrideprotectedvirtual

Returns internal serialized length.

This function is to be overridden by derived classes and should return the length of the the serialized object per-se.

Returns
Internal serialized length
See also
encode_internal() for encoding format

Implements Hypertable::Serializable.

Definition at line 143 of file Operation.cc.

virtual size_t Hypertable::Operation::encoded_length_state ( ) const
pure virtual
size_t Operation::encoded_result_length ( ) const
virtual

Length of encoded operation result.

This method returns the length of the encoded result

Returns
length of encoded result
See also
encode_result() for encoding format.

Reimplemented in Hypertable::OperationSystemStatus, and Hypertable::OperationStatus.

Definition at line 344 of file Operation.cc.

uint8_t Operation::encoding_version ( ) const
overrideprotectedvirtual

Returns encoding version.

Returns
Encoding version

Implements Hypertable::Serializable.

Definition at line 139 of file Operation.cc.

virtual uint8_t Hypertable::Operation::encoding_version_state ( ) const
pure virtual
bool Hypertable::Operation::ephemeral ( )
inline

Gets the ephemeral flag.

Definition at line 490 of file Operation.h.

virtual bool Hypertable::Operation::exclusive ( )
inlinevirtual

Indicates if operation is exclusive.

An operation can be designated as exclusive which means that only one operation of this type may be added to the OperationProcessor at any given time. This method is used in conjunction with the name() method to determine if the operation can be added to the OperationProcessor. If this method returns true and another exclusive operation exists in the OperationProcessor with the same name as returned by name(), then the attempt to add the operation will throw an Exception with error code Error::MASTER_OPERATION_IN_PROGRESS.

Returns
true if operation is exclusive, false otherwise.

Reimplemented in Hypertable::OperationRecover, Hypertable::OperationGatherStatistics, Hypertable::OperationBalance, and Hypertable::OperationCollectGarbage.

Definition at line 222 of file Operation.h.

void Operation::exclusivities ( DependencySet exclusivities)
virtual

Definition at line 459 of file Operation.cc.

virtual void Hypertable::Operation::execute ( )
pure virtual

Executes (carries out) the operation.

This method is called by the OperationProcessor to carry out the operation. After calling this method, the OperationProcessor will check the state of the operation with a call to get_state(). If the state is OperationState::COMPLETE, then it assumes that the operation is complete and will destory it. Otherwise, it will remain in the operation dependency graph and will get re-executed at a later time. After the call to this method, the OperationProcessor will re-compute the operation dependency graph (which may have changed due to the removal of this operation or if there were modifications to m_exclusivities, m_dependencies, or m_obstructions) and will continue operation execution in the approprate order.

Implemented in Hypertable::OperationRegisterServerBlocker, Hypertable::OperationCreateTable, Hypertable::OperationSetState, Hypertable::OperationDropTable, Hypertable::OperationRecreateIndexTables, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationRecover, Hypertable::OperationCompact, Hypertable::OperationAlterTable, Hypertable::OperationGatherStatistics, Hypertable::OperationRecoverRanges, Hypertable::OperationMoveRange, Hypertable::OperationSystemStatus, Hypertable::OperationBalance, Hypertable::OperationRelinquishAcknowledge, Hypertable::OperationRenameTable, Hypertable::OperationStatus, Hypertable::OperationCreateNamespace, Hypertable::OperationDropNamespace, Hypertable::OperationRegisterServer, Hypertable::OperationSystemUpgrade, Hypertable::OperationStop, Hypertable::OperationTimedBarrier, Hypertable::OperationInitialize, Hypertable::OperationCollectGarbage, Hypertable::OperationRecoveryBlocker, and Hypertable::OperationWaitForServers.

ClockT::time_point Hypertable::Operation::expiration_time ( )
inline

Returns operation expiration time.

Operations have an expiration time held in the m_expiration_time member. It is initialized to either the value of the property Hypertable.Request.Timeout or the timeout value of the client request that caused the operation to be created. Currently it is only used by the ResponseManager class. When a completed operation is added to the ResponseManager, it will be held there until either a FETCH_RESULT command for the operation has be received from the client, or the expiration time has been reached, after which the operation will be permanently removed.

Returns
Expiration time of the operation

Definition at line 340 of file Operation.h.

void Operation::fetch_sub_operations ( std::vector< std::shared_ptr< Operation > > &  sub_ops)

Definition at line 475 of file Operation.cc.

int32_t Hypertable::Operation::get_error ( )
inline

Get error code.

Returns
Error code

Definition at line 497 of file Operation.h.

String Hypertable::Operation::get_error_msg ( )
inline

Get error message.

Returns
Error message

Definition at line 505 of file Operation.h.

int32_t Hypertable::Operation::get_original_type ( )
inline

Definition at line 480 of file Operation.h.

uint16_t Hypertable::Operation::get_remove_approval_mask ( )
inline

Gets the remove approvals bit mask.

Returns
The remove approvals bit mask
See also
remove_approval_add, set_remove_approval_mask

Definition at line 353 of file Operation.h.

int32_t Hypertable::Operation::get_state ( )
inline

Definition at line 472 of file Operation.h.

virtual const String Hypertable::Operation::graphviz_label ( )
inlinevirtual

Human readable operation label used in graphviz output.

The OperationProcessor periodically generates graphviz output describing the operation dependency graph. This method is simlar to label(), but can be modified to produce a string that renders better in the dependency graph visualization. It is typically the same as what's produce by label(), but may contain newlines or elided strings to reduce the width of the label.

Returns
Human readable operation label for use with graphviz.

Reimplemented in Hypertable::OperationMoveRange, and Hypertable::OperationRelinquishAcknowledge.

Definition at line 209 of file Operation.h.

virtual int64_t Hypertable::Operation::hash_code ( ) const
inlinevirtual

Definition at line 455 of file Operation.h.

int64_t Hypertable::Operation::id ( )
inline

Operation identifier.

Returns an integer identifier that uniquely identifies this operation. The ID that is returned is the same as the id field of the Metalog::Entity::header member of the base class.

Returns
operation identifier.

Definition at line 326 of file Operation.h.

bool Hypertable::Operation::is_blocked ( )
inline

Definition at line 477 of file Operation.h.

bool Hypertable::Operation::is_complete ( )
inline

Definition at line 478 of file Operation.h.

virtual bool Hypertable::Operation::is_perpetual ( )
inlinevirtual
virtual const String Hypertable::Operation::label ( )
pure virtual
const String Hypertable::Operation::name ( )
overridepure virtual

Name of operation used for exclusivity.

An operation can be marked exclusive (see exclusvive()) which tells the Operation processor that only one operation of this name may be added to the dependency graph. If an attempt to add an an exclusive operation is made and the OperationProcessor already contains an exclusive operation with the same name, the attempt will fail and will result in an Exception with error code Error::MASTER_OPERATION_IN_PROGRESS.

Returns
Name of operation used to enforce exclusivity constraint

Implements Hypertable::MetaLog::Entity.

Implemented in Hypertable::OperationRegisterServerBlocker, Hypertable::OperationCreateTable, Hypertable::OperationSetState, Hypertable::OperationDropTable, Hypertable::OperationRecreateIndexTables, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationCompact, Hypertable::OperationRecover, Hypertable::OperationAlterTable, Hypertable::OperationGatherStatistics, Hypertable::OperationRecoverRanges, Hypertable::OperationMoveRange, Hypertable::OperationSystemStatus, Hypertable::OperationBalance, Hypertable::OperationRelinquishAcknowledge, Hypertable::OperationRenameTable, Hypertable::OperationStatus, Hypertable::OperationCreateNamespace, Hypertable::OperationDropNamespace, Hypertable::OperationRegisterServer, Hypertable::OperationSystemUpgrade, Hypertable::OperationStop, Hypertable::OperationTimedBarrier, Hypertable::OperationInitialize, Hypertable::OperationCollectGarbage, Hypertable::OperationRecoveryBlocker, and Hypertable::OperationWaitForServers.

void Operation::obstructions ( DependencySet obstructions)
virtual

Definition at line 469 of file Operation.cc.

void Operation::post_run ( )

Definition at line 488 of file Operation.cc.

void Operation::pre_run ( )

Definition at line 482 of file Operation.cc.

void Operation::record_state ( std::vector< MetaLog::EntityPtr > &  additional)

Records operation state and additional entities to the MML.

This member function builds up a vector of entities to record in the MML by adding the following:

  • This operation.
  • The additional entities.
  • This operation's sub operations.

For each entity to be recorded in the MML, if the entity is an operation and removal_approved() returns true, then the operation is marked for removal with a call to mark_for_removal(). The vector of entities is recorded to the MML. Then, the operations that were marked for removal are removed from the reference manager. Finally, the m_sub_ops array is modified to hold the sub operation IDs that were not removed by this function.

Parameters
additionalAdditional entities to be recorded in MML

Definition at line 367 of file Operation.cc.

void Hypertable::Operation::record_state ( )
inline

Records operation state to the MML.

This member function creates an empty entity vector and passes it into a chained call to record_state().

Definition at line 401 of file Operation.h.

bool Operation::removal_approved ( )

Checks if all remove approvals have been received.

This member function will return true if the remove approval mask is non-zero and the approvals received (m_remove_approvals) equals the mask.

Returns
true if remove approvals required for removal have been received, false otherwise.

Definition at line 362 of file Operation.cc.

bool Hypertable::Operation::remove_approval_add ( uint16_t  approval)
inline

Sets remove approval bits.

This method is used for operations that are to be removed explicitly. It sets bits in m_remove_approvals by bitwise OR'ing it with approval. Once the bits in m_remove_approvals are set such that m_remove_approvals is equal to those returned by m_remove_approval_mask, the operation can be safely removed.

See also
get_remove_approval_mask, set_remove_approval_mask
Parameters
approvalInteger flag indicating bits to be set in m_remove_approvals

Definition at line 367 of file Operation.h.

void Hypertable::Operation::set_ephemeral ( )
inline

Sets the ephemeral flag to true.

Definition at line 484 of file Operation.h.

void Hypertable::Operation::set_original_type ( int32_t  original_type)
inline

Definition at line 481 of file Operation.h.

void Hypertable::Operation::set_remove_approval_mask ( uint16_t  mask)
inline

Sets the remove approvals bit mask.

Parameters
maskBitmask to use as remove approvals mask.
See also
remove_approval_add, get_remove_approval_mask

Definition at line 345 of file Operation.h.

void Hypertable::Operation::set_state ( int32_t  state)
inline

Definition at line 473 of file Operation.h.

void Operation::stage_subop ( std::shared_ptr< Operation operation)
protected

Stages a sub operation for execution.

This member function creates the following dependency string:

  this->name() + " subop " + operation->name() + operation->hash_code()

and adds it as a dependency to the current operation (this) and also adds it as a permanent obstruction to operation, making the current operation dependent on the sub operation. A remove approval mask of 0x01 is set for operation, and then operation is added to the reference manager and it's ID is pushed onto the end of m_sub_ops.

Parameters
operationSub operation to stage

Definition at line 536 of file Operation.cc.

bool Operation::unblock ( )

Definition at line 504 of file Operation.cc.

bool Operation::validate_subops ( )
protected

Handles the results of sub operations.

For each sub operation, fetches the operation from the reference manager. Checks to see if sub operation resulted in an error, if so, calls complete_error() with the sub operation's error information and returns false. Otherwise, the sub operation's remove approvals are set and the sub operation dependency string (see stage_subop()) is removed from m_dependencies. All of the sub operations are added to a local additional vector, then m_sub_ops is cleared, and the additional vector is passed into a call to record_state().

Returns
true if no sub operation is outstanding or if all of the sub operations completed without error, false otherwise.

Definition at line 512 of file Operation.cc.

Member Data Documentation

bool Hypertable::Operation::m_blocked {}
protected

Flag indicating if operation is blocked.

Definition at line 580 of file Operation.h.

ContextPtr Hypertable::Operation::m_context
protected

Pointer to Master context.

Definition at line 553 of file Operation.h.

DependencySet Hypertable::Operation::m_dependencies
protected

Set of dependencies.

Definition at line 595 of file Operation.h.

bool Hypertable::Operation::m_ephemeral {}
protected

Indicates if operation is ephemeral and does not get persisted to MML.

Definition at line 583 of file Operation.h.

int32_t Hypertable::Operation::m_error {}
protected

Result error code.

Definition at line 571 of file Operation.h.

String Hypertable::Operation::m_error_msg
protected

Result error message.

Definition at line 574 of file Operation.h.

EventPtr Hypertable::Operation::m_event
protected

Pointer to client event (if any) that originated the operation.

Definition at line 556 of file Operation.h.

DependencySet Hypertable::Operation::m_exclusivities
protected

Set of exclusivities.

Definition at line 592 of file Operation.h.

ClockT::time_point Hypertable::Operation::m_expiration_time
protected

Expiration time (used by ResponseManager)

Definition at line 586 of file Operation.h.

int64_t Hypertable::Operation::m_hash_code
protected

Hash code uniqely identifying operation.

Definition at line 589 of file Operation.h.

DependencySet Hypertable::Operation::m_obstructions
protected

Set of obstructions.

Definition at line 598 of file Operation.h.

DependencySet Hypertable::Operation::m_obstructions_permanent
protected

Set of permanent obstructions.

Definition at line 601 of file Operation.h.

int32_t Hypertable::Operation::m_original_type {}
protected

Original entity type read from MML (prior to conversion)

Definition at line 568 of file Operation.h.

uint16_t Hypertable::Operation::m_remove_approval_mask {}
protected

Remove approval mask.

Definition at line 565 of file Operation.h.

uint16_t Hypertable::Operation::m_remove_approvals {}
protected

Remove approvals received.

Definition at line 562 of file Operation.h.

std::vector<int64_t> Hypertable::Operation::m_sub_ops
protected

Vector of sub operations IDs.

Definition at line 604 of file Operation.h.

bool Hypertable::Operation::m_unblock_on_exit {}
protected

Flag to signal operation to be unblocked on exit (post_run())

Definition at line 577 of file Operation.h.


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