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 | Friends | List of all members
Hypertable::MetaLog::Entity Class Referenceabstract

Base class for MetaLog entities. More...

#include <MetaLogEntity.h>

Inheritance diagram for Hypertable::MetaLog::Entity:
Inheritance graph
[legend]
Collaboration diagram for Hypertable::MetaLog::Entity:
Collaboration graph
[legend]

Public Member Functions

 Entity (int32_t type)
 Constructor from entity type. More...
 
 Entity (const EntityHeader &header_)
 Constructor from entity header. More...
 
virtual ~Entity ()
 Destructor. More...
 
virtual void decode (const uint8_t **bufp, size_t *remainp, uint16_t definition_version)
 Decodes serialized entity state. 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...
 
virtual const std::string name ()=0
 Returns the name of the entity. More...
 
int64_t id () const
 Returns the entity ID. More...
 
virtual void display (std::ostream &os)
 Prints a textual representation of the entity state to an ostream. 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

void encode_entry (uint8_t **bufp)
 Encodes entity header plus serialized state. More...
 
- Protected Member Functions inherited from Hypertable::Serializable
virtual uint8_t encoding_version () const =0
 Returns encoding version. More...
 
virtual size_t encoded_length_internal () const =0
 Returns internal serialized length. More...
 
virtual void encode_internal (uint8_t **bufp) const =0
 Writes serialized representation of object to a buffer. More...
 
virtual void decode_internal (uint8_t version, const uint8_t **bufp, size_t *remainp)=0
 Reads serialized representation of object from a buffer. More...
 

Protected Attributes

std::mutex m_mutex
 Mutex for serializing access to members More...
 
EntityHeader header
 Entity header More...
 

Friends

class Reader
 
class Writer
 
std::ostream & operator<< (std::ostream &os, Entity &entity)
 ostream shift function for Entity objects. More...
 

Detailed Description

Base class for MetaLog entities.

A MetaLog entitiy is associated with each application object that is to be persisted in the MetaLog. Entity objects are what get passed into and out of the read and write methods of the MetaLog API. Application objects can include a member that is derived from this class for the purpose of persisting its state. The application object class can also be derived from Entity allowing the application object itself to be passed directly into the Metalog APIs.

Definition at line 62 of file MetaLogEntity.h.

Constructor & Destructor Documentation

Entity::Entity ( int32_t  type)

Constructor from entity type.

This method constructs a new entity, initializing the header member with type.

Parameters
typeNumeric entity type

Definition at line 40 of file MetaLogEntity.cc.

Entity::Entity ( const EntityHeader header_)

Constructor from entity header.

This method constructs an entity from an entity header (typically read and deserialized from a MetaLog). The header member is initialized with header_.

Parameters
header_Entity header

Definition at line 42 of file MetaLogEntity.cc.

virtual Hypertable::MetaLog::Entity::~Entity ( )
inlinevirtual

Destructor.

Definition at line 81 of file MetaLogEntity.h.

Member Function Documentation

virtual void Hypertable::MetaLog::Entity::decode ( const uint8_t **  bufp,
size_t *  remainp,
uint16_t  definition_version 
)
inlinevirtual

Decodes serialized entity state.

Parameters
bufpAddress of destination buffer pointer (advanced by call)
remainpAddress of integer holding amount of remaining buffer
definition_versionVersion of MetaLog::Definition that was used to generate the log.

Reimplemented in Hypertable::Operation, Hypertable::BalancePlanAuthority, Hypertable::MetaLog::EntityRecover, Hypertable::MetaLogEntityRange, Hypertable::SystemState, Hypertable::MetaLogEntityRemoveOkLogs, Hypertable::RecoveredServers, Hypertable::RangeServerConnection, and Hypertable::MetaLog::EntityTaskAcknowledgeRelinquish.

Definition at line 91 of file MetaLogEntity.h.

virtual void Hypertable::MetaLog::Entity::display ( std::ostream &  os)
inlinevirtual

Prints a textual representation of the entity state to an ostream.

Parameters
osostream on which to print entity state

Reimplemented in Hypertable::Operation, Hypertable::BalancePlanAuthority, Hypertable::MetaLogEntityRange, Hypertable::SystemState, Hypertable::MetaLogEntityRemoveOkLogs, Hypertable::RecoveredServers, Hypertable::RangeServerConnection, and Hypertable::MetaLog::EntityTaskAcknowledgeRelinquish.

Definition at line 142 of file MetaLogEntity.h.

void Entity::encode_entry ( uint8_t **  bufp)
protected

Encodes entity header plus serialized state.

This method first encodes the serialized state at *bufp plus EntityHeader::LENGTH bytes. It then computes the checksum of the serialized state with a call to fletcher32() and stores the result in header.checksum. It then encodes header at the beginning of the buffer. *bufp is left pointing to the end of the serialized state when the method returns.

Parameters
bufpAddress of destination buffer pointer (advanced by call)

Definition at line 45 of file MetaLogEntity.cc.

int64_t Hypertable::MetaLog::Entity::id ( ) const
inline

Returns the entity ID.

Returns
Entity ID from the

Definition at line 137 of file MetaLogEntity.h.

void Hypertable::MetaLog::Entity::lock ( )
inline

Locks the entity's mutex.

Definition at line 97 of file MetaLogEntity.h.

void Hypertable::MetaLog::Entity::mark_for_removal ( )
inline

Marks entity for removal.

To remove an entity from a MetaLog, the entity header gets written to the log with the EntityHeader::FLAG_REMOVE bit set in the flags field of the header. This method sets the EntityHeader::FLAG_REMOVE bit in the header and sets the header length and header checksum fields to zero. After a call to this method, the next time the entity is persisted to the log, it will be logically removed.

Definition at line 110 of file MetaLogEntity.h.

bool Hypertable::MetaLog::Entity::marked_for_removal ( )
inline

Checks if entity is marked for removal.

This method returns true if the EntityHeader::FLAG_REMOVE bit is set in the flags member of its header which means the next time it gets persisted, it will be logically removed removed.

See also
mark_for_removal()
Returns
true if entity is marked for removal, false otherwise

Definition at line 123 of file MetaLogEntity.h.

virtual const std::string Hypertable::MetaLog::Entity::name ( )
pure virtual
void Hypertable::MetaLog::Entity::unlock ( )
inline

Unlocks the entity's mutex.

Definition at line 100 of file MetaLogEntity.h.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
Entity entity 
)
friend

ostream shift function for Entity objects.

This method writes a human readable representation of an Entity to a given ostream. It prints the header followed by the entity state.

Parameters
osostream on which to print entity
entityEntity object to print
Returns
os

Definition at line 179 of file MetaLogEntity.h.

friend class Reader
friend

Definition at line 145 of file MetaLogEntity.h.

friend class Writer
friend

Definition at line 146 of file MetaLogEntity.h.

Member Data Documentation

EntityHeader Hypertable::MetaLog::Entity::header
protected

Entity header

Definition at line 165 of file MetaLogEntity.h.

std::mutex Hypertable::MetaLog::Entity::m_mutex
mutableprotected

Mutex for serializing access to members

Definition at line 162 of file MetaLogEntity.h.


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