Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends

df_RecReader Class Reference
[IVD Data format.]

RecReader class is a BlockReader that parse record by record and for each call Proc<record>() method. More...

#include <df.h>

Inheritance diagram for df_RecReader:
Inheritance graph
[legend]
Collaboration diagram for df_RecReader:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 df_RecReader (df_BlockProxy *a_blockProxy, const cmn_UUID_t &a_volumeID=cmn_UUID_t(string("")))
 Default constructor.
virtual ~df_RecReader ()
UInt32_t Unpack (const UInt8_t *a_dataBlock_p, UInt32_t a_curBlockID)
UInt32_t Unpack ()
 return type of last read record.
void Abort ()
void Reset (bool a_resetBlockProxy=true, bool a_reparseBlockHdr=false)
bool IsNextRecordRaw () const
UInt32_t GetBlkSize () const
UInt32_t GetCurBlockUsed () const
UInt32_t GetCurBlockPos () const
UInt32_t GetBlockID () const
UInt32_t GetLastKnownGoodBlockID () const
bool IsCurBlockPtrNull ()
UInt32_t GetRecNum () const
UInt32_t GetBlockNum () const
const df_RecCmn_tPositionToRecord (UInt32_t a_recType)
 This function is intended for positioning to the first occurance of a specific record type inside the current block from the current position.
UInt32_t GetPrevRecType () const
virtual void ProcEndOfInput ()
 method ProcEndOfInput() must be called at the end of input when block per block parsing is used (migration, FRI check before wirtten to media.

Static Public Member Functions

static const df_RecCmn_tVerifiedRecCmn (const UInt8_t *a_buffer, UInt32_t &a_curRecNum, UInt32_t a_curBlockType, UInt32_t &a_prevRecType, UInt32_t a_lastGoodBlock)
static bool VerifyRecHeader (const UInt8_t *a_buffer, UInt32_t a_recType, UInt32_t a_recSeqNum, UInt32_t a_recSize)

Protected Member Functions

void SetNewDataBlock (const UInt8_t *a_dataBlock_p, UInt32_t a_curBlockID=0)
bool IsBlkPerBlkUnpacking ()
bool DoesBlockContainNewMigration ()
void SetFindMode ()

Protected Attributes

UInt32_t m_curRecType
UInt32_t m_prevRecType
UInt64_t m_curStreamLeft
 How much stream has to be read?
UInt32_t m_curStreamType
 follow members are used in derived classes.
string m_curStreamName
 UTF-8 name of the current stream.
const cmn_UUID_t m_volumeID
 parsing data of volume
bool m_isVolumeIDRegular
cmn_UUID_t m_currVolID
 set when FRI is read
bool m_ignoreCorruptedMetaData

Private Member Functions

virtual bool HandleDFError (const ivd_DFError &ie)
bool LocateNextFile ()
void GetNextRecord ()
void GetNextRawRecord ()
virtual void ProcBlock (const UInt8_t *a_dataBlock)
virtual void ProcRawBlock (const UInt8_t *a_dataBlock)
virtual void ProcRecFileHdr (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecFileEnd (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecBSStart (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecEmbData (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecRawData (const UInt8_t *a_block_p)
virtual void ProcRecBSEnd (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecFRIStart (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecFRIEnd (const df_RecCmn_t *a_recCmn_p)
virtual void ProcRecFRISpInfo (const df_RecCmn_t *a_recCmn_p)
virtual void PrepareDataStreamUnpacker ()
void FRIStartCheck (const df_RecCmn_t *a_recCmn_p)
void FRIEndCheck (const df_RecCmn_t *a_recCmn_p)

Private Attributes

 log_CLASSID_m
 Macro to add class name member s_className.
UInt32_t m_curBlockPos
UInt32_t m_recNum
auto_ptr< df_BlockProxym_blockProxy
const df_RecCmn_tm_recCmn_p
bool m_findMode
bool m_blkPerBlkUnpacking

Friends

IVD_DF_DECL_d ostream & operator<< (ostream &a_os, const df_RecReader &o)

Detailed Description

RecReader class is a BlockReader that parse record by record and for each call Proc<record>() method.

Author:
Dejan Volk Lupo, HERMES SoftLab
See also:
<reference>

Definition at line 1469 of file df.h.


Constructor & Destructor Documentation

df_RecReader::df_RecReader ( df_BlockProxy a_blockProxy,
const cmn_UUID_t a_volumeID = cmn_UUID_t(string("")) 
)

Default constructor.

Warning:
: a_blockProxy is stored in internal auto_ptr and thus destroyed automatically.

Definition at line 93 of file df_recreader.cpp.

References blk_FRI_c, cmn_GetEnvVariable(), cmn_StrUpperCase(), dbg_LOW, dbg_NORM, df_ignoreCorruptedMetaData_c(), log_DBG_m, log_FUNC_m, m_blockProxy, m_ignoreCorruptedMetaData, m_prevRecType, and rec_ExpectFRIStart_c.

    :
    m_curRecType(rec_NoRec_c),
    m_prevRecType(rec_NoRec_c),
    m_curStreamLeft(0),
    m_curStreamType(0),
    m_volumeID(a_volumeID),
    m_isVolumeIDRegular(!m_volumeID.IsNull()),
    m_currVolID(cmn_UUID_t(string(""))),
    m_ignoreCorruptedMetaData(false),
    m_curBlockPos(0),
    m_recNum(0),
    m_blockProxy(a_blockProxy),
    m_recCmn_p(NULL),
    m_findMode(false),
    m_blkPerBlkUnpacking(false) {

    log_FUNC_m(df_RecReader);

    string verifyPos = cmn_GetEnvVariable(df_ignoreCorruptedMetaData_c);
    if (verifyPos.length() > 0) {
        log_DBG_m(dbg_LOW, df_ignoreCorruptedMetaData_c << " = " << verifyPos << ".");
        cmn_StrUpperCase(verifyPos);

        if (verifyPos.compare("yes") == 0) {
            m_ignoreCorruptedMetaData = true;
        }
        else if (verifyPos.compare("no") == 0) {
            m_ignoreCorruptedMetaData = false;
        }
        else {
            log_DBG_m(dbg_LOW,
                df_ignoreCorruptedMetaData_c << " defined but contains unexpected contents.");
        }
    }

    if (m_blockProxy->IsBlkType(blk_FRI_c)) {
        log_DBG_m(dbg_NORM, "FRI Blocks --> Next expected record is FRIS.");
        m_prevRecType = rec_ExpectFRIStart_c;
    }
    log_DBG_m(dbg_NORM,  "df_RecReader obj: " << *this);
}

Here is the call graph for this function:

virtual df_RecReader::~df_RecReader (  )  [inline, virtual]

Definition at line 1482 of file df.h.

{};


Member Function Documentation

void df_RecReader::Abort (  ) 

Definition at line 479 of file df_recreader.cpp.

                        {
}

bool df_RecReader::DoesBlockContainNewMigration (  )  [protected]

Definition at line 763 of file df_recreader.cpp.

References blk_Data_c, GetBlkSize(), log_FUNC_m, m_blockProxy, NULL, rec_FileHdr_c, and VerifyRecHeader().

Referenced by df_FRIDistiller::ProcRecRawData().

                                                {
    log_FUNC_m(DoesBlockContainNewMigration);

    const UInt8_t *block_p = m_blockProxy->GetData();

    return (  (block_p != NULL)
           &&  m_blockProxy->VerifyBlockHeader(block_p,
                                 GetBlkSize(),
                                 1,  // first block in migration
                                 blk_Data_c,
                                 0)  // no continuous block
           &&  VerifyRecHeader(block_p + sizeof(df_BlockHeader_t),
                               rec_FileHdr_c,
                               1, // record seq number
                               sizeof(df_RecCmn_t) + sizeof(df_RecFile_t))
           );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_RecReader::FRIEndCheck ( const df_RecCmn_t a_recCmn_p  )  [private]

Definition at line 728 of file df_recreader.cpp.

References cmn_UUID_t::Clear(), dbg_DETAIL, dbg_LOW, df_RecFRIEnd_t::endPos, GetLastKnownGoodBlockID(), ie_DF_INVSEQ, cmn_UUID_t::IsNull(), log_DBG_m, log_FUNC_m, m_currVolID, ntoh(), df_RecFRIEnd_t::startPos, and df_RecFRIEnd_t::volID.

Referenced by Unpack().

                                                            {
    log_FUNC_m(FRIEndCheck);
    const df_RecFRIEnd_t *friEnd_p = df_GetSpecificRec<df_RecFRIEnd_t>(a_recCmn_p);

    log_DBG_m(dbg_LOW,
        endl <<
        "FRIEnd start pos : " << ntoh(friEnd_p->startPos) << endl <<
        "FRIEnd end pos : " << ntoh(friEnd_p->endPos) );

    if (m_currVolID.IsNull()) {
        ostringstream sstr;
        sstr << *this;
        throw ivd_DFError(
            ie_DF_INVSEQ,
            GetLastKnownGoodBlockID(),
            "Got FRIEnd record, but missing FRIStart record. ", sstr.str(), true);
    }

    if (friEnd_p->volID != m_currVolID) {
        ostringstream sstr;
        sstr << "(" << friEnd_p->volID << "!=" << m_currVolID << ") "
            << *this;

        throw ivd_DFError(
            ie_DF_INVSEQ,
            GetLastKnownGoodBlockID(),
            "FRIEnd.volID != FRIStart.volID. ",
            sstr.str(), true);
    }

    m_currVolID.Clear();
    log_DBG_m(dbg_DETAIL, " Clear m_currVolID " << m_currVolID);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_RecReader::FRIStartCheck ( const df_RecCmn_t a_recCmn_p  )  [private]

Definition at line 698 of file df_recreader.cpp.

References dbg_DETAIL, GetLastKnownGoodBlockID(), ie_DF_INVSEQ, cmn_UUID_t::IsNull(), log_DBG_m, log_FUNC_m, m_currVolID, m_isVolumeIDRegular, m_volumeID, and df_RecFRIStart_t::volID.

Referenced by Unpack().

                                                              {
    log_FUNC_m(FRIStartCheck);
    const df_RecFRIStart_t *friStart_p = df_GetSpecificRec<df_RecFRIStart_t>(a_recCmn_p);
    if (!m_currVolID.IsNull()) {
        ostringstream sstr;
        sstr << " new VolID : " << friStart_p->volID << endl
             << *this;
        throw ivd_DFError(
            ie_DF_INVSEQ,
            GetLastKnownGoodBlockID(),
            "Got second FRIStart record, missing FRIEnd.", sstr.str(), true);
    }

    m_currVolID   = friStart_p->volID;

    if (  m_isVolumeIDRegular
       && m_volumeID != m_currVolID) {
        ostringstream sstr;
        sstr << " new VolID : " << friStart_p->volID << endl
             << *this;
        throw ivd_DFError(
            ie_DF_INVSEQ,
            GetLastKnownGoodBlockID(),
            "Got FRIStart record with different VolID then expected. ", sstr.str(), true);
    }

    log_DBG_m(dbg_DETAIL, " Set m_currVolID " << m_currVolID);
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t df_RecReader::GetBlkSize (  )  const [inline]
UInt32_t df_RecReader::GetBlockID (  )  const [inline]
UInt32_t df_RecReader::GetBlockNum (  )  const [inline]

Definition at line 1565 of file df.h.

Referenced by df_FRIDistiller::HandleDFError(), df_FRIDistiller::ProcBlock(), and df_Filter::ProcBlock().

{ return m_blockProxy->GetBlockNum(); };

Here is the caller graph for this function:

UInt32_t df_RecReader::GetCurBlockPos (  )  const [inline]

Definition at line 1560 of file df.h.

Referenced by df_Filter::CopyRecord().

{ return m_curBlockPos; };

Here is the caller graph for this function:

UInt32_t df_RecReader::GetCurBlockUsed (  )  const [inline]

Definition at line 1559 of file df.h.

Referenced by df_Filter::CopyRecord().

{ return m_blockProxy->GetCurBlockUsed(); };

Here is the caller graph for this function:

UInt32_t df_RecReader::GetLastKnownGoodBlockID (  )  const [inline]

Definition at line 1562 of file df.h.

Referenced by FRIEndCheck(), FRIStartCheck(), GetNextRecord(), PrepareDataStreamUnpacker(), df_SplitInfoUnpacker::ProcEndOfInput(), df_SplitInfoUnpacker::ProcRecFileEnd(), and Unpack().

{ return m_blockProxy->GetLastKnownGoodBlockID();};

Here is the caller graph for this function:

void df_RecReader::GetNextRawRecord (  )  [private]

Definition at line 650 of file df_recreader.cpp.

References GetBlkSize(), IsCurBlockPtrNull(), m_blockProxy, m_curBlockPos, m_curRecType, m_prevRecType, ProcRawBlock(), rec_Data_c, and rec_NoRec_c.

Referenced by GetNextRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

void df_RecReader::GetNextRecord (  )  [private]

Definition at line 598 of file df_recreader.cpp.

References cmn_Num2Str(), dbg_DETAIL, GetBlkSize(), GetLastKnownGoodBlockID(), GetNextRawRecord(), ie_DF_INV_BLK, IsCurBlockPtrNull(), IsNextRecordRaw(), log_DBG_m, log_FUNC_m, m_blockProxy, m_curBlockPos, m_curRecType, m_prevRecType, m_recCmn_p, m_recNum, ntoh(), ProcBlock(), rec_Data_c, rec_NoRec_c, df_RecCmn_t::size, df_RecCmn_t::type, and VerifiedRecCmn().

Referenced by Unpack().

                                 {

    log_FUNC_m(GetNextRecord);

    if (m_curBlockPos == 0 && m_curRecType == rec_Data_c) {
        m_curBlockPos = GetBlkSize();
        return;
    }

    if ( IsNextRecordRaw() ) {
        log_DBG_m(dbg_DETAIL, "Next record is raw block.");
        GetNextRawRecord();
        return;
    }

    if (   m_curBlockPos >= m_blockProxy->GetCurBlockUsed()
        || IsCurBlockPtrNull()) {
        m_blockProxy->GetNextBlock();

        m_curBlockPos = sizeof(df_BlockHeader_t);
        m_curRecType = rec_NoRec_c;

        if (IsCurBlockPtrNull()) {
            return;
        };
        ProcBlock(m_blockProxy->GetData());
    };

    m_recCmn_p = VerifiedRecCmn(
        m_blockProxy->GetData() + m_curBlockPos,
        m_recNum,
        m_blockProxy->GetBlkType(),
        m_prevRecType,
        GetLastKnownGoodBlockID() );

    m_curRecType     = m_recCmn_p->type;
    m_prevRecType    = m_curRecType;
    m_curBlockPos   += ntoh(m_recCmn_p->size);

    // if next record position is above block used size -> very strange!
    if (m_curBlockPos > m_blockProxy->GetCurBlockUsed()) {
        log_FUNC_m(GetNextRecord);
        throw ivd_DFError(ie_DF_INV_BLK,
            GetLastKnownGoodBlockID(),
            "Block Used=" + cmn_Num2Str(m_blockProxy->GetCurBlockUsed()) +
            ", Record End=" + cmn_Num2Str(m_curBlockPos));
    }
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t df_RecReader::GetPrevRecType (  )  const [inline]

Definition at line 1569 of file df.h.

Referenced by i_FSC_i::InsertSplitFromFRIBlock().

{ return m_prevRecType; };

Here is the caller graph for this function:

UInt32_t df_RecReader::GetRecNum (  )  const [inline]

Definition at line 1564 of file df.h.

{ return m_recNum; };

virtual bool df_RecReader::HandleDFError ( const ivd_DFError ie  )  [inline, private, virtual]

Reimplemented in df_FRIDistiller.

Definition at line 1578 of file df.h.

Referenced by Unpack().

{ return false; };

Here is the caller graph for this function:

bool df_RecReader::IsBlkPerBlkUnpacking (  )  [inline, protected]

Definition at line 1575 of file df.h.

Referenced by Unpack().

{ return m_blkPerBlkUnpacking; };

Here is the caller graph for this function:

bool df_RecReader::IsCurBlockPtrNull (  )  [inline]

Definition at line 1563 of file df.h.

Referenced by GetNextRawRecord(), GetNextRecord(), LocateNextFile(), and Unpack().

{ return m_blockProxy->GetData() == NULL; };

Here is the caller graph for this function:

bool df_RecReader::IsNextRecordRaw (  )  const

Definition at line 195 of file df_recreader.cpp.

References GetBlkSize(), m_blockProxy, m_curBlockPos, and m_curStreamLeft.

Referenced by GetNextRecord(), and df_Filter::NextInputBlock().

                                         {
    if (m_blockProxy->IsEndOfBlock(m_curBlockPos) &&
        m_curStreamLeft >= GetBlkSize() ) {

        return true;
    }
    else {
        return false;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool df_RecReader::LocateNextFile (  )  [private]

Definition at line 668 of file df_recreader.cpp.

References dbg_LOW, GetBlockID(), IsCurBlockPtrNull(), log_DBG_m, log_FUNC_m, m_blockProxy, m_findMode, NULL, PositionToRecord(), and rec_FileHdr_c.

Referenced by Unpack().

                                  {
    log_FUNC_m(LocateNextFile);

    if (IsCurBlockPtrNull()) {
        // No more input data.
        return false;
    }

    if (m_blockProxy->GetFindMode()) {
        // Still in find mode: block header not yet found
        m_blockProxy->GetNextBlock();
        return false;
    }

    const df_RecCmn_t* pos = PositionToRecord(rec_FileHdr_c);
    if (pos != NULL) {
        log_DBG_m(dbg_LOW, "File header found on position: " << GetBlockID());
        m_findMode = false;
        return true;
    }
    else {
        // turn block proxy back into find mode
        m_blockProxy->SetFindMode(true);
        m_blockProxy->GetNextBlock();
    }
    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const df_RecCmn_t * df_RecReader::PositionToRecord ( UInt32_t  a_recType  ) 

This function is intended for positioning to the first occurance of a specific record type inside the current block from the current position.

Most useful to position to the beginning of a file (rec_FileHdr_c).

Returns:
pointer to the record
Return values:
NULL if the record is not found

Definition at line 170 of file df_recreader.cpp.

References log_FUNC_m, m_blockProxy, m_curBlockPos, m_curRecType, m_prevRecType, m_recCmn_p, m_recNum, ntoh(), df_RecCmn_t::seqNum, df_RecCmn_t::size, and df_RecCmn_t::type.

Referenced by LocateNextFile(), and df_Filter::ProcBlock().

                                                                    {
    log_FUNC_m(PositionToRecord);

    UInt32_t used = m_blockProxy->GetCurBlockUsed();
    while (m_curBlockPos < used) {

        m_recCmn_p = reinterpret_cast<const df_RecCmn_t*>(
            m_blockProxy->GetData() + m_curBlockPos);

        if (m_recCmn_p->type == a_recType) {
            m_prevRecType    = m_curRecType;
            m_curRecType     = m_recCmn_p->type;
            return m_recCmn_p;
        }
        // recNum will be set and checked by GetNextRecord()
        m_recNum         = ntoh(m_recCmn_p->seqNum);
        m_curRecType     = m_recCmn_p->type;
        m_curBlockPos   += ntoh(m_recCmn_p->size);
    };
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_RecReader::PrepareDataStreamUnpacker (  )  [private, virtual]

Definition at line 433 of file df_recreader.cpp.

References cmn_Num2Str(), dbg_DETAIL, df_RF_SPLITTED, df_RecCmn_t::flags, GetLastKnownGoodBlockID(), df_RecCmn_t::GetVarDataNet(), ie_DF_INVSTREAMFMT, ie_IMPOSSIBLE, log_DBG_m, log_FUNC_m, m_curStreamLeft, m_curStreamName, m_curStreamType, m_recCmn_p, ntoh(), df_RecByteStreamStart_t::streamName, df_RecByteStreamStart_t::streamOffset, df_RecByteStreamStart_t::streamSize, df_RecByteStreamStart_t::streamSplitSize, and df_RecByteStreamStart_t::streamType.

Referenced by Unpack().

                                             {
    log_FUNC_m(PrepareDataStreamUnpacker);

    const df_RecByteStreamStart_t *bss_p
        = df_GetSpecificRec<df_RecByteStreamStart_t>(m_recCmn_p);

    m_curStreamType = ntoh(bss_p->streamType);
    UInt64_t streamSplitSize = ntoh(bss_p->streamSplitSize);
    UInt64_t streamSize      = ntoh(bss_p->streamSize);
    UInt64_t streamOffset    = ntoh(bss_p->streamOffset);

// NOTE!  m_curStreamLeft could be changed by inherited class in ProcRecBSStart() method
    if (  streamSplitSize > 0
       || ntoh(m_recCmn_p->flags) & df_RF_SPLITTED) {
        if (streamSplitSize > streamSize - streamOffset) {
            log_MARKLINE_m;
            throw ivd_InternalError(
                ie_IMPOSSIBLE, "streamSplitSize > streamSize");
        }
        m_curStreamLeft = streamSplitSize;
    }
    else {
        m_curStreamLeft = streamSize - streamOffset;
    }

    m_curStreamName.assign(
        m_recCmn_p->GetVarDataNet(bss_p->streamName));

    log_DBG_m(dbg_DETAIL, "Stream: Size=" << streamSize
                       << ", Offset=" << streamOffset
                       << ", SplitSize=" << streamSplitSize
                       << ", Name = \'" << m_curStreamName << "\'");

    log_DBG_m(dbg_DETAIL, "Stream left=" << m_curStreamLeft);

    if (m_curStreamType == 0) {
        throw ivd_DFError(ie_DF_INVSTREAMFMT,
            GetLastKnownGoodBlockID(),
            "BSStart, but invalid streamType:"
            " strType=" + cmn_Num2Str(m_curStreamType) +
            ", strName=" + m_curStreamName +
            ", strLeft=" + cmn_Num2Str(m_curStreamLeft));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void df_RecReader::ProcBlock ( const UInt8_t a_dataBlock  )  [inline, private, virtual]

Reimplemented in df_FRIDistiller, and df_Filter.

Definition at line 1586 of file df.h.

Referenced by GetNextRecord(), and SetNewDataBlock().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcEndOfInput (  )  [inline, virtual]

method ProcEndOfInput() must be called at the end of input when block per block parsing is used (migration, FRI check before wirtten to media.

).

Reimplemented in df_FRIDistiller, df_SplitInfoUnpacker, and df_Filter.

Definition at line 1601 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRawBlock ( const UInt8_t a_dataBlock  )  [inline, private, virtual]

Reimplemented in df_FRIDistiller.

Definition at line 1587 of file df.h.

Referenced by GetNextRawRecord(), and SetNewDataBlock().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecBSEnd ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Reimplemented in hsm_IVDFSRecoverer, hsm_Recall, df_FRIDistiller, df_SplitInfoUnpacker, and df_Filter.

Definition at line 1594 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecBSStart ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Reimplemented in hsm_IVDFSRecoverer, hsm_Recall, df_FRIDistiller, df_SplitInfoUnpacker, and df_Filter.

Definition at line 1591 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecEmbData ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Reimplemented in hsm_IVDFSRecoverer, hsm_Recall, df_FRIDistiller, df_SplitInfoUnpacker, and df_Filter.

Definition at line 1592 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecFileEnd ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Reimplemented in hsm_IVDFSRecoverer, hsm_Recall, df_FRIDistiller, df_SplitInfoUnpacker, and df_Filter.

Definition at line 1590 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecFileHdr ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Reimplemented in hsm_IVDFSRecoverer, hsm_Recall, df_FRIDistiller, df_SplitInfoUnpacker, and df_Filter.

Definition at line 1589 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecFRIEnd ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Reimplemented in df_SplitInfoUnpacker.

Definition at line 1596 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecFRISpInfo ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Reimplemented in df_SplitInfoUnpacker.

Definition at line 1597 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecFRIStart ( const df_RecCmn_t a_recCmn_p  )  [inline, private, virtual]

Definition at line 1595 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

virtual void df_RecReader::ProcRecRawData ( const UInt8_t a_block_p  )  [inline, private, virtual]

Reimplemented in hsm_IVDFSRecoverer, hsm_Recall, df_FRIDistiller, df_SplitInfoUnpacker, and df_Filter.

Definition at line 1593 of file df.h.

Referenced by Unpack().

{};

Here is the caller graph for this function:

void df_RecReader::Reset ( bool  a_resetBlockProxy = true,
bool  a_reparseBlockHdr = false 
)

Definition at line 140 of file df_recreader.cpp.

References log_FUNC_m, m_blockProxy, m_curBlockPos, m_curRecType, m_curStreamLeft, m_curStreamType, m_prevRecType, m_recCmn_p, m_recNum, and rec_NoRec_c.

Referenced by df_FRIDistiller::HandleDFError(), and df_FRIDistiller::ProcRecRawData().

                                                                       {

    log_FUNC_m(Reset);

    m_recCmn_p = NULL,
    m_curRecType = rec_NoRec_c,
    m_prevRecType = rec_NoRec_c,
    m_curBlockPos = sizeof(df_BlockHeader_t),
    m_recNum = 0,
    m_curStreamLeft = 0,
    m_curStreamType = 0;

    if (a_resetBlockProxy) {
        m_blockProxy->Reset();
        if (a_reparseBlockHdr) {
            m_blockProxy->ParseBlockHeader();
        }
    }
}

Here is the caller graph for this function:

void df_RecReader::SetFindMode (  )  [protected]

Definition at line 233 of file df_recreader.cpp.

References log_FUNC_m, m_blockProxy, and m_findMode.

Referenced by df_FRIDistiller::HandleDFError().

                               {
    log_FUNC_m(SetFindMode);

    //
    // When in find mode, record reader attempts to position to the next
    // file record. It does not throw data format exceptions.
    //
    // When the file record is found, the find mode is automatically reset.
    //
    m_blockProxy->SetFindMode(true);
    m_blockProxy->GetNextBlock();
    m_findMode = true;
}

Here is the caller graph for this function:

void df_RecReader::SetNewDataBlock ( const UInt8_t a_dataBlock_p,
UInt32_t  a_curBlockID = 0 
) [protected]

Definition at line 209 of file df_recreader.cpp.

References dbg_DETAIL, GetBlkSize(), log_DBG_m, log_FUNC_m, m_blockProxy, m_curBlockPos, m_curRecType, m_curStreamLeft, ProcBlock(), ProcRawBlock(), and rec_Data_c.

Referenced by Unpack().

                           {

    log_FUNC_m(SetNewDataBlock);

    log_DBG_m(dbg_DETAIL,
        "left: " << m_curStreamLeft << " bs: " << GetBlkSize() );

    if (m_curStreamLeft >= GetBlkSize()) {
        m_blockProxy->SetPtrToDataBlock(a_dataBlock_p, a_curBlockID, true);
        m_curRecType = rec_Data_c;
        m_curBlockPos = 0;
        ProcRawBlock(a_dataBlock_p);
    }
    else {
        m_blockProxy->SetPtrToDataBlock(a_dataBlock_p, a_curBlockID, false);
        m_curBlockPos = sizeof(df_BlockHeader_t);
        ProcBlock(a_dataBlock_p);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t df_RecReader::Unpack (  ) 

return type of last read record.

Used in FSC update. to check rec_FRIEnd_c

Definition at line 257 of file df_recreader.cpp.

References blk_FRI_c, cmn_Num2Str(), df_RecEmbeddedData_t::data, dbg_DETAIL, dbg_LOW, dbg_NORM, df_ST_ALTDATA, df_ST_META, FRIEndCheck(), FRIStartCheck(), GetBlkSize(), GetLastKnownGoodBlockID(), GetNextRecord(), HandleDFError(), ie_DF_INVSTREAMFMT, IsBlkPerBlkUnpacking(), IsCurBlockPtrNull(), LocateNextFile(), log_DBG_m, log_ERR_m, log_FUNC_m, m_blockProxy, m_curRecType, m_curStreamLeft, m_curStreamName, m_curStreamType, m_findMode, m_ignoreCorruptedMetaData, m_prevRecType, m_recCmn_p, m_recNum, ntoh(), PrepareDataStreamUnpacker(), ProcEndOfInput(), ProcRecBSEnd(), ProcRecBSStart(), ProcRecEmbData(), ProcRecFileEnd(), ProcRecFileHdr(), ProcRecFRIEnd(), ProcRecFRISpInfo(), ProcRecFRIStart(), ProcRecRawData(), rec_BSEnd_c, rec_BSStart_c, rec_Data_c, rec_EmbData_c, rec_FileEnd_c, rec_FileHdr_c, rec_FRIEnd_c, rec_FRISpInfo_c, rec_FRIStart_c, rec_NoRec_c, ivd_VarData_t::size, df_RecByteStreamEnd_t::streamSize, df_RecByteStreamEnd_t::streamType, df_RecEmbeddedData_t::streamType, and df_RecCmn_t::type.

Referenced by Unpack().

                              {
    log_FUNC_m(Unpack);

    // This loop exits by break when the input stream runs out.
    while (true) {
        try {
            if (m_findMode) {
                // In find mode we try to position to the next
                // file header.
                if (!LocateNextFile()) {
                    // File not yet found
                    if (IsCurBlockPtrNull()) {
                        // end of input stream
                        // exit while loop
                        break;
                    }
                    else {
                        // file header not found yet, but
                        // there's more input available
                        continue;
                    }
                }
            }

            GetNextRecord();

            if (m_curRecType == rec_NoRec_c) {
                // NOTE: rec_NoRec_c is the iternal indicator
                //       that the input stream is exhausted.
                if ( ! IsBlkPerBlkUnpacking() ) {
                    ProcEndOfInput();
                }
                // exit while loop
                break;
            }
            else {
                string recType(
                    reinterpret_cast<char*>(&(m_curRecType)),
                    sizeof(m_curRecType) );
                log_DBG_m(dbg_DETAIL, "RECORD TYPE: " << recType);
            }

            if (m_curRecType == rec_FileHdr_c) {
                ProcRecFileHdr(m_recCmn_p);
            }
            else if (m_curRecType == rec_FileEnd_c) {
                ProcRecFileEnd(m_recCmn_p);
            }
            else if (m_curRecType == rec_BSStart_c) {
                PrepareDataStreamUnpacker();
                ProcRecBSStart(m_recCmn_p);
            }
            else if (m_curRecType == rec_EmbData_c) {
                const df_RecEmbeddedData_t *eData_p
                    = df_GetSpecificRec<df_RecEmbeddedData_t>(m_recCmn_p);

                if (m_curStreamType != 0) {
                    if (ntoh(eData_p->streamType) != m_curStreamType) {
                        log_FUNC_m(Unpack);
                        throw ivd_DFError(ie_DF_INVSTREAMFMT,
                            GetLastKnownGoodBlockID(),
                            "EDta, but not from current stream:"
                            " strType=" + cmn_Num2Str(m_curStreamType) +
                            ", strName=" + m_curStreamName +
                            ", strLeft=" + cmn_Num2Str(m_curStreamLeft));
                    }
                    UInt32_t embSize = ntoh(eData_p->data.size);
                    if (embSize == 0 || embSize > m_curStreamLeft) {
                        log_FUNC_m(Unpack);
                        throw ivd_DFError(ie_DF_INVSTREAMFMT,
                            GetLastKnownGoodBlockID(),
                            "EDta - less/more embedded than expected:"
                            " embSize=" + cmn_Num2Str(embSize) +
                            ", strLeft=" + cmn_Num2Str(m_curStreamLeft));
                    }

                    m_curStreamLeft -= embSize;
                }
                ProcRecEmbData(m_recCmn_p);
            }
            else if (m_curRecType == rec_Data_c) {
                m_curStreamLeft    -= GetBlkSize();
                ProcRecRawData(m_blockProxy->GetData());
            }
            else if (m_curRecType == rec_BSEnd_c) {
                const df_RecByteStreamEnd_t *bse_p
                    = df_GetSpecificRec<df_RecByteStreamEnd_t>(m_recCmn_p);

                if (m_curStreamType != 0) {
                    if (ntoh(bse_p->streamType) != m_curStreamType) {
                        log_FUNC_m(Unpack);
                        throw ivd_DFError(ie_DF_INVSTREAMFMT,
                            GetLastKnownGoodBlockID(),
                            string("BSEnd, but not from current stream:"
                            " Stream info : "
                            " Name=") + m_curStreamName
                        + ", got Type=" + cmn_Num2Str(ntoh(bse_p->streamType))
                        + ", expected Type=" + cmn_Num2Str(m_curStreamType)
                        + ", Left=" + cmn_Num2Str(m_curStreamLeft)
                        + ", Size=" + cmn_Num2Str(ntoh(bse_p->streamSize)));
                    }
                    /* Only BSS and BSE is stored in FRI at alternate data stream.
                    But older stream contain ADS data too.
                    So m_stremLeft could be as large as whole ADS.
                    */
                    if (m_curStreamLeft > 0
                        && !(   m_curStreamType == df_ST_ALTDATA           // we do not have ADS
                            && m_blockProxy->IsBlkType(blk_FRI_c)          // or we do not have a FRI block
                            && m_curStreamLeft == ntoh(bse_p->streamSize)  // or no data written
                            )
                    ) {
                        log_FUNC_m(Unpack);
                        if ( m_ignoreCorruptedMetaData && (m_curStreamType == df_ST_META)) {
                            log_ERR_m( "Incomplete meta data stream ignored. "
                                    << " FRI Record SeqNum=" << m_recNum
                                    << " this is the bad record. "
                                    << "Search around this in ivd_df --FRI --recfull --rechdr output."
                                    << " Stream info : Name=" << m_curStreamName
                                    << ", Type=" << cmn_Num2Str(m_curStreamType)
                                    << ", Left=" << cmn_Num2Str(m_curStreamLeft)
                                    << ", Size=" << cmn_Num2Str(ntoh(bse_p->streamSize)));
                        }
                        else {
                            throw ivd_DFError(ie_DF_INVSTREAMFMT,
                                GetLastKnownGoodBlockID(),
                                "BSEnd, but we expect more data."
                                " Stream info : "
                                " Name=" + m_curStreamName +
                            + ", Type=" + cmn_Num2Str(m_curStreamType)
                            + ", Left=" + cmn_Num2Str(m_curStreamLeft)
                            + ", Size=" + cmn_Num2Str(ntoh(bse_p->streamSize)));
                        }
                    }

                }
                ProcRecBSEnd(m_recCmn_p);
                m_curStreamLeft   = 0;
                m_curStreamType   = 0;
                m_curStreamName.clear();
            }
            else if (m_curRecType == rec_FRIStart_c) {
                FRIStartCheck(m_recCmn_p);
                ProcRecFRIStart(m_recCmn_p);
            }
            else if (m_curRecType == rec_FRIEnd_c) {
                FRIEndCheck(m_recCmn_p);
                ProcRecFRIEnd(m_recCmn_p);
            }
            else if (m_curRecType == rec_FRISpInfo_c) {
                ProcRecFRISpInfo(m_recCmn_p);
            }
            else {
                log_FUNC_m(Unpack);
                throw ivd_DFError(
                    ie_DF_INVSTREAMFMT,
                    GetLastKnownGoodBlockID(),
                    "Unknown record type:"
                    "strType=" + cmn_Num2Str(m_recCmn_p->type));
            }
        }
        catch(const ivd_DFError& ie) {
            if (HandleDFError(ie)) {
                log_DBG_m(dbg_LOW, "DF exception handled. Continue processing data.");
                //continue;
            }
            else {
                log_DBG_m(dbg_NORM, "DF exception not handled. Re-throwing.");
                throw;
            }
        }
    }// while (true)

    return m_prevRecType;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t df_RecReader::Unpack ( const UInt8_t a_dataBlock_p,
UInt32_t  a_curBlockID 
)

Definition at line 249 of file df_recreader.cpp.

References log_FUNC_A_m, m_blkPerBlkUnpacking, SetNewDataBlock(), and Unpack().

Referenced by i_FSC_i::CheckWithMedVolume(), i_HSM_i::EfficientRecall(), i_FSC_i::FSCRecovery(), i_FSC_i::InsertSplitFromFRIBlock(), and bea_RecallThread::Recall().

                                                                                 {
    log_FUNC_A_m(Unpack, "id=" << a_curBlockID);
    m_blkPerBlkUnpacking = true;
    SetNewDataBlock(a_dataBlock_p, a_curBlockID);
    return Unpack();
}

Here is the call graph for this function:

Here is the caller graph for this function:

const df_RecCmn_t * df_RecReader::VerifiedRecCmn ( const UInt8_t a_buffer,
UInt32_t a_curRecNum,
UInt32_t  a_curBlockType,
UInt32_t a_prevRecType,
UInt32_t  a_lastGoodBlock 
) [static]

Definition at line 483 of file df_recreader.cpp.

References cmn_Num2Str(), df_IsValidPredecessor(), df_RF_CONTINUED, df_RecCmn_t::flags, ie_DF_INVRECCOOKIE, ie_DF_INVRECSEQNUM, ie_DF_INVSEQ, IsRecordCookie(), log_FUNC_m, df_RecCmn_t::magicCookie, ntoh(), rec_NoRec_c, df_RecCmn_t::seqNum, and df_RecCmn_t::type.

Referenced by GetNextRecord(), and bea_FRI::ReadFRIStart().

                                     {


    const df_RecCmn_t* recCmn_p =
        reinterpret_cast<const df_RecCmn_t*>(a_buffer);

    // -- CHECKING MAGIC COOKIE --

    if (!IsRecordCookie(recCmn_p->magicCookie)) {
        log_FUNC_m(VerifiedRecCmn);
        throw ivd_DFError(
            ie_DF_INVRECCOOKIE,
            a_lastGoodBlock,
            "Got=" +
            string((const char*)recCmn_p->magicCookie,
                   sizeof(recCmn_p->magicCookie)) );
    };

    // -- CHECKING SEQUENCE NUMBER --

    UInt32_t curRecNum      = ntoh(recCmn_p->seqNum);
    UInt32_t curRecFlags    = ntoh(recCmn_p->flags);
    // if this is first record - set recNum appropriately
    if (a_curRecNum == 0) {
        a_curRecNum = curRecNum;
    }
    else if (curRecNum == 1) { // start of new migration: reset counter
        a_curRecNum = 1;
        a_prevRecType = rec_NoRec_c;
    }
    else if ( (curRecFlags & df_RF_CONTINUED) != 0) {
        // Split in the middle of the volume.
        // Reset block number and type
        a_curRecNum = curRecNum;
        a_prevRecType = rec_NoRec_c;
    }
    else {
        a_curRecNum++;
        if (curRecNum != a_curRecNum) {
            log_FUNC_m(VerifiedRecCmn);
            throw ivd_DFError(
                ie_DF_INVRECSEQNUM,
                a_lastGoodBlock,
                "Got=" + cmn_Num2Str(curRecNum) +
                ", expected=" + cmn_Num2Str(a_curRecNum));
        }
    };

    // -- CHECKING RECORD TYPE SEQUENCE --

    // NOTE: No ntoh necessary!
    UInt32_t curRecType = recCmn_p->type;

    if (    a_prevRecType != rec_NoRec_c
        &&  !df_IsValidPredecessor(a_curBlockType, a_prevRecType, curRecType)) {

        string blockType = string(
            reinterpret_cast<const char*>(&a_curBlockType),
            sizeof(a_curBlockType));

        string prevStr = string(
            reinterpret_cast<const char*>(&a_prevRecType),
            sizeof(a_prevRecType));

        string curStr =
            (recCmn_p->type == rec_NoRec_c)
            ? string("NULL REC")
            : string((const char*)(&curRecType), sizeof(curRecType));

        ostringstream sstr;
        sstr << "Record " << prevStr
             << " can't be followed by " << curStr
             << " Block Type " << blockType
             << " a_curRecNum = " << a_curRecNum
             << *recCmn_p;

        log_FUNC_m(VerifiedRecCmn);
        throw ivd_DFError(ie_DF_INVSEQ, a_lastGoodBlock, sstr.str());
    };

    a_prevRecType = curRecType;

    return recCmn_p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool df_RecReader::VerifyRecHeader ( const UInt8_t a_buffer,
UInt32_t  a_recType,
UInt32_t  a_recSeqNum,
UInt32_t  a_recSize 
) [static]

Definition at line 574 of file df_recreader.cpp.

References df_RECVERSION_SIZE_d, df_verMaj_c, df_verMin_c, df_RecCmn_t::flags, IsRecordCookie(), log_FUNC_m, df_RecCmn_t::magicCookie, ntoh(), df_RecCmn_t::reserved1, df_RecCmn_t::seqNum, df_RecCmn_t::size, df_RecCmn_t::type, df_RecCmn_t::verMajor, and df_RecCmn_t::verMinor.

Referenced by DoesBlockContainNewMigration(), and ParseBlock().

                               {

    log_FUNC_m(VerifyRecHeader);

    const df_RecCmn_t* recCmn_p =
        reinterpret_cast<const df_RecCmn_t*>(a_buffer);

    return (  (memcmp(&recCmn_p->verMajor, df_verMaj_c, df_RECVERSION_SIZE_d) <= 0)
           && (memcmp(&recCmn_p->verMinor, df_verMin_c, df_RECVERSION_SIZE_d) <= 0)
           &&  IsRecordCookie(recCmn_p->magicCookie)
           && (recCmn_p->type         == a_recType)
           && (ntoh(recCmn_p->flags)  <  df_RF_SENTINEL)
           && (ntoh(recCmn_p->seqNum) == a_recSeqNum)
           && (ntoh(recCmn_p->size)   >= a_recSize)
           && (recCmn_p->reserved1[0] == 0)
           && (recCmn_p->reserved1[1] == 0)
           );
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

IVD_DF_DECL_d ostream& operator<< ( ostream &  a_os,
const df_RecReader o 
) [friend]

Definition at line 60 of file df_recreader.cpp.

                                                           {
    a_os
        << "m_curRecType:"    << o.m_curRecType << endl
        << "m_prevRecType:"   << o.m_prevRecType << endl
        << "m_curBlockPos:"   << o.m_curBlockPos << endl
        << "m_recNum:"        << o.m_recNum << endl
        << "m_curStreamLeft:" << o.m_curStreamLeft << endl
        << "m_curStreamType:" << o.m_curStreamType << endl
        << "m_findMode:" << boolalpha << o.m_findMode << endl
        << "m_blkPerBlkUnpacking:" << boolalpha << o.m_blkPerBlkUnpacking << endl
        << "m_currVolID:" << o.m_currVolID << endl
        << "m_volumeID:" << o.m_volumeID << endl
        << "m_isVolumeIDRegular:" << boolalpha << o.m_isVolumeIDRegular << endl
        << "m_ignoreCorruptedMetaData:" << boolalpha << o.m_ignoreCorruptedMetaData << endl;

    if (o.m_recCmn_p == NULL) {
        a_os << ", m_recCmn_p : NULL" << endl;
    }
    else {
        a_os << ", m_recCmn_p : " << *(o.m_recCmn_p);
    }

    if (o.m_blockProxy.get() != NULL) {
        a_os << *(o.m_blockProxy); // it is auto pointer
    }
    else {
        a_os << "Block proxy: NULL." << endl;
    }

    return a_os;
}


Member Data Documentation

Macro to add class name member s_className.

Reimplemented in hsm_IVDFSRecoverer, hsm_Recall, df_FRIDistiller, df_SplitInfoUnpacker, df_Filter, fsc_FRIblockUnpacker, fsc_FRIunpacker, and fsc_VolumeCheck.

Definition at line 1512 of file df.h.

Definition at line 1525 of file df.h.

Referenced by operator<<(), and Unpack().

set when FRI is read

Definition at line 1504 of file df.h.

Referenced by FRIEndCheck(), FRIStartCheck(), operator<<(), and df_SplitInfoUnpacker::ProcEndOfInput().

string df_RecReader::m_curStreamName [protected]
bool df_RecReader::m_findMode [private]

Definition at line 1522 of file df.h.

Referenced by LocateNextFile(), operator<<(), SetFindMode(), and Unpack().

Definition at line 1508 of file df.h.

Referenced by df_RecReader(), operator<<(), df_SplitInfoUnpacker::ProcRecBSEnd(), and Unpack().

Definition at line 1501 of file df.h.

Referenced by FRIStartCheck(), and operator<<().

Definition at line 1519 of file df.h.

Referenced by GetNextRecord(), operator<<(), PositionToRecord(), Reset(), and Unpack().

parsing data of volume

Definition at line 1500 of file df.h.

Referenced by FRIStartCheck(), and operator<<().


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