28 #ifndef Hypertable_Master_Operation_h
29 #define Hypertable_Master_Operation_h
50 namespace OperationState {
94 namespace Dependency {
95 extern const char *
INIT;
97 extern const char *
ROOT;
100 extern const char *
USER;
254 virtual void decode_result(
const uint8_t **bufp,
size_t *remainp);
289 virtual void decode_state(uint8_t version,
const uint8_t **bufp,
290 size_t *remainp) = 0;
293 size_t *remainp) = 0;
312 void decode(
const uint8_t **bufp,
size_t *remainp,
313 uint16_t definition_version)
override;
318 void display(std::ostream &os)
override;
396 void record_state(std::vector<MetaLog::EntityPtr> &additional);
402 std::vector<MetaLog::EntityPtr> additional;
452 void complete_ok(std::vector<MetaLog::EntityPtr> &additional);
520 size_t *remainp)
override;
522 void decode_old(
const uint8_t **bufp,
size_t *remainp,
523 uint16_t definition_version);
550 void stage_subop(std::shared_ptr<Operation> operation);
615 #endif // Hypertable_Master_Operation_h
virtual void encode_result(uint8_t **bufp) const
Encode operation result.
int64_t id()
Operation identifier.
virtual void display_state(std::ostream &os)=0
Write human readable operation state to output stream.
virtual bool exclusive()
Indicates if operation is exclusive.
ContextPtr m_context
Pointer to Master context.
uint16_t m_remove_approvals
Remove approvals received.
String m_error_msg
Result error message.
virtual size_t encoded_length_state() const =0
Encoded length of operation state.
std::string String
A String is simply a typedef to std::string.
std::shared_ptr< Entity > EntityPtr
Smart pointer to Entity.
virtual void execute()=0
Executes (carries out) the operation.
chrono::time_point< fast_clock > time_point
bool validate_subops()
Handles the results of sub operations.
void set_original_type(int32_t original_type)
virtual void decode_result(const uint8_t **bufp, size_t *remainp)
Decode operation result.
void decode(const uint8_t **bufp, size_t *remainp, uint16_t definition_version) override
Decode operation.
void set_ephemeral()
Sets the ephemeral flag to true.
virtual uint8_t encoding_version_state() const =0
Returns version of encoding format of state.
void add_exclusivity(const String &exclusivity)
virtual const String graphviz_label()
Human readable operation label used in graphviz output.
virtual void obstructions(DependencySet &obstructions)
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
uint16_t m_remove_approval_mask
Remove approval mask.
void add_obstruction(const String &obstruction)
virtual int64_t hash_code() const
int32_t m_original_type
Original entity type read from MML (prior to conversion)
int32_t get_error()
Get error code.
const char * get_text(int32_t state)
uint16_t get_remove_approval_mask()
Gets the remove approvals bit mask.
const char * RECOVER_SERVER
int64_t m_hash_code
Hash code uniqely identifying operation.
EventPtr m_event
Pointer to client event (if any) that originated the operation.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
uint8_t encoding_version() const override
Returns encoding version.
virtual void dependencies(DependencySet &dependencies)
void set_state(int32_t state)
size_t encoded_length_internal() const override
Returns internal serialized length.
String get_error_msg()
Get error message.
int32_t m_error
Result error code.
void add_dependency(const String &dependency)
virtual void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp)=0
DependencySet m_obstructions_permanent
Set of permanent obstructions.
void stage_subop(std::shared_ptr< Operation > operation)
Stages a sub operation for execution.
bool removal_approved()
Checks if all remove approvals have been received.
bool ephemeral()
Gets the ephemeral flag.
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
void set_remove_approval_mask(uint16_t mask)
Sets the remove approvals bit mask.
void record_state()
Records operation state to the MML.
const String name() override=0
Name of operation used for exclusivity.
bool m_blocked
Flag indicating if operation is blocked.
ClockT::time_point expiration_time()
Returns operation expiration time.
void complete_error(Exception &e, std::vector< MetaLog::EntityPtr > &additional)
Completes operation with exception.
bool m_ephemeral
Indicates if operation is ephemeral and does not get persisted to MML.
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.
const char * RECOVERY_BLOCKER
virtual const String label()=0
Human readable label for operation.
void add_obstruction_permanent(const String &obstruction)
virtual ~Operation()
Destructor.
DependencySet m_obstructions
Set of obstructions.
virtual void exclusivities(DependencySet &exclusivities)
virtual bool is_perpetual()
DependencySet m_dependencies
Set of dependencies.
void fetch_sub_operations(std::vector< std::shared_ptr< Operation > > &sub_ops)
void decode_old(const uint8_t **bufp, size_t *remainp, uint16_t definition_version)
Abstract base class for master operations.
Operation(ContextPtr &context, int32_t type)
Constructor with operation type specifier.
void display(std::ostream &os) override
Write human readable string represenation of operation to output stream.
void complete_error(Exception &e, MetaLog::EntityPtr additional=MetaLog::EntityPtr())
Completes operation with exception.
std::vector< int64_t > m_sub_ops
Vector of sub operations IDs.
This is a generic exception class for Hypertable.
virtual void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp)=0
Decode operation state.
bool m_unblock_on_exit
Flag to signal operation to be unblocked on exit (post_run())
virtual void encode_state(uint8_t **bufp) const =0
Encode operation state.
DependencySet m_exclusivities
Set of exclusivities.
std::set< String > DependencySet
Set of dependency string.
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
std::shared_ptr< Operation > OperationPtr
Smart pointer to Operation.
int32_t get_original_type()
bool remove_approval_add(uint16_t approval)
Sets remove approval bits.
void complete_error(int error, const String &msg, std::vector< MetaLog::EntityPtr > &additional)
Completes operation with error.
Declarations for Context.
virtual size_t encoded_result_length() const
Length of encoded operation result.
int code() const
Returns the error code.
ClockT::time_point m_expiration_time
Expiration time (used by ResponseManager)
Executes user-defined functions when leaving the current scope.