Public Member Functions | Public Attributes | Private Attributes | Friends

fio_JourHandle Class Reference
[Classes for large file i/o, relative file, and DataBase]

#include <fio_JourHandle.h>

Collaboration diagram for fio_JourHandle:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fio_JourHandle (fio_JourFile *a_jouFile_p, ivd_FilePosition_t a_startPosition, ivd_FileBufSize_t a_transSize)
 ~fio_JourHandle ()
ivd_TransNumber_t GetTransNumber ()
ivd_TransNumber_t GetLastDBTransNum ()
ivd_FileBufSize_t GetTransSize ()
fio_JourFileGetJourFile ()
ivd_FilePosition_t GetStartPosition ()
ivd_FilePosition_t GetNextStartPosition ()
void SetTransSize (ivd_FileBufSize_t a_size)
void SetNextStartPosition (ivd_FilePosition_t a_pos)
void AddStartPosition (ivd_FileBufSize_t a_size)
void SetStartPosition (ivd_FilePosition_t a_pos)
void SetStartPositionIsCurrent ()
void SetTransNumber (ivd_TransNumber_t a_transNum)
void SetLastDBTransNum (ivd_TransNumber_t a_lastDBtransNum)
void Release ()
bool GetReleased ()
ivd_FilePosition_t GetLimitPosition ()
ivd_FileID_t GetFileID ()
void JourWrite (const void *a_buffer, ivd_FileBufSize_t a_size)
void JourFlush (const void *a_buffer, ivd_FileBufSize_t a_size)
int JourRead (void *a_buffer, ivd_FileBufSize_t a_size)
int JourSkip (ivd_FileBufSize_t a_offset)
 Skip a_offset bytes in file.
ivd_FilePosition_t FindNextTransHdr (bool a_repair)
 When current transaction is damaged then find nex one set repaire argument to TRUE when need update of damege trans header.
void JourSync ()
void ResetPosition ()
ivd_FilePosition_t GetCurrentPosition ()

Public Attributes

 log_CLASSID_m
 Macro to add class name member s_className.

Private Attributes

fio_JourFilem_jourFile_p
ivd_FilePosition_t m_startPosition
ivd_FileBufSize_t m_transSize
ivd_FilePosition_t m_currentPosition
ivd_FilePosition_t m_limitPosition
ivd_TransNumber_t m_transNumber
ivd_TransNumber_t m_lastDBtransNum
bool m_released
 set to true when jour handle is released
ivd_FilePosition_t m_nextStartPosition
 In case that transaction was failed next start position is set.

Friends

ostream & operator<< (ostream &a_os, fio_JourHandle &a_jh)

Detailed Description

Definition at line 50 of file fio_JourHandle.h.


Constructor & Destructor Documentation

fio_JourHandle::fio_JourHandle ( fio_JourFile a_jouFile_p,
ivd_FilePosition_t  a_startPosition,
ivd_FileBufSize_t  a_transSize 
)

Definition at line 59 of file fio_JourHandle.cpp.

References fio_JourFile::IncRefCount(), and m_jourFile_p.

                :
                m_jourFile_p(a_jourFile_p),
                m_startPosition(a_startPosition),
                m_transSize(a_transSize),
                m_currentPosition(a_startPosition),
                m_limitPosition(a_startPosition + a_transSize),
                m_transNumber(0),
                m_lastDBtransNum(0),
                m_released(false),
                m_nextStartPosition(0)
//                m_blockFilled(0)
{
    m_jourFile_p->IncRefCount();
}

Here is the call graph for this function:

fio_JourHandle::~fio_JourHandle (  ) 

Definition at line 80 of file fio_JourHandle.cpp.

References fio_JourFile::DecRefCount(), and m_jourFile_p.

Here is the call graph for this function:


Member Function Documentation

void fio_JourHandle::AddStartPosition ( ivd_FileBufSize_t  a_size  )  [inline]

Definition at line 101 of file fio_JourHandle.h.

References m_startPosition, and SetStartPosition().

Referenced by fio_Transaction::ReadTransactionFromLog().

Here is the call graph for this function:

Here is the caller graph for this function:

ivd_FilePosition_t fio_JourHandle::FindNextTransHdr ( bool  a_repair  ) 

When current transaction is damaged then find nex one set repaire argument to TRUE when need update of damege trans header.

Definition at line 155 of file fio_JourHandle.cpp.

References fio_StartTransaction_t::FindStart(), GetJourFile(), JourWrite(), log_FUNC_m, log_WRN_m, m_startPosition, fio_JourFile::ResetFreeTransPosition(), ResetPosition(), SetStartPosition(), SetTransSize(), and fio_StartTransaction_t::TransSize.

Referenced by fio_JourFile::DumpDamagedTrans(), and fio_Transaction::ReadTransactionFromLog().

                                                                  {
    log_FUNC_m(FindNextTransHdr);
    fio_JourFile &jourFile = *GetJourFile();
    // fix bug 480
    // next start transaction record must be at least after this damaged one
    ivd_FilePosition_t searchPos = m_startPosition + sizeof(fio_StartTransaction_t);
    ivd_FilePosition_t pos = fio_StartTransaction_t::FindStart(jourFile, searchPos);

    if (a_repair) {        
      // update start transaction header with NULL for alocace and released UV 
      // do not forget to update size of transaction, maybe transaction number too. 
      // It's better for scaning UV to recreate buffer
      // Scaninig doesn't need to check if header exist and is consistent.
      
        // Last transaction is cut in the middle of its start transaction header
        // usualy disk full heppened.
        // Now write down whole header.
        if (pos < searchPos) {
            log_WRN_m( "EOF detected. No space to write header at file possition " << pos
                    << ", available space " << pos - m_startPosition
                    << ", trans header size " << sizeof(fio_StartTransaction_t)
                    << ". Write freely over the end of the file." );
            pos = searchPos;
            jourFile.ResetFreeTransPosition(pos);
        }
        fio_StartTransaction_t cleanStartTrans(0, pos - m_startPosition, 0, 0, 0);
        SetTransSize(cleanStartTrans.TransSize);
        log_WRN_m( "Found new possition " << pos
                  << "  bad trans size " << cleanStartTrans.TransSize 
                  << "  trans header size " << sizeof(fio_StartTransaction_t));
        // set the position to start transaction 
        ResetPosition();
        // update 
        JourWrite(&cleanStartTrans, sizeof(fio_StartTransaction_t));
        SetStartPosition(pos);    
    }
    return pos;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ivd_FilePosition_t fio_JourHandle::GetCurrentPosition (  )  [inline]

Definition at line 147 of file fio_JourHandle.h.

References m_currentPosition.

Referenced by fio_JourFile::Dump(), and fio_JourMgr::Replay().

{return m_currentPosition;};

Here is the caller graph for this function:

ivd_FileID_t fio_JourHandle::GetFileID ( void   ) 

Definition at line 216 of file fio_JourHandle.cpp.

References fio_File::GetFileID(), and m_jourFile_p.

Referenced by fio_Transaction::EndTransaction(), and fio_JourMgr::ReleaseWaiters().

                                       { 

    return m_jourFile_p->GetFileID();

}

Here is the call graph for this function:

Here is the caller graph for this function:

fio_JourFile* fio_JourHandle::GetJourFile (  )  [inline]

Definition at line 88 of file fio_JourHandle.h.

References m_jourFile_p.

Referenced by FindNextTransHdr(), and fio_StartTransaction_t::FindStart().

{ return m_jourFile_p;};

Here is the caller graph for this function:

ivd_TransNumber_t fio_JourHandle::GetLastDBTransNum (  )  [inline]

Definition at line 86 of file fio_JourHandle.h.

References m_lastDBtransNum.

Referenced by fio_Transaction::ReadTransactionFromLog().

{ return m_lastDBtransNum;};

Here is the caller graph for this function:

ivd_FilePosition_t fio_JourHandle::GetLimitPosition (  )  [inline]

Definition at line 120 of file fio_JourHandle.h.

References m_limitPosition.

Referenced by fio_JourMgr::ReleaseWaiters().

{ return m_limitPosition;};

Here is the caller graph for this function:

ivd_FilePosition_t fio_JourHandle::GetNextStartPosition (  )  [inline]

Definition at line 90 of file fio_JourHandle.h.

References m_nextStartPosition.

{ return m_nextStartPosition;};

bool fio_JourHandle::GetReleased (  )  [inline]

Definition at line 118 of file fio_JourHandle.h.

References m_released.

{ return m_released;};

ivd_FilePosition_t fio_JourHandle::GetStartPosition (  )  [inline]

Definition at line 89 of file fio_JourHandle.h.

References m_startPosition.

Referenced by fio_Transaction::EndTransaction(), fio_StartTransaction_t::FindStart(), and fio_Transaction::ReadTransactionFromLog().

{ return m_startPosition;};

Here is the caller graph for this function:

ivd_TransNumber_t fio_JourHandle::GetTransNumber (  )  [inline]
ivd_FileBufSize_t fio_JourHandle::GetTransSize (  )  [inline]

Definition at line 87 of file fio_JourHandle.h.

References m_transSize.

{ return m_transSize;};

void fio_JourHandle::JourFlush ( const void *  a_buffer,
ivd_FileBufSize_t  a_size 
)

Definition at line 116 of file fio_JourHandle.cpp.

References ie_TRANS_EXCEED_JOUR_SPACE, log_FUNC_m, m_currentPosition, m_jourFile_p, m_limitPosition, and fio_File::PosWrite().

Referenced by JourWrite().

                                                                {
    ivd_FilePosition_t newpos = m_currentPosition + a_size;
    if (newpos > m_limitPosition) {
        log_FUNC_m(JourFlush);
        throw ivd_InternalError(ie_TRANS_EXCEED_JOUR_SPACE, "You miss something. :)", true);
    }
    m_jourFile_p->PosWrite(m_currentPosition, a_buffer, a_size);
    m_currentPosition = newpos;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fio_JourHandle::JourRead ( void *  a_buffer,
ivd_FileBufSize_t  a_size 
)

Definition at line 129 of file fio_JourHandle.cpp.

References ie_NOT_STARTTRANS_T, ivd_Error, log_FUNC_m, m_currentPosition, m_jourFile_p, m_limitPosition, and fio_File::PosRead().

Referenced by fio_JourFile::Dump(), fio_JourFile::DumpDamagedTrans(), fio_Alter_t::fio_Alter_t(), fio_StartTransaction_t::Init(), fio_EndTransaction_t::Init(), fio_AlterJour::Insert(), and fio_Transaction::ReadUVListFromJour().

                                                         {
    
    ivd_FilePosition_t newpos = m_currentPosition + a_size;
    if (newpos > m_limitPosition) {
        log_FUNC_m(JourRead);
        throw ivd_Error(ie_NOT_STARTTRANS_T, "Read over transaction space.", true);
    }
    int ret = m_jourFile_p->PosRead(m_currentPosition, a_buffer, a_size);
    m_currentPosition += a_size;

    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fio_JourHandle::JourSkip ( ivd_FileBufSize_t  a_offset  ) 

Skip a_offset bytes in file.

Definition at line 145 of file fio_JourHandle.cpp.

References log_FUNC_m, m_currentPosition, m_jourFile_p, and cmn_File::SeekRelF().

Referenced by fio_JourFile::Dump().

                                                        {
    log_FUNC_m(JourSkip);
    int ret = m_jourFile_p->SeekRelF(a_offset);
    m_currentPosition += a_offset;

    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_JourHandle::JourSync (  ) 

Definition at line 196 of file fio_JourHandle.cpp.

References m_jourFile_p, and cmn_File::SyncF().

Referenced by fio_Transaction::EndTransaction().

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_JourHandle::JourWrite ( const void *  a_buffer,
ivd_FileBufSize_t  a_size 
)

Definition at line 99 of file fio_JourHandle.cpp.

References ie_TRANS_EXCEED_JOUR_SPACE, JourFlush(), log_FUNC_m, m_currentPosition, m_jourFile_p, m_limitPosition, and fio_File::PosWrite().

Referenced by FindNextTransHdr(), fio_Transaction::WriteEndHeader(), fio_Transaction::WriteStartHeader(), fio_AlterJourBlock::WriteToLog(), and fio_Transaction::WriteUVListToJour().

                                                                {

    ivd_FilePosition_t newpos = m_currentPosition + a_size;
    if (newpos > m_limitPosition) {
        log_FUNC_m(JourFlush);
        ostringstream sstr;        
        sstr << "You miss something. :)" << *this;
        
        throw ivd_InternalError(ie_TRANS_EXCEED_JOUR_SPACE, sstr.str() , true);
    }
    m_jourFile_p->PosWrite(m_currentPosition, a_buffer, a_size);
    m_currentPosition = newpos;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_JourHandle::Release (  )  [inline]

Definition at line 117 of file fio_JourHandle.h.

References m_released.

Referenced by fio_JourMgr::ReleaseJourHandle().

{ m_released = true;};

Here is the caller graph for this function:

void fio_JourHandle::ResetPosition (  )  [inline]
void fio_JourHandle::SetLastDBTransNum ( ivd_TransNumber_t  a_lastDBtransNum  ) 

Definition at line 93 of file fio_JourHandle.cpp.

References log_FUNC_m, and m_lastDBtransNum.

Referenced by fio_JourMgr::Replay().

                                                                         {
    log_FUNC_m(SetLastDBTransNum);
    m_lastDBtransNum = a_lastDBtransNum;
}

Here is the caller graph for this function:

void fio_JourHandle::SetNextStartPosition ( ivd_FilePosition_t  a_pos  )  [inline]

Definition at line 97 of file fio_JourHandle.h.

References m_nextStartPosition.

                                                               { 
        m_nextStartPosition = a_pos;
    };

void fio_JourHandle::SetStartPosition ( ivd_FilePosition_t  a_pos  )  [inline]

Definition at line 105 of file fio_JourHandle.h.

References m_currentPosition, and m_startPosition.

Referenced by AddStartPosition(), and FindNextTransHdr().

                                                           { 
        m_startPosition   = a_pos;
        m_currentPosition = a_pos;
    };

Here is the caller graph for this function:

void fio_JourHandle::SetStartPositionIsCurrent (  )  [inline]

Definition at line 110 of file fio_JourHandle.h.

References m_currentPosition, and m_startPosition.

Referenced by fio_JourFile::Dump(), and fio_Transaction::ReadTransactionFromLog().

Here is the caller graph for this function:

void fio_JourHandle::SetTransNumber ( ivd_TransNumber_t  a_transNum  ) 

Definition at line 86 of file fio_JourHandle.cpp.

References m_transNumber.

Referenced by fio_JourFile::Dump(), fio_JourMgr::GetJourWriteHandle(), and fio_Transaction::ReadTransactionFromLog().

                                                                {
//    log_FUNC_m(SetTransNumber);
    m_transNumber =  a_transNum;
}

Here is the caller graph for this function:

void fio_JourHandle::SetTransSize ( ivd_FileBufSize_t  a_size  )  [inline]

Definition at line 92 of file fio_JourHandle.h.

References m_limitPosition, m_startPosition, and m_transSize.

Referenced by fio_JourFile::Dump(), FindNextTransHdr(), fio_StartTransaction_t::Init(), and fio_Transaction::ReadTransactionFromLog().

                                                       { 
        m_transSize = a_size;
        m_limitPosition = m_startPosition + a_size;
    };

Here is the caller graph for this function:


Friends And Related Function Documentation

ostream& operator<< ( ostream &  a_os,
fio_JourHandle a_jh 
) [friend]

Definition at line 202 of file fio_JourHandle.cpp.

                                                          {
    a_os << "************** Journal Handle Object ***************"              << endl;
    a_os << "Jounal file              = " << a_jh.m_jourFile_p->GetFileName()   << endl;
    a_os << "Start file position      = " << a_jh.m_startPosition               << endl;
    a_os << "Size of transaction      = " << a_jh.m_transSize                   << endl;
    a_os << "Current file position    = " << a_jh.m_currentPosition             << endl;
    a_os << "Limit file position      = " << a_jh.m_limitPosition               << endl;
    a_os << "Transaction number       = " << a_jh.m_transNumber                 << endl;
    a_os << "Is handle released       = " << a_jh.m_released                    << endl;
    a_os << "Next start file position = " << a_jh.m_nextStartPosition           << endl;
    a_os << "********** End Of Journal Handle Object ************"              << endl;
    return a_os;
}


Member Data Documentation

Macro to add class name member s_className.

Definition at line 82 of file fio_JourHandle.h.

Definition at line 72 of file fio_JourHandle.h.

Referenced by GetLastDBTransNum(), and SetLastDBTransNum().

In case that transaction was failed next start position is set.

Definition at line 78 of file fio_JourHandle.h.

Referenced by GetNextStartPosition(), operator<<(), and SetNextStartPosition().

set to true when jour handle is released

Definition at line 75 of file fio_JourHandle.h.

Referenced by GetReleased(), operator<<(), and Release().

Definition at line 70 of file fio_JourHandle.h.

Referenced by GetTransNumber(), operator<<(), and SetTransNumber().

Definition at line 64 of file fio_JourHandle.h.

Referenced by GetTransSize(), operator<<(), and SetTransSize().


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