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

Abstraction for reading a stream of blocks from a commit log file. More...

#include <CommitLogBlockStream.h>

Collaboration diagram for Hypertable::CommitLogBlockStream:
Collaboration graph
[legend]

Public Member Functions

 CommitLogBlockStream (FilesystemPtr &fs)
 
 CommitLogBlockStream (FilesystemPtr &fs, const std::string &log_dir, const std::string &fragment)
 
virtual ~CommitLogBlockStream ()
 
void load (const std::string &log_dir, const std::string &fragment)
 
void close ()
 
bool next (CommitLogBlockInfo *, BlockHeaderCommitLog *)
 
std::string & get_fname ()
 

Static Public Member Functions

static bool read_header (FilesystemPtr &fs, int32_t fd, uint32_t *versionp, uint64_t *next_offset)
 Reads commit log file header. More...
 
static void write_header (FilesystemPtr &fs, int32_t fd)
 Writes commit log file header. More...
 
static uint64_t header_size ()
 Size of header. More...
 

Static Public Attributes

static bool ms_assert_on_error = true
 

Private Member Functions

int load_next_valid_header (BlockHeaderCommitLog *header)
 
bool archive_bad_fragment (const std::string &fname, std::string &archive_fname)
 

Private Attributes

FilesystemPtr m_fs
 Pointer to filesystem. More...
 
std::string m_log_dir
 Directory containing commit log fragment file. More...
 
std::string m_fragment
 Fragment file name within commit log directory. More...
 
std::string m_fname
 Full pathname of commit log fragment file. More...
 
uint32_t m_version
 Version of commit log fragment file format. More...
 
int32_t m_fd
 File descriptor. More...
 
uint64_t m_cur_offset
 Current read offset within the fragment file. More...
 
uint64_t m_file_length
 Length of commit log fragment file. More...
 
DynamicBuffer m_block_buffer
 Buffer holding most recently loaded block. More...
 

Detailed Description

Abstraction for reading a stream of blocks from a commit log file.

Definition at line 62 of file CommitLogBlockStream.h.

Constructor & Destructor Documentation

CommitLogBlockStream::CommitLogBlockStream ( FilesystemPtr fs)

Definition at line 56 of file CommitLogBlockStream.cc.

CommitLogBlockStream::CommitLogBlockStream ( FilesystemPtr fs,
const std::string &  log_dir,
const std::string &  fragment 
)

Definition at line 61 of file CommitLogBlockStream.cc.

CommitLogBlockStream::~CommitLogBlockStream ( )
virtual

Definition at line 68 of file CommitLogBlockStream.cc.

Member Function Documentation

bool CommitLogBlockStream::archive_bad_fragment ( const std::string &  fname,
std::string &  archive_fname 
)
private

Definition at line 270 of file CommitLogBlockStream.cc.

void CommitLogBlockStream::close ( )

Definition at line 99 of file CommitLogBlockStream.cc.

std::string& Hypertable::CommitLogBlockStream::get_fname ( )
inline

Definition at line 75 of file CommitLogBlockStream.h.

uint64_t CommitLogBlockStream::header_size ( )
static

Size of header.

Returns
Size of header in bytes

Definition at line 217 of file CommitLogBlockStream.cc.

void CommitLogBlockStream::load ( const std::string &  log_dir,
const std::string &  fragment 
)

Definition at line 73 of file CommitLogBlockStream.cc.

int CommitLogBlockStream::load_next_valid_header ( BlockHeaderCommitLog header)
private

Definition at line 223 of file CommitLogBlockStream.cc.

bool CommitLogBlockStream::next ( CommitLogBlockInfo infop,
BlockHeaderCommitLog header 
)

Definition at line 114 of file CommitLogBlockStream.cc.

bool CommitLogBlockStream::read_header ( FilesystemPtr fs,
int32_t  fd,
uint32_t *  versionp,
uint64_t *  next_offset 
)
static

Reads commit log file header.

This function assumes that fd is a valid file descriptor for a commit log file that is opened for reading and positioned at the beginning of the file. It reads the header and extracts the version number, saving it to *versionp, and sets *next_offset to the file offset immediately following the header. If the header is invalid, it implies that the file is in the original format that did not have the header. In this case, *versionp is set to zero, *next_offset is set to zero, and false is returned.

Parameters
fsReference to filesystem object
fdFile descriptor of newly opened commit log file
versionpAddress of variable to hold version read from header
next_offsetAddress of file offset variable positioned to first byte after the header
Returns
true if valid header was encountered, false otherwise

Definition at line 183 of file CommitLogBlockStream.cc.

void CommitLogBlockStream::write_header ( FilesystemPtr fs,
int32_t  fd 
)
static

Writes commit log file header.

This function assumes that fd is a valid file descriptor for a commit log file that is opened for writing and positioned at the beginning of the file. The header that is written consists of eight bytes and has the following format:

vNNNN\f\n\0

The NNNN component consists of four ASCII digits that represent the latest version number. The formfeed+newline allows the verison number to be displayed by running the Unix more on the file, which will display the version number and then pause the output.

Parameters
fsReference to filesystem object
fdFile descriptor of newly opened commit log file

Definition at line 209 of file CommitLogBlockStream.cc.

Member Data Documentation

DynamicBuffer Hypertable::CommitLogBlockStream::m_block_buffer
private

Buffer holding most recently loaded block.

Definition at line 155 of file CommitLogBlockStream.h.

uint64_t Hypertable::CommitLogBlockStream::m_cur_offset
private

Current read offset within the fragment file.

Definition at line 149 of file CommitLogBlockStream.h.

int32_t Hypertable::CommitLogBlockStream::m_fd
private

File descriptor.

Definition at line 146 of file CommitLogBlockStream.h.

uint64_t Hypertable::CommitLogBlockStream::m_file_length
private

Length of commit log fragment file.

Definition at line 152 of file CommitLogBlockStream.h.

std::string Hypertable::CommitLogBlockStream::m_fname
private

Full pathname of commit log fragment file.

Definition at line 140 of file CommitLogBlockStream.h.

std::string Hypertable::CommitLogBlockStream::m_fragment
private

Fragment file name within commit log directory.

Definition at line 137 of file CommitLogBlockStream.h.

FilesystemPtr Hypertable::CommitLogBlockStream::m_fs
private

Pointer to filesystem.

Definition at line 131 of file CommitLogBlockStream.h.

std::string Hypertable::CommitLogBlockStream::m_log_dir
private

Directory containing commit log fragment file.

Definition at line 134 of file CommitLogBlockStream.h.

uint32_t Hypertable::CommitLogBlockStream::m_version
private

Version of commit log fragment file format.

Definition at line 143 of file CommitLogBlockStream.h.

bool CommitLogBlockStream::ms_assert_on_error = true
static

Definition at line 77 of file CommitLogBlockStream.h.


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