Abstract base class for master operations. More...
#include <Operation.h>
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... | |
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.
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.
context | Master context |
type | Operation 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.
context | Master context |
event | Event object |
type | Operation 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.
context | Master context |
header_ | MetaLog header |
Definition at line 74 of file Operation.cc.
|
inlinevirtual |
Destructor.
Definition at line 165 of file Operation.h.
|
inline |
Definition at line 462 of file Operation.h.
|
inline |
Definition at line 461 of file Operation.h.
|
inline |
Definition at line 463 of file Operation.h.
|
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:
error
msg
additional
with a call to record_state() error | Error code of operation result |
msg | Error message of operation result |
additional | Vector 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
error | Error code of operation result |
msg | Error message of operation result |
additional | Additional entity to persist to MML |
Definition at line 428 of file Operation.cc.
|
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.
e | Exception precipitating the operation completion |
additional | Vector of additional entities to persist to MML |
Definition at line 437 of file Operation.h.
|
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.
e | Exception precipitating the operation completion |
additional | Vector 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.
|
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.
bufp | Address of source buffer pointer (advanced by call) |
remainp | Amount of remaining buffer pointed to by *bufp (decremented by call). |
definition_version | Version of DefinitionMaster |
Reimplemented from Hypertable::MetaLog::Entity.
Definition at line 275 of file Operation.cc.
|
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().
version | Encoding version |
bufp | Address of destination buffer pointer (advanced by call) |
remainp | Address of integer holding amount of serialized encoding remaining |
Implements Hypertable::Serializable.
Definition at line 205 of file Operation.cc.
|
protected |
Definition at line 283 of file Operation.cc.
|
virtual |
Decode operation result.
This method is called by decode() to handle decoding of the operation result.
bufp | Address of pointer to encoded result |
remainp | Address of integer holding amount of remaining buffer |
Reimplemented in Hypertable::OperationMoveRange, and Hypertable::OperationInitialize.
Definition at line 356 of file Operation.cc.
|
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.
version | Encoding version |
bufp | Address of pointer to destination buffer |
remainp | Address 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.
|
pure virtual |
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 |
Definition at line 464 of file Operation.cc.
|
overridevirtual |
Write human readable string represenation of operation to output stream.
os | Output stream to which string is written |
Reimplemented from Hypertable::MetaLog::Entity.
Definition at line 79 of file Operation.cc.
|
pure virtual |
Write human readable operation state to output stream.
This method is called by display() to write a human readable string representation of the operation state to os
os | Output stream to which state string is to be written |
Implemented in Hypertable::OperationDropTable, Hypertable::OperationSetState, Hypertable::OperationCreateTable, Hypertable::OperationRegisterServerBlocker, Hypertable::OperationRecreateIndexTables, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationCompact, Hypertable::OperationAlterTable, Hypertable::OperationRecover, Hypertable::OperationGatherStatistics, Hypertable::OperationMoveRange, Hypertable::OperationRecoverRanges, Hypertable::OperationRelinquishAcknowledge, Hypertable::OperationSystemStatus, Hypertable::OperationBalance, Hypertable::OperationRenameTable, Hypertable::OperationStatus, Hypertable::OperationCreateNamespace, Hypertable::OperationDropNamespace, Hypertable::OperationRegisterServer, Hypertable::OperationTimedBarrier, Hypertable::OperationSystemUpgrade, Hypertable::OperationStop, Hypertable::OperationCollectGarbage, Hypertable::OperationInitialize, Hypertable::OperationRecoveryBlocker, and Hypertable::OperationWaitForServers.
|
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.
bufp | Address of destination buffer pointer (advanced by call) |
Implements Hypertable::Serializable.
Definition at line 172 of file Operation.cc.
|
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:
Encoding | Description |
---|---|
i32 | Error code |
vstr | Error message (if error code != Error::OK) |
bufp | Address of pointer to destination buffer |
Reimplemented in Hypertable::OperationSystemStatus, and Hypertable::OperationStatus.
Definition at line 350 of file Operation.cc.
|
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.
bufp | Address 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.
|
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.
Implements Hypertable::Serializable.
Definition at line 143 of file Operation.cc.
|
pure virtual |
Encoded length of operation state.
Implemented in Hypertable::OperationDropTable, Hypertable::OperationCreateTable, Hypertable::OperationEphemeral, Hypertable::OperationSetState, Hypertable::OperationRecreateIndexTables, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationAlterTable, Hypertable::OperationCompact, Hypertable::OperationRecover, Hypertable::OperationMoveRange, Hypertable::OperationRecoverRanges, Hypertable::OperationBalance, Hypertable::OperationRenameTable, Hypertable::OperationCreateNamespace, Hypertable::OperationDropNamespace, and Hypertable::OperationInitialize.
|
virtual |
Length of encoded operation result.
This method returns the length of the encoded result
Reimplemented in Hypertable::OperationSystemStatus, and Hypertable::OperationStatus.
Definition at line 344 of file Operation.cc.
|
overrideprotectedvirtual |
Returns encoding version.
Implements Hypertable::Serializable.
Definition at line 139 of file Operation.cc.
|
pure virtual |
Returns version of encoding format of state.
This is method returns the version of the encoding format of the state.
Implemented in Hypertable::OperationEphemeral, Hypertable::OperationDropTable, Hypertable::OperationCreateTable, Hypertable::OperationSetState, Hypertable::OperationRecreateIndexTables, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationAlterTable, Hypertable::OperationCompact, Hypertable::OperationRecover, Hypertable::OperationMoveRange, Hypertable::OperationRecoverRanges, Hypertable::OperationBalance, Hypertable::OperationRenameTable, Hypertable::OperationCreateNamespace, Hypertable::OperationDropNamespace, and Hypertable::OperationInitialize.
|
inline |
Gets the ephemeral flag.
Definition at line 490 of file Operation.h.
|
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.
Reimplemented in Hypertable::OperationRecover, Hypertable::OperationGatherStatistics, Hypertable::OperationBalance, and Hypertable::OperationCollectGarbage.
Definition at line 222 of file Operation.h.
|
virtual |
Definition at line 459 of file Operation.cc.
|
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.
|
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.
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.
|
inline |
|
inline |
|
inline |
Definition at line 480 of file Operation.h.
|
inline |
Gets the remove approvals bit mask.
Definition at line 353 of file Operation.h.
|
inline |
Definition at line 472 of file Operation.h.
|
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.
Reimplemented in Hypertable::OperationMoveRange, and Hypertable::OperationRelinquishAcknowledge.
Definition at line 209 of file Operation.h.
|
inlinevirtual |
Definition at line 455 of file Operation.h.
|
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.
Definition at line 326 of file Operation.h.
|
inline |
Definition at line 477 of file Operation.h.
|
inline |
Definition at line 478 of file Operation.h.
|
inlinevirtual |
Reimplemented in Hypertable::OperationTimedBarrier, Hypertable::OperationWaitForServers, and Hypertable::OperationRecoveryBlocker.
Definition at line 474 of file Operation.h.
|
pure virtual |
Human readable label for operation.
This method is used to generate a human readable string describing the operation and is typically used for generating log messages.
Implemented in Hypertable::OperationRegisterServerBlocker, Hypertable::OperationCreateTable, Hypertable::OperationDropTable, Hypertable::OperationSetState, Hypertable::OperationRecreateIndexTables, Hypertable::OperationToggleTableMaintenance, Hypertable::OperationCompact, Hypertable::OperationAlterTable, Hypertable::OperationRecover, 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.
|
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.
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.
|
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:
additional
entities.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.
additional | Additional entities to be recorded in MML |
Definition at line 367 of file Operation.cc.
|
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.
Definition at line 362 of file Operation.cc.
|
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.
approval | Integer flag indicating bits to be set in m_remove_approvals |
Definition at line 367 of file Operation.h.
|
inline |
Sets the ephemeral flag to true.
Definition at line 484 of file Operation.h.
|
inline |
Definition at line 481 of file Operation.h.
|
inline |
Sets the remove approvals bit mask.
mask | Bitmask to use as remove approvals mask. |
Definition at line 345 of file Operation.h.
|
inline |
Definition at line 473 of file Operation.h.
|
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.
operation | Sub operation to stage |
Definition at line 536 of file Operation.cc.
bool Operation::unblock | ( | ) |
Definition at line 504 of file Operation.cc.
|
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().
Definition at line 512 of file Operation.cc.
|
protected |
Flag indicating if operation is blocked.
Definition at line 580 of file Operation.h.
|
protected |
Pointer to Master context.
Definition at line 553 of file Operation.h.
|
protected |
Set of dependencies.
Definition at line 595 of file Operation.h.
|
protected |
Indicates if operation is ephemeral and does not get persisted to MML.
Definition at line 583 of file Operation.h.
|
protected |
Result error code.
Definition at line 571 of file Operation.h.
|
protected |
Result error message.
Definition at line 574 of file Operation.h.
|
protected |
Pointer to client event (if any) that originated the operation.
Definition at line 556 of file Operation.h.
|
protected |
Set of exclusivities.
Definition at line 592 of file Operation.h.
|
protected |
Expiration time (used by ResponseManager)
Definition at line 586 of file Operation.h.
|
protected |
Hash code uniqely identifying operation.
Definition at line 589 of file Operation.h.
|
protected |
Set of obstructions.
Definition at line 598 of file Operation.h.
|
protected |
Set of permanent obstructions.
Definition at line 601 of file Operation.h.
|
protected |
Original entity type read from MML (prior to conversion)
Definition at line 568 of file Operation.h.
|
protected |
Remove approval mask.
Definition at line 565 of file Operation.h.
|
protected |
Remove approvals received.
Definition at line 562 of file Operation.h.
|
protected |
Vector of sub operations IDs.
Definition at line 604 of file Operation.h.
|
protected |
Flag to signal operation to be unblocked on exit (post_run())
Definition at line 577 of file Operation.h.