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

Carries out recovery operaton for a range server. More...

#include <OperationRecover.h>

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

Public Types

enum  { RESTART = 1 }
 

Public Member Functions

 OperationRecover (ContextPtr &context, RangeServerConnectionPtr &rsc, int flags=0)
 Constructor. More...
 
 OperationRecover (ContextPtr &context, const MetaLog::EntityHeader &header_)
 
virtual ~OperationRecover ()
 
void execute () override
 Executes (carries out) the operation. More...
 
const String name () override
 Name of operation used for exclusivity. More...
 
const String label () override
 Human readable label for operation. More...
 
const Stringlocation () const
 
void display_state (std::ostream &os) override
 Write human readable operation state to output stream. More...
 
uint8_t encoding_version_state () const override
 Returns version of encoding format of state. More...
 
size_t encoded_length_state () const override
 Encoded length of operation state. More...
 
void encode_state (uint8_t **bufp) const override
 Encode operation state. More...
 
void decode_state (uint8_t version, const uint8_t **bufp, size_t *remainp) override
 Decode operation state. More...
 
void decode_state_old (uint8_t version, const uint8_t **bufp, size_t *remainp) override
 
bool exclusive () override
 Indicates if operation is exclusive. More...
 
- 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 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 acquire_server_lock ()
 
void create_recovery_plan ()
 
void read_rsml (std::vector< MetaLog::EntityPtr > &removable_move_ops)
 
void handle_split_shrunk (MetaLogEntityRange *range_entity, std::vector< MetaLog::EntityPtr > &removable_move_ops)
 
void clear_server_state ()
 

Private Attributes

String m_location
 
vector< QualifiedRangeSpecm_root_specs
 
vector< RangeStatem_root_states
 
vector< QualifiedRangeSpecm_metadata_specs
 
vector< RangeStatem_metadata_states
 
vector< QualifiedRangeSpecm_system_specs
 
vector< RangeStatem_system_states
 
vector< QualifiedRangeSpecm_user_specs
 
vector< RangeStatem_user_states
 
CharArena m_arena
 
RangeServerConnectionPtr m_rsc
 
String m_hostname
 
uint64_t m_hyperspace_handle {}
 
bool m_restart {}
 
bool m_lock_acquired {}
 

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 recovery operaton for a range server.

Definition at line 44 of file OperationRecover.h.

Constructor & Destructor Documentation

OperationRecover::OperationRecover ( ContextPtr context,
RangeServerConnectionPtr rsc,
int  flags = 0 
)

Constructor.

This method constructs a new OperationRecover object. If RESTART is passed in for the flags argument then it will prevent notifiction if unable to acquire lock on range server's lock file. This is expected behavior on service restart, so no notification should be deliverd.

Parameters
contextMaster context object
rscRangeServerConnection object referring to server to be recovered
flagsSet to RESTART if this object is being created due to a server restart

Definition at line 54 of file OperationRecover.cc.

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

Definition at line 67 of file OperationRecover.cc.

OperationRecover::~OperationRecover ( )
virtual

Definition at line 254 of file OperationRecover.cc.

Member Function Documentation

bool OperationRecover::acquire_server_lock ( )
private

Definition at line 258 of file OperationRecover.cc.

void OperationRecover::clear_server_state ( )
private

Definition at line 324 of file OperationRecover.cc.

void OperationRecover::create_recovery_plan ( )
private

Definition at line 337 of file OperationRecover.cc.

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

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

Implements Hypertable::Operation.

Definition at line 525 of file OperationRecover.cc.

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

Implements Hypertable::Operation.

Definition at line 560 of file OperationRecover.cc.

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

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

Parameters
osOutput stream to which state string is to be written

Implements Hypertable::Operation.

Definition at line 312 of file OperationRecover.cc.

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

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)

Implements Hypertable::Operation.

Definition at line 497 of file OperationRecover.cc.

size_t OperationRecover::encoded_length_state ( ) const
overridevirtual

Encoded length of operation state.

Returns
Length of encoded operation state.

Implements Hypertable::Operation.

Definition at line 484 of file OperationRecover.cc.

uint8_t OperationRecover::encoding_version_state ( ) const
overridevirtual

Returns version of encoding format of state.

This is method returns the version of the encoding format of the state.

Returns
Version of encoding format of state.

Implements Hypertable::Operation.

Definition at line 480 of file OperationRecover.cc.

bool Hypertable::OperationRecover::exclusive ( )
inlineoverridevirtual

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 from Hypertable::Operation.

Definition at line 81 of file OperationRecover.h.

void OperationRecover::execute ( )
overridevirtual

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.

Implements Hypertable::Operation.

Definition at line 73 of file OperationRecover.cc.

void OperationRecover::handle_split_shrunk ( MetaLogEntityRange range_entity,
std::vector< MetaLog::EntityPtr > &  removable_move_ops 
)
private

Definition at line 441 of file OperationRecover.cc.

const String OperationRecover::label ( )
overridevirtual

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.

Returns
Human readable string describing operation

Implements Hypertable::Operation.

Definition at line 320 of file OperationRecover.cc.

const String& Hypertable::OperationRecover::location ( ) const
inline

Definition at line 73 of file OperationRecover.h.

const String OperationRecover::name ( )
overridevirtual

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::Operation.

Definition at line 316 of file OperationRecover.cc.

void OperationRecover::read_rsml ( std::vector< MetaLog::EntityPtr > &  removable_move_ops)
private

Definition at line 346 of file OperationRecover.cc.

Member Data Documentation

CharArena Hypertable::OperationRecover::m_arena
private

Definition at line 113 of file OperationRecover.h.

String Hypertable::OperationRecover::m_hostname
private

Definition at line 115 of file OperationRecover.h.

uint64_t Hypertable::OperationRecover::m_hyperspace_handle {}
private

Definition at line 116 of file OperationRecover.h.

String Hypertable::OperationRecover::m_location
private

Definition at line 103 of file OperationRecover.h.

bool Hypertable::OperationRecover::m_lock_acquired {}
private

Definition at line 118 of file OperationRecover.h.

vector<QualifiedRangeSpec> Hypertable::OperationRecover::m_metadata_specs
private

Definition at line 106 of file OperationRecover.h.

vector<RangeState> Hypertable::OperationRecover::m_metadata_states
private

Definition at line 107 of file OperationRecover.h.

bool Hypertable::OperationRecover::m_restart {}
private

Definition at line 117 of file OperationRecover.h.

vector<QualifiedRangeSpec> Hypertable::OperationRecover::m_root_specs
private

Definition at line 104 of file OperationRecover.h.

vector<RangeState> Hypertable::OperationRecover::m_root_states
private

Definition at line 105 of file OperationRecover.h.

RangeServerConnectionPtr Hypertable::OperationRecover::m_rsc
private

Definition at line 114 of file OperationRecover.h.

vector<QualifiedRangeSpec> Hypertable::OperationRecover::m_system_specs
private

Definition at line 108 of file OperationRecover.h.

vector<RangeState> Hypertable::OperationRecover::m_system_states
private

Definition at line 109 of file OperationRecover.h.

vector<QualifiedRangeSpec> Hypertable::OperationRecover::m_user_specs
private

Definition at line 110 of file OperationRecover.h.

vector<RangeState> Hypertable::OperationRecover::m_user_states
private

Definition at line 111 of file OperationRecover.h.


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