Drizzled Public API Documentation

TransactionLog Class Reference

List of all members.

Public Types

enum  Status { CRASHED = 0, OFFLINE, ONLINE, WRITING }
typedef std::vector
< TransactionLogEntry
Entries
typedef std::vector
< TransactionLogTransactionEntry
TransactionEntries

Public Member Functions

 TransactionLog (const std::string in_log_file_path, uint32_t in_flush_frequency, bool in_do_checksum)
 ~TransactionLog ()
off_t getLogOffset ()
const std::string & getLogFilename ()
const std::string & getLogFilepath ()
enum Status getState ()
uint8_t * packTransactionIntoLogEntry (const drizzled::message::Transaction &trx, uint8_t *buffer, uint32_t *checksum_out)
off_t writeEntry (const uint8_t *data, size_t data_length)
void truncate ()
bool findLogFilenameContainingTransactionId (const drizzled::ReplicationServices::GlobalTransactionId &to_find, std::string &out_filename) const
bool hasError () const
const std::string & getErrorMessage () const

Static Public Member Functions

static size_t getLogEntrySize (const drizzled::message::Transaction &trx)

Static Public Attributes

static const uint32_t FLUSH_FREQUENCY_OS = 0
 Rely on operating system to sync log file.
static const uint32_t FLUSH_FREQUENCY_EVERY_WRITE = 1
static const uint32_t FLUSH_FREQUENCY_EVERY_SECOND = 2
 Sync no more than once a second.

Private Member Functions

 TransactionLog (const TransactionLog &other)
TransactionLogoperator= (const TransactionLog &other)
void clearError ()
int syncLogFile ()

Private Attributes

int log_file
 Handle for our log file.
Status state
 The state the log is in.
const std::string log_file_path
 Full path to the log file.
std::string log_file_name
 Name of the log file.
drizzled::atomic< off_t > log_offset
 Offset in log file where log will write next command.
bool has_error
 Is the log in error?
std::string error_message
 Current error message.
uint32_t flush_frequency
 Determines behaviour of syncing log file.
time_t last_sync_time
 Last time the log file was synced (only set in FLUSH_FREQUENCY_EVERY_SECOND)
bool do_checksum
 Do a CRC32 checksum when writing Transaction message to log?

Static Private Attributes

static const uint32_t HEADER_TRAILER_BYTES

Detailed Description

Definition at line 48 of file transaction_log.h.


Member Enumeration Documentation

The state the log is in

Definition at line 56 of file transaction_log.h.


Constructor & Destructor Documentation

TransactionLog::~TransactionLog ( )

Destructor

Definition at line 117 of file module.cc.


Member Function Documentation

void TransactionLog::clearError ( ) [private]

Clears the current error message

Definition at line 304 of file transaction_log.cc.

References error_message, and has_error.

bool TransactionLog::findLogFilenameContainingTransactionId ( const drizzled::ReplicationServices::GlobalTransactionId &  to_find,
std::string &  out_filename 
) const

Takes a global transaction ID and a reference to a string to fill with the name of the log file which contains the command with the transaction ID. If the transaction ID is contained in a log file, the function returns true, false otherwise.

Parameters:
[in]Globaltransaction ID to search on
inout]String to fill with name of logfile containing command with the needed transaction ID
Return values:
trueif found
falseotherwise

Definition at line 287 of file transaction_log.cc.

References log_file_path.

const string & TransactionLog::getErrorMessage ( ) const

Returns the log's current error message

Definition at line 310 of file transaction_log.cc.

References error_message.

size_t TransactionLog::getLogEntrySize ( const drizzled::message::Transaction trx) [static]

Static helper method which returns the transaction log entry size in bytes of a given transaction message.

Parameters:
[in]Transactionmessage

Definition at line 315 of file transaction_log.cc.

Referenced by TransactionLogApplier::apply().

const string & TransactionLog::getLogFilename ( )

Returns the filename of the transaction log

Definition at line 261 of file transaction_log.cc.

References log_file_name.

Referenced by PrintTransactionMessageFunction::val_str(), and HexdumpTransactionMessageFunction::val_str().

const string & TransactionLog::getLogFilepath ( )

Returns the filename of the transaction log

Definition at line 266 of file transaction_log.cc.

References log_file_path.

off_t TransactionLog::getLogOffset ( ) [inline]

Returns the current offset into the log

Definition at line 77 of file transaction_log.h.

References log_offset.

enum Status TransactionLog::getState ( ) [inline]

Returns the state that the log is in

Definition at line 95 of file transaction_log.h.

References state.

bool TransactionLog::hasError ( ) const

Returns whether the log is currently in error.

Definition at line 299 of file transaction_log.cc.

References has_error.

uint8_t * TransactionLog::packTransactionIntoLogEntry ( const drizzled::message::Transaction trx,
uint8_t *  buffer,
uint32_t *  checksum_out 
)

Method which packs into a raw byte buffer a transaction log entry. Supplied buffer should be of adequate size.

Returns a pointer to the start of the original buffer.

Parameters:
[in]Transactionmessage to pack
[in]Rawbyte buffer
[out]Pointerto storage for checksum of message

Definition at line 143 of file transaction_log.cc.

References do_checksum.

Referenced by TransactionLogApplier::apply().

int TransactionLog::syncLogFile ( ) [private]

Helper method which synchronizes/flushes the transaction log file according to the transaction_log_flush_frequency system variable

Return values:
0== Success
>0== Failure. Error code.

Definition at line 239 of file transaction_log.cc.

References flush_frequency, FLUSH_FREQUENCY_EVERY_SECOND, FLUSH_FREQUENCY_OS, last_sync_time, and log_file.

Referenced by writeEntry().

void TransactionLog::truncate ( )

Truncates the existing log file

Note:

This is only called currently during debugging and testing of the command log...when the global command_log_truncate variable is set to anything other than false, this is called.

Definition at line 271 of file transaction_log.cc.

References log_file, and log_offset.

off_t TransactionLog::writeEntry ( const uint8_t *  data,
size_t  data_length 
)

Writes a chunk of data to the log file of a specified length and returns the offset at which the chunk of data was written.

Parameters:
[in]Bytesto write
in[Length of bytes to write
Return values:
Returnsthe write offset if the write succeeded, OFF_T_MAX otherwise.

Definition at line 180 of file transaction_log.cc.

References log_file, log_offset, state, and syncLogFile().

Referenced by TransactionLogApplier::apply().


Member Data Documentation

const uint32_t TransactionLog::HEADER_TRAILER_BYTES [static, private]
Initial value:
 sizeof(uint32_t) + 
                                              sizeof(uint32_t) + 
                                              sizeof(uint32_t)

Definition at line 177 of file transaction_log.h.


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