Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends

df_DataBlock Class Reference
[IVD Data format.]

Class to handle one data block of specified size. More...

#include <df.h>

List of all members.

Public Member Functions

 df_DataBlock (UInt8_t *a_block, const UInt32_t a_size)
bool IsEmpty () const
bool IsClosed () const
void SetBlockID (UInt32_t a_blkID)
UInt32_t GetBlockID () const
UInt8_tGetData () const
UInt32_t GetBlockSize () const
UInt32_t GetUsedSize () const
UInt32_t GetFreeSize () const
 How much space is there to be processed? Used by the writer.
UInt8_tGetPosition () const
 Returns a pointer to the beginning of the free space.
void Move (UInt32_t a_amount)
 Writing or reading data of a block is just increasing the amount of used space (a "virtual" pointer to the beginning of free space in a block).
void Close (UInt32_t a_numReaders)
 Marks the block closed.
void Release ()
 Each reader must release the block after it is finished with it.
void Delete ()
 Deleting is resetting the amount of used space.
void Wipe ()
 Currently not used.

Public Attributes

 log_CLASSID_m

Private Member Functions

virtual ~df_DataBlock ()

Private Attributes

UInt8_tm_block
const UInt32_t m_size
 Size of the data block df_DataBlock::m_block.
UInt32_t m_used
 How much of the block space is already used (written or read by front end).
bool m_closed
 Writing to closed block is prevented.
UInt32_t m_numReaders
 How many back-ends are left to finish processing this block.
UInt32_t m_blockID
 Arbitrary block identification (e.g.

Friends

class df_BlockManager
class fsc_nsFSrecovery

Detailed Description

Class to handle one data block of specified size.

df_Datablock class is a wrapper class around raw memory buffer. It synchronises access to the memory block among a writer and reader(s).

It is used by df_BlockManager.

Author:
Matej Kenda, HERMES SoftLab

Definition at line 68 of file df.h.


Constructor & Destructor Documentation

df_DataBlock::df_DataBlock ( UInt8_t a_block,
const UInt32_t  a_size 
)
Parameters:
a_block Pointer to the beginning of pre-allocated memory buffer.
a_size Size of memory buffer.

Definition at line 66 of file df_datablock.cpp.

    : m_block(a_block),
      m_size(a_size),
      m_used(0),
      m_closed(false),
      m_blockID(0) {

    // Empty
}

df_DataBlock::~df_DataBlock (  )  [private, virtual]

Definition at line 76 of file df_datablock.cpp.

                            {
    // Empty
}


Member Function Documentation

void df_DataBlock::Close ( UInt32_t  a_numReaders  ) 

Marks the block closed.

Nothing can be written to/read from the block until it is released. Used by writer.

Data block after useful data is filled with zeroes. That allows better compression on tape. However, if the block is logically completelly empty it is not wiped for performance optimization reasons.

Parameters:
a_numReaders The number of readers that will process this block, before it is released.
See also:
Release()

Definition at line 150 of file df_datablock.cpp.

References GetFreeSize(), GetPosition(), IsEmpty(), log_FUNC_INT_m, m_closed, and m_numReaders.

Referenced by df_BlockManager::Flush().

                                              {
    log_FUNC_INT_m(Close);

    // Do not wipe out the block if it is completely empty.
    // The user of the class must detect that the block is logically empty.
    if ( !IsEmpty()) {
        UInt32_t wipeSize = GetFreeSize();
        memset(GetPosition(), 0, wipeSize);
    };

    m_closed = true;
    m_numReaders = a_numReaders;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_DataBlock::Delete (  ) 

Deleting is resetting the amount of used space.

Called by Release().

Definition at line 186 of file df_datablock.cpp.

References m_used.

Referenced by fsc_nsFSrecovery::FlushBlock(), Release(), and Wipe().

                          {
    m_used = 0;
}

Here is the caller graph for this function:

UInt32_t df_DataBlock::GetBlockID (  )  const [inline]

Definition at line 103 of file df.h.

Referenced by df_BlockReader::GetNextBlock(), and df_BlockReader::GetRawNextBlock().

{ return m_blockID; };

Here is the caller graph for this function:

UInt32_t df_DataBlock::GetBlockSize (  )  const [inline]

Definition at line 105 of file df.h.

Referenced by df_Unpacker::GetBSData(), and bea_FRI::ReadFRI().

{ return m_size; };

Here is the caller graph for this function:

UInt8_t* df_DataBlock::GetData (  )  const [inline]

Definition at line 104 of file df.h.

Referenced by df_Unpacker::GetBSData(), df_Unpacker::GetNextBlock(), df_BlockReader::GetNextBlock(), df_BlockReader::GetRawNextBlock(), and bea_MigrationThread::Migrate().

{ return m_block; };

Here is the caller graph for this function:

UInt32_t df_DataBlock::GetFreeSize (  )  const

How much space is there to be processed? Used by the writer.

See also:
IsEmpty()

Definition at line 115 of file df_datablock.cpp.

References m_closed, m_size, and m_used.

Referenced by df_BlockProxyWriter::Allocate(), df_BlockProxyWriter::AllocateRawBlock(), Close(), df_BlockProxyWriter::GetFreeSize(), Move(), blk_NetReader::Run(), blk_BufferReader::Run(), and bea_VolumeReader::Run().

                                         {
    if (m_closed) {
        return 0;
    }
    else{
        return (m_size - m_used);
    }
}

Here is the caller graph for this function:

UInt8_t * df_DataBlock::GetPosition (  )  const

Returns a pointer to the beginning of the free space.

Used by the writer.

Exceptions:
ivd_InternalError(ie_DF_BLOCKFULL) 

Definition at line 129 of file df_datablock.cpp.

References ie_DF_BLOCKFULL, log_FUNC_m, m_block, m_closed, and m_used.

Referenced by df_BlockProxyWriter::Allocate(), df_BlockProxyWriter::AllocateRawBlock(), Close(), df_BlockProxyWriter::Go(), df_BlockProxyWriter::Move(), bea_FRI::ReadFRI(), blk_NetReader::Run(), blk_BufferReader::Run(), and bea_VolumeReader::Run().

                                         {
    if (m_closed) {
        log_FUNC_m(GetPosition);
        throw ivd_InternalError(ie_DF_BLOCKFULL, "Block is already closed.");
    }
    return (UInt8_t*)(m_block + m_used);
}

Here is the caller graph for this function:

UInt32_t df_DataBlock::GetUsedSize (  )  const [inline]

Definition at line 106 of file df.h.

Referenced by fsc_nsFSrecovery::FlushBlock(), df_Writer::FlushBlock(), and fsc_nsFSrecovery::~fsc_nsFSrecovery().

{ return m_used; };

Here is the caller graph for this function:

bool df_DataBlock::IsClosed (  )  const [inline]

Definition at line 100 of file df.h.

Referenced by df_Writer::GetNewBlock(), df_BlockManager::Release(), and df_MgrWriter::~df_MgrWriter().

{ return m_closed; };

Here is the caller graph for this function:

bool df_DataBlock::IsEmpty (  )  const [inline]

Definition at line 99 of file df.h.

Referenced by Close(), df_Unpacker::GetNextBlock(), bea_MigrationThread::Migrate(), df_BlockReader::ReleaseAndGetNextBlock(), and df_MgrWriter::~df_MgrWriter().

{ return (m_used == 0); };

Here is the caller graph for this function:

void df_DataBlock::Move ( UInt32_t  a_amount  ) 

Writing or reading data of a block is just increasing the amount of used space (a "virtual" pointer to the beginning of free space in a block).

Parameters:
a_amount The amount of data that has been written to the block.
Exceptions:
ivd_InternalError(ie_DF_BLOCKFULL) 
Warning:
Throws an exception if the data can't fit in the block. In fact, something has really gone wrong. Most probably the writing front end had already corrupted the memory buffer or reading front end had written over the block.

Definition at line 95 of file df_datablock.cpp.

References cmn_Num2Str(), GetFreeSize(), ie_DF_BLOCKFULL, log_FUNC_m, m_closed, and m_used.

Referenced by df_BlockProxyWriter::Allocate(), df_BlockProxyWriter::Go(), df_BlockProxyWriter::Move(), bea_FRI::ReadFRI(), blk_NetReader::Run(), blk_BufferReader::Run(), and bea_VolumeReader::Run().

                                         {
    if (m_closed) {
        log_FUNC_m(Move);
        throw ivd_InternalError(ie_DF_BLOCKFULL);
    }

    if (GetFreeSize() < a_amount) {
        log_FUNC_m(Move);
        throw ivd_InternalError(ie_DF_BLOCKFULL,
            "Free: " + cmn_Num2Str(GetFreeSize()) +
            " req: " + cmn_Num2Str(a_amount));
    }
    m_used += a_amount;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_DataBlock::Release (  ) 

Each reader must release the block after it is finished with it.

df_DataBlock::m_readers gets decreased at each call.

Last reader also re-opens data block (sets df_DataBlock::m_closed to false) and deletes it (with Delete()).

Warning:
Each reader may call release only once for each data block.
See also:
df_BlockManager::Release()

Definition at line 174 of file df_datablock.cpp.

References Delete(), log_FUNC_INT_m, m_blockID, m_closed, and m_numReaders.

Referenced by df_BlockManager::Release().

                           {
    log_FUNC_INT_m(Release);

    m_numReaders--;
    if (m_numReaders == 0) {
        m_closed = false;
        m_blockID = 0;
        Delete();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_DataBlock::SetBlockID ( UInt32_t  a_blkID  )  [inline]

Definition at line 102 of file df.h.

Referenced by bea_VolumeReader::Run().

{ m_blockID = a_blkID; };

Here is the caller graph for this function:

void df_DataBlock::Wipe (  ) 

Currently not used.

Wipe the whole contents of a block with zeroes?

Definition at line 193 of file df_datablock.cpp.

References Delete(), and log_FUNC_m.

                        {
    log_FUNC_m(Wipe);

    // Zero memory?
    Delete();
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class df_BlockManager [friend]

Definition at line 118 of file df.h.

friend class fsc_nsFSrecovery [friend]

Definition at line 119 of file df.h.


Member Data Documentation

Definition at line 75 of file df.h.

Definition at line 79 of file df.h.

Referenced by GetPosition().

Arbitrary block identification (e.g.

media position).

Definition at line 95 of file df.h.

Referenced by Release().

bool df_DataBlock::m_closed [private]

Writing to closed block is prevented.

Reopen at Delete(), which is called by Release() of the last back end.

Definition at line 89 of file df.h.

Referenced by Close(), GetFreeSize(), GetPosition(), Move(), and Release().

How many back-ends are left to finish processing this block.

Definition at line 92 of file df.h.

Referenced by Close(), and Release().

const UInt32_t df_DataBlock::m_size [private]

Size of the data block df_DataBlock::m_block.

Definition at line 82 of file df.h.

Referenced by GetFreeSize().

How much of the block space is already used (written or read by front end).

Definition at line 85 of file df.h.

Referenced by Delete(), GetFreeSize(), GetPosition(), and Move().


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