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

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

#include <fio_Transaction.h>

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

List of all members.

Public Member Functions

 fio_Transaction (fio_DataBase *a_database_p, const fio_TransactionID_t a_transactionID)
 This constructore create new transaction object on new log file.
virtual ~fio_Transaction ()
void VectorIsFreed (const ivd_RelFileID_t a_fileID, const ivd_VectorSize_t a_vectorSize, const ivd_RecordIDX_t a_idx)
 VectorIsFreed method take care about vectors that were released from DB.
void VectorIsFreed (const fio_UV_t &a_uv)
void VectorIsUsed (const ivd_RelFileID_t a_fileID, const ivd_VectorSize_t a_vectorSize, const ivd_RecordIDX_t a_idx)
 VectorIsUsed method take care about vectors that are got from UVbuffer and used in DB.
void VectorIsUsed (const fio_UV_t &a_uv)
void StartTransaction (fio_TransType_e a_transType)
void StartTransaction ()
void StartTransAnyType ()
void EndTransaction ()
void EndTransIfStarted ()
void AbortTransaction ()
void InsertAlteration (fio_JourHandle *a_jourHnd_p)
 alteration object MUST be created on heap, cause transaction take care about it.
void InsertAlteration (UInt16_t a_fileID, ivd_FilePosition_t a_filePosition, ivd_FileBufSize_t a_bufSize, const UInt8_t *a_data)
int GetStartCount () const
ivd_TransNumber_t GetTransNumber () const
fio_TransactionID_t GetTransID () const
bool IsExclStartTrans ()
void ReadTransactionFromLog (fio_JourHandle *a_jourHnd_p)
 mathod that read transactin start header and reply UVbuffer first and after transaction number >= a_jourhnd_p->GetTransNumb then updateDB is perform too.
void SetMiniTransaction (bool a_set)

Public Attributes

 log_CLASSID_m

Private Member Functions

void CleanUp ()
void ClearAlterVector ()
void WriteAlterationToLog ()
void ExclusiveStartTransaction ()
void FinishTransaction ()
void UpdateDB ()
void PutVectorToBuffer ()
void ReplyAddVectorToBuffer ()
void ReplyRemoveVectorFromBuffer ()
void WriteEndHeader ()
void WriteStartHeader ()
void WriteUVListToJour ()
void ReadUVListFromJour (UInt32_t a_numOfFreedUV, UInt32_t a_numOfUsedUV)

Private Attributes

fio_DataBasem_database_p
 The transaction object is constructed by database and holds pointer to it.
const fio_TransactionID_t m_transactionID
 Is obtained by database. It is used to concurrently access to list of list of unused vectors.
fio_JourHandlem_jourHnd_p
 Jounal handle is used to store start, end transaction header, and DB alterations between them into journal file.
fio_AlterJour m_alteration
 journal of alterations
bool m_valid
 Transaction is valid if is started and then ended.
int m_startCount
 This member is set to 0 by constructor and is increment by each StartTransaction method and is decremented by each EndTransaction method.
ivd_TransNumber_t m_transNumber
 transaction number is set by journal manager through journal handle and it is stored in start and end transaction header.
ivd_FileBufSize_t m_transSize
ivd_AlterNumber_t m_alterNumber
 nujmber of alteration inside transaction, each InsertAlteration() increment this number by 1
bool m_exclStartTrans
 Allow start transaction no mather of DB lock status.
fio_UV_v_t m_freedVec_m
 In this map are UV that DB don't need any more.
fio_UV_v_t m_usedVec_m
 In this map are UV that are got from UVbuffer.
bool m_miniTransaction
 when transaction is use for get or put to UV then is mini prevent that mini trans not trig another mini transaction
fio_TransType_e m_transType
 now only ftt_CIRC_VECT is used

Friends

class fio_DataBase
class fio_uvListMgr

Detailed Description

Definition at line 159 of file fio_Transaction.h.


Constructor & Destructor Documentation

fio_Transaction::fio_Transaction ( fio_DataBase a_database_p,
const fio_TransactionID_t  a_transactionID 
)

This constructore create new transaction object on new log file.

Definition at line 247 of file fio_Transaction.cpp.

References log_FUNC_m.

fio_Transaction::~fio_Transaction (  )  [virtual]

Definition at line 270 of file fio_Transaction.cpp.

References ClearAlterVector(), and log_FUNC_m.

Here is the call graph for this function:


Member Function Documentation

void fio_Transaction::AbortTransaction (  ) 

Definition at line 470 of file fio_Transaction.cpp.

References CleanUp(), dbg_NORM, fio_DataBase::EndTransaction(), log_DBG_m, log_FUNC_m, m_alterNumber, m_database_p, m_exclStartTrans, m_miniTransaction, m_startCount, m_transNumber, and m_transSize.

Referenced by fsc_DataLMgr::GetBunchOfFileIDs().

                                       {
    log_FUNC_m(AbortTransaction);
    log_DBG_m(dbg_NORM, "ABORT TRANSACTION " << m_transNumber << 
                " alter number = " << m_alterNumber <<
                " alter size = " << m_transSize);
    if (m_startCount > 0) {
        m_database_p->EndTransaction();
    }
    m_startCount      = 0;
    m_exclStartTrans  = false;
    m_miniTransaction = false;
    CleanUp();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::CleanUp (  )  [private]

Definition at line 278 of file fio_Transaction.cpp.

References ClearAlterVector(), cmn_Num2Str(), log_ERR_m, log_FUNC_m, m_alterNumber, m_freedVec_m, m_startCount, m_transNumber, m_transSize, m_usedVec_m, and m_valid.

Referenced by AbortTransaction(), EndTransaction(), ReadTransactionFromLog(), and StartTransAnyType().

                              {
    m_valid       = false;
    if (m_startCount > 0) {
        log_FUNC_m(CleanUp);
        log_ERR_m( string("Transaction ") + cmn_Num2Str(m_transNumber) 
                 + string(" is going to clean up, but it is not Aborted. Start trans count is ")
                 + cmn_Num2Str(m_startCount));
    }
    m_startCount  = 0;  // cause start transaction header is read.
    m_transNumber = 0;  // trans number is got from jour file
    m_transSize   = 0;  // reset transaction counters
    m_alterNumber = 0;

    m_freedVec_m.clear();
    m_usedVec_m.clear();
    ClearAlterVector();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::ClearAlterVector (  )  [private]

Definition at line 298 of file fio_Transaction.cpp.

References fio_AlterJour::Clear(), and m_alteration.

Referenced by CleanUp(), and ~fio_Transaction().

                                       {
//    log_FUNC_m(ClearAlterVector);
    m_alteration.Clear();

    //fio_Alteration* *ip = &(*m_alteration_v.begin());
    //fio_Alteration* *ep = &(*m_alteration_v.end()); // addres of past the end
    //for (; ip < ep; ++ip) {
    //    if (*ip != NULL) {
    //       delete (*ip);
    //    }
    //}
    //m_alteration_v.clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::EndTransaction (  ) 

Definition at line 376 of file fio_Transaction.cpp.

References CleanUp(), fio_DataBase::Continue(), dbg_NORM, fio_DataBase::EndTransaction(), fio_regularFlushUV_c, ftt_NORMAL, fio_JourHandle::GetFileID(), fio_JourMgr::GetJourWriteHandle(), fio_JourHandle::GetStartPosition(), fio_JourHandle::GetTransNumber(), fio_JourHandle::JourSync(), log_DBG_m, log_FUNC_m, m_alteration, m_alterNumber, m_database_p, m_exclStartTrans, m_freedVec_m, cmn_LockOwn::m_groupID, m_jourHnd_p, fio_DataBase::m_jourMgr_p, m_miniTransaction, m_startCount, m_transactionID, m_transNumber, m_transSize, m_transType, m_usedVec_m, m_valid, PutVectorToBuffer(), fio_DataBase::RegularSuspend(), fio_JourMgr::ReleaseJourHandle(), ReplyAddVectorToBuffer(), fio_AlterJour::Size(), UpdateDB(), WriteAlterationToLog(), WriteEndHeader(), and WriteStartHeader().

Referenced by hsm_FileHeader::AddToReleaseCanList(), hsm_FileHeader::CompleteMigIsDone(), hsm_FileHeader::Event(), hsm_FileHeader::EventOffline(), fsc_DataLMgr::FlushChangesAndCleanCache(), fsc_DataLMgr::GetBunchOfFileIDs(), hsm_FHmigc::GetFileIDs(), fio_CirFileTrans::GetRFIdxFromNextBlock(), hdb_RemoveName(), hsm_FileHeader::InitActive(), fio_TransGroupLock< _T, _defTransEl >::LockByIDOwn(), hsm_FileHeader::MigrationIsDone(), fio_CirFileTrans::NewWriteBackBlock(), hsm_ActiveFH::OrphanedToMigList(), fio_uvListMgr::PutVector(), fio_uvListMgr::ReadUV(), hsm_FileHeader::Recalled(), hsm_FileHeader::RemoveFromHSM(), hsm_FileHeader::StoreDirTreeRec(), hsm_FileHeader::StoreNameOwnRec(), hsm_FileHeader::StoreOldNameOwnRec(), fio_DataBase::Synchronize(), hsm_FHrelc::Truncate(), and fio_TransGroupLock< _T, _defTransEl >::UnLockAndFlush().

                                     {
    log_FUNC_m(EndTransaction);

    if (m_startCount == 0) {
//        throw ivd_Error(ie_TRANSACTION_NOT_STARTED, 
        log_DBG_m(dbg_NORM, "Transaction level is already 0. Maybe the transaction was aborted.");
        return;
    }

    m_startCount--;
    if (m_startCount == 0) {

        bool newJournalFile = false;

        log_DBG_m(dbg_NORM, "END   transaction. ID : " << m_transactionID
            << "  type " << m_transType 
            << "  groupID" << m_groupID
            << "  startCount " << m_startCount);

        // if something change
        if (  m_alteration.Size() > 0
           || m_freedVec_m.size()   > 0
           || m_usedVec_m.size()    > 0) {

            m_transSize +=   (sizeof(fio_StartTransaction_t) 
                            + sizeof(fio_EndTransaction_t))
                            + m_freedVec_m.size() * sizeof(fio_UV_t)
                            + m_usedVec_m.size()  * sizeof(fio_UV_t);

            // get journal header
            m_jourHnd_p   = m_database_p->m_jourMgr_p->GetJourWriteHandle(m_transSize, newJournalFile);
            m_transNumber = m_jourHnd_p->GetTransNumber();

            log_DBG_m(dbg_NORM, "INFO  transaction. ID : " << m_transactionID
             << "  type " << m_transType 
             << "  Size " << m_transSize << 
                "  freedVec " << m_freedVec_m.size() <<
                "  usedVec " << m_usedVec_m.size() <<
                "  alter number " << m_alterNumber <<
                "  jour file 0x" << hex << m_jourHnd_p->GetFileID() << dec <<
                "  jour pos " << m_jourHnd_p->GetStartPosition());

            WriteStartHeader();
            WriteAlterationToLog();
            WriteEndHeader();
            m_jourHnd_p->JourSync();  // flush all changes to journal file

            m_valid = true;

            UpdateDB(); // database must be update before UV from transaction bug 1029;

            // release journal header and commit changes
            m_database_p->m_jourMgr_p->ReleaseJourHandle(m_jourHnd_p);
            m_jourHnd_p = NULL;

            if (m_miniTransaction) {   // do not trig another mini transaction
                ReplyAddVectorToBuffer();
            }
            else {
                // put released vector to UVlist
                PutVectorToBuffer();
            }

        } //  if (m_alteration_v.size() > 0) 

        // notify DB about end transaction event
        m_database_p->EndTransaction();

        CleanUp();

        if (    newJournalFile 
            && !m_miniTransaction
            && !m_exclStartTrans
            && (m_transType == ftt_NORMAL)) { // mini, exclusive and circ-vect transactions can't be initiators
            log_DBG_m(dbg_NORM, "Flush UV." );
            m_database_p->RegularSuspend(false);
            m_database_p->Continue(fio_regularFlushUV_c); // do not delete journal files
        }
        else {
            log_DBG_m(dbg_NORM, "UV not flushed. " 
                    << "newJournalFile : " << boolalpha << newJournalFile
                    << ", m_miniTransaction : " << boolalpha << m_miniTransaction
                    << ", m_exclStartTrans : " << boolalpha << m_exclStartTrans
                    << ", m_transType : " << m_transType);
        }
        m_exclStartTrans  = false;
        // if new journal file then suspend=, continue DB.
        
        m_transType = ftt_NONE;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::EndTransIfStarted (  )  [inline]

Definition at line 301 of file fio_Transaction.h.

Referenced by fio_TransGroupLock< _T, _defTransEl >::ReleaseGroup().

                             {
        if (m_startCount > 0) {
            EndTransaction();
        }
    };

Here is the caller graph for this function:

void fio_Transaction::ExclusiveStartTransaction (  )  [private]

Definition at line 314 of file fio_Transaction.cpp.

References ftt_HANDLE_UV, log_FUNC_m, m_exclStartTrans, m_miniTransaction, m_transType, and StartTransAnyType().

Referenced by fio_uvListMgr::PutVector(), fio_uvListMgr::ReadUV(), and fio_DataBase::Synchronize().

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::FinishTransaction (  )  [private]
int fio_Transaction::GetStartCount (  )  const [inline]

Definition at line 315 of file fio_Transaction.h.

{ return m_startCount; };

fio_TransactionID_t fio_Transaction::GetTransID (  )  const [inline]

Definition at line 318 of file fio_Transaction.h.

Referenced by fio_TransLstMgr::isTransRegistered(), and fio_TransLstMgr::ReleaseTransObj().

{ return m_transactionID; };

Here is the caller graph for this function:

ivd_TransNumber_t fio_Transaction::GetTransNumber (  )  const [inline]

Definition at line 316 of file fio_Transaction.h.

{ return (m_startCount > 0) ? m_transNumber : 0; };

void fio_Transaction::InsertAlteration ( fio_JourHandle a_jourHnd_p  ) 

alteration object MUST be created on heap, cause transaction take care about it.

void fio_Transaction::InsertAlteration(fio_Alteration *a_alter_p) { log_FUNC_m(InsertAlteration);

if (m_startCount > 0) { m_transSize += a_alter_p->AlterSize(); m_alterNumber++; m_alteration_v.push_back(a_alter_p); log_DBG_m(dbg_DETAIL, " alt num " << m_alterNumber << " alter size " << a_alter_p->AlterSize() << " trans size" << m_transSize); } else { log_FUNC_m(InsertAlteration); throw ivd_Error(ie_TRANSACTION_NOT_STARTED, "Can't InsertAlteration() before StartTransaction().", true); } }

Definition at line 529 of file fio_Transaction.cpp.

References fio_Alter_t::bufSize, fio_AlterJour::Insert(), m_alteration, m_alterNumber, and m_transSize.

Referenced by InsertAlteration(), fio_RelFileTrans::PosWrite(), and ReadTransactionFromLog().

                                                                  {
//    log_FUNC_m(InsertAlteration(jour_p))
    fio_Alter_t alter(a_jourHnd_p);
    m_transSize += sizeof(fio_Alter_t) + alter.bufSize;
    m_alterNumber++;
    m_alteration.Insert(alter, a_jourHnd_p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::InsertAlteration ( UInt16_t  a_fileID,
ivd_FilePosition_t  a_filePosition,
ivd_FileBufSize_t  a_bufSize,
const UInt8_t a_data 
)

Definition at line 539 of file fio_Transaction.cpp.

References ie_TRANSACTION_NOT_STARTED, fio_AlterJour::Insert(), InsertAlteration(), ivd_Error, log_FUNC_m, m_alteration, m_alterNumber, m_startCount, and m_transSize.

                                                                   {
//    log_FUNC_m(InsertAlteration)
    if (m_startCount > 0) {
        m_transSize += sizeof(fio_Alter_t) + a_bufSize;
        m_alterNumber++;
        m_alteration.Insert(a_fileID, a_filePosition, a_bufSize);
        m_alteration.Insert(a_data, a_bufSize);
        //log_DBG_m(dbg_DETAIL, " alt num "  << m_alterNumber
        //                    << " RelFileID " <<  a_fileID
        //                    << " alter size " <<  a_bufSize
        //                    << " trans size"  << m_transSize);
        //log_DBG_m(dbg_DETAIL, "W alteration : " <<  endl <<
        //    cmn_HexDump(a_data, a_bufSize, 16, false) );
    }
    else {
        log_FUNC_m(InsertAlteration);
        throw ivd_Error(ie_TRANSACTION_NOT_STARTED, 
            "Can't InsertAlteration() before StartTransaction().", true);
    }
}

Here is the call graph for this function:

bool fio_Transaction::IsExclStartTrans (  )  [inline]

Definition at line 320 of file fio_Transaction.h.

Referenced by fio_DataBase::StartTransaction().

{return m_exclStartTrans;};

Here is the caller graph for this function:

void fio_Transaction::PutVectorToBuffer (  )  [private]

Definition at line 818 of file fio_Transaction.cpp.

References dbg_DETAIL, fio_DataBase::GetRelFileTrans(), log_DBG_m, log_FUNC_m, m_database_p, fio_UV_t::m_fileID, m_freedVec_m, fio_UV_t::m_idx, and fio_UV_t::m_vectorSize.

Referenced by EndTransaction().

                                        {
    log_FUNC_m(PutVectorToBuffer);
    
    //fio_RelFileTrans *rft_p = NULL;
    //ivd_RelFileID_t      prevFileID = 0;
//    ivd_RelFileID_t      currFileID;

    register fio_UV_t *ip = &(*m_freedVec_m.begin());
    register fio_UV_t *ep = &(*m_freedVec_m.end()); // addres of past the end
    for(; ip < ep; ++ip) {
        //ivd_RelFileID_t currFileID = iter->m_fileID;
        //if (currFileID == 0) {
        //    throw ivd_InternalError(ie_REL_FILE_INDEX_INV, "Idx " + cmn_Num2Str(currFileID), true);
        //}
        //if (prevFileID != currFileID) {  // get new relfiletrans pointer
        //    prevFileID  = currFileID;
        //    rft_p = m_database_p->GetRelFileTrans(currFileID);
        //}
//        rft_p->PutVectorToBufferAndFlush(iter->m_idx, iter->m_vectorSize);
    log_DBG_m(dbg_DETAIL, "Freed UV RelFileID " << (int)ip->m_fileID << "  idx " << ip->m_idx 
                     << "  size " << ip->m_vectorSize);
        m_database_p->GetRelFileTrans(ip->m_fileID)->
            PutVectorToBufferAndFlush(ip->m_idx, ip->m_vectorSize);
    }
    m_freedVec_m.clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::ReadTransactionFromLog ( fio_JourHandle a_jourHnd_p  ) 

mathod that read transactin start header and reply UVbuffer first and after transaction number >= a_jourhnd_p->GetTransNumb then updateDB is perform too.

before return the method must set file startPosition of a_jourHnd_p soon after transaction for next call

Definition at line 605 of file fio_Transaction.cpp.

References fio_JourHandle::AddStartPosition(), fio_StartTransaction_t::AlterNumber, CleanUp(), dbg_DETAIL, fio_JourHandle::FindNextTransHdr(), fio_StartTransaction_t::FreedVector, ivd_BaseException::GetError(), fio_JourHandle::GetLastDBTransNum(), fio_JourHandle::GetStartPosition(), fio_JourHandle::GetTransNumber(), fio_EndTransaction_t::Init(), fio_StartTransaction_t::Init(), InsertAlteration(), log_DBG_m, log_FUNC_m, log_WRN_m, m_alterNumber, m_jourHnd_p, m_startCount, m_transNumber, m_valid, ReadUVListFromJour(), ReplyAddVectorToBuffer(), ReplyRemoveVectorFromBuffer(), fio_JourHandle::ResetPosition(), fio_JourHandle::SetStartPositionIsCurrent(), fio_JourHandle::SetTransNumber(), fio_JourHandle::SetTransSize(), fio_StartTransaction_t::TransNumber, fio_StartTransaction_t::TransSize, UpdateDB(), and fio_StartTransaction_t::UsedVector.

Referenced by fio_JourMgr::Replay().

{
    log_FUNC_m(ReadTransactionFromLog);

    m_jourHnd_p = a_jourHnd_p;
    log_DBG_m(dbg_DETAIL, "Read jour at position " << a_jourHnd_p->GetStartPosition()
                        << ", transNumber " << m_jourHnd_p->GetTransNumber()
                        << ", lastDBTransNum " << m_jourHnd_p->GetLastDBTransNum());

    CleanUp();

    ivd_AlterNumber_t jourAlterNum = 0; // will be checked after all alteration are insert

    fio_StartTransaction_t startTrans;
    fio_EndTransaction_t   endTrans;

    try {

        startTrans.Init(*m_jourHnd_p);
        if (startTrans.TransNumber == 0) { // transaction is damaged and signed as invalid
            if (startTrans.TransSize >= sizeof(fio_StartTransaction_t)) {
                m_jourHnd_p->AddStartPosition(startTrans.TransSize);  
                return;
            } else {
                m_valid = false;
                goto endofread;
            }
        }

        m_jourHnd_p->SetTransSize(startTrans.TransSize);

        m_startCount++; // cause start transaction header is going to read.

        ReadUVListFromJour(startTrans.FreedVector, startTrans.UsedVector);
       
        m_transNumber = startTrans.TransNumber; 

        if (m_transNumber < m_jourHnd_p->GetLastDBTransNum()) {
            log_DBG_m(dbg_DETAIL, "DB is up to date, but UV are not.")
            // just update UV buffers
            //get again all vectors from UV buffer, to rebuild UV buffer
            try {
                ReplyRemoveVectorFromBuffer();
            }
            catch (ivd_InternalError &err) {
                if (err.GetError() == ie_UV_NOT_IN_BUFFER) {
                    log_WRN_m(startTrans << endl << *m_jourHnd_p);
                }
            }
            // put released vector to UVlist, to rebuild UV buffer
            ReplyAddVectorToBuffer();
            // set next file position
            m_jourHnd_p->AddStartPosition(startTrans.TransSize);  
            m_startCount--;
            return;
        }
        jourAlterNum  = startTrans.AlterNumber; // need to match number of alterations

    }
    catch (ivd_Error &err) {
        if (err.GetError() == ie_NOT_STARTTRANS_T) { 
            m_valid = false;
            goto endofread;
        }
        else {
            throw(err);
        }
    }

    while (m_alterNumber < jourAlterNum) {  // read all alteration
        try {
            InsertAlteration(a_jourHnd_p); // increase m_alterNumber too
        }
        catch (ivd_Error &err) {
            if (err.GetError() == ie_NOT_ALTER_T) { 
                // TODO  repair
                m_jourHnd_p->ResetPosition();
                m_valid = false;
                goto endofread;
            }
            else {
                throw(err);
            }
        }
     }  // while (m_alterNumber <= jourAlterNum)  // loop until all alteration is read

    try {
        endTrans.Init(*m_jourHnd_p);
        m_startCount--; // because end transaction header is read.
        m_valid = (  startTrans == endTrans );
    }                    
    catch (ivd_Error &err) {
        if (err.GetError() == ie_NOT_ENDTRANS_T) { 
            // TODO  repair
            m_valid = false;
            goto endofread;
        }
        else {
            throw(err);
        }
    }

endofread:

    if (m_valid) {
        log_DBG_m(dbg_DETAIL, "Transaction is valid. Update DB.")

        //get again all vectors from UV buffer, to rebuild UV buffer
        ReplyRemoveVectorFromBuffer();
        // put released vector to UVlist, to rebuild UV buffer
        ReplyAddVectorToBuffer();

        // update journal to know that transaction is successfuly finished
        m_jourHnd_p->SetTransNumber(m_transNumber); 
        UpdateDB();

        m_jourHnd_p->SetStartPositionIsCurrent();    
    }
    else {
        log_WRN_m( "Transaction is not valid. JourHandle = " << endl << *m_jourHnd_p << startTrans);
        // find next header and repaire current
        m_jourHnd_p->FindNextTransHdr(true);

        m_startCount = 0; // same as at abort transaction, but not anounce DB
    }
    CleanUp();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::ReadUVListFromJour ( UInt32_t  a_numOfFreedUV,
UInt32_t  a_numOfUsedUV 
) [private]

Definition at line 944 of file fio_Transaction.cpp.

References fio_JourHandle::JourRead(), log_ERR_m, log_FUNC_m, fio_UV_t::m_fileID, fio_UV_t::m_idx, m_jourHnd_p, fio_UV_t::m_vectorSize, VectorIsFreed(), and VectorIsUsed().

Referenced by ReadTransactionFromLog().

                                                                                        {
//            log_FUNC_m(ReadUVListFromJour);

    fio_UV_t uv;
    unsigned int i;
//    log_DBG_m(dbg_DETAIL, "Num of freed UV " << a_numOfFreedUV 
//                     << "  num of used UV " << a_numOfUsedUV);
    for (i = 0; i < a_numOfFreedUV; i++) {
        m_jourHnd_p->JourRead(&uv, sizeof(uv));
        if (uv.m_idx == 0) {
            log_FUNC_m(ReadUVListFromJour);
            log_ERR_m("Skip freed UV that is read from jour. Idx = 0  RelFileID = " << (int)uv.m_fileID
                   << "  vectorSize = " << uv.m_vectorSize);
        }
        else {
            VectorIsFreed(uv);
        }
    }
    for (i = 0; i < a_numOfUsedUV; i++) {
        m_jourHnd_p->JourRead(&uv, sizeof(uv));
        if (uv.m_idx == 0) {
            log_FUNC_m(ReadUVListFromJour);
            log_ERR_m("Skip used UV that is read from jour. Idx = 0  RelFileID = " << (int)uv.m_fileID
                   << "  vectorSize = " << uv.m_vectorSize);
        }
        else {
            VectorIsUsed(uv);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::ReplyAddVectorToBuffer (  )  [private]

Definition at line 847 of file fio_Transaction.cpp.

References fio_DataBase::GetRelFileTrans(), m_database_p, fio_UV_t::m_fileID, m_freedVec_m, fio_UV_t::m_idx, and fio_UV_t::m_vectorSize.

Referenced by EndTransaction(), and ReadTransactionFromLog().

                                             {
    
    //fio_RelFileTrans *rft_p = NULL;
    //ivd_RelFileID_t      prevFileID = 0;
//    ivd_RelFileID_t      currFileID;

    register fio_UV_t *ip = &(*m_freedVec_m.begin());
    register fio_UV_t *ep = &(*m_freedVec_m.end()); // addres of past the end
    for(; ip < ep; ++ip) {
        //ivd_RelFileID_t currFileID = ip->m_fileID;
        //if (currFileID == 0) {
        //    log_FUNC_m(ReplyAddVectorToBuffer);
        //    throw ivd_InternalError(ie_REL_FILE_INDEX_INV, "Idx " + cmn_Num2Str(currFileID), true);
        //    
        //}
        //if (prevFileID != currFileID) {  // get new relfiletrans pointer
        //    prevFileID  = currFileID;
        //    rft_p = m_database_p->GetRelFileTrans(currFileID);
        //}
//        rft_p->AddVectorToBuffer(iter->m_idx, iter->m_vectorSize);
        m_database_p->GetRelFileTrans(ip->m_fileID)->
            AddVectorToBuffer(ip->m_idx, ip->m_vectorSize);
    }
    m_freedVec_m.clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::ReplyRemoveVectorFromBuffer (  )  [private]

Definition at line 875 of file fio_Transaction.cpp.

References fio_DataBase::GetRelFileTrans(), log_FUNC_m, m_database_p, fio_UV_t::m_fileID, fio_UV_t::m_idx, m_usedVec_m, and fio_UV_t::m_vectorSize.

Referenced by ReadTransactionFromLog().

                                                  {
    log_FUNC_m(ReplyRemoveVectorFromBuffer);

    //fio_RelFileTrans *rft_p = NULL;
    //ivd_RelFileID_t      prevFileID = 0;
    //ivd_RelFileID_t      currFileID;
//    fio_UV_v_i iter;

    register fio_UV_t *ip = &(*m_usedVec_m.begin());
    register fio_UV_t *ep = &(*m_usedVec_m.end()); // addres of past the end
    for(; ip < ep; ++ip) {
        //currFileID = iter->m_fileID;
        //if (  prevFileID != currFileID 
        //   || rft_p      == NULL) {  // get new relfiletrans pointer
        //    prevFileID  = currFileID;
        //    rft_p = m_database_p->GetRelFileTrans(currFileID);
        //}
        m_database_p->GetRelFileTrans(ip->m_fileID)->
            RemoveVectorFromBuffer(ip->m_idx, ip->m_vectorSize);
//        rft_p->RemoveVectorFromBuffer(iter->m_idx, iter->m_vectorSize);
    }
    m_usedVec_m.clear();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::SetMiniTransaction ( bool  a_set  )  [inline]

Definition at line 328 of file fio_Transaction.h.

Referenced by fio_uvListMgr::ReadUV().

                                               {
        m_miniTransaction = a_set;
    }

Here is the caller graph for this function:

void fio_Transaction::StartTransaction ( fio_TransType_e  a_transType  ) 
void fio_Transaction::StartTransaction (  ) 

Definition at line 348 of file fio_Transaction.cpp.

References log_FUNC_m, m_exclStartTrans, m_miniTransaction, m_transType, and StartTransAnyType().

Referenced by StartTransaction().

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::StartTransAnyType (  ) 

Definition at line 359 of file fio_Transaction.cpp.

References CleanUp(), dbg_NORM, log_DBG_m, log_FUNC_m, m_database_p, cmn_LockOwn::m_groupID, m_startCount, m_transactionID, m_transType, and fio_DataBase::StartTransaction().

Referenced by ExclusiveStartTransaction(), and StartTransaction().

                                        {
    log_FUNC_m(StartTransAnyType);
    if (m_startCount == 0) {
        log_DBG_m(dbg_NORM, "START transaction. ID : " << m_transactionID
            << "  type " << m_transType 
            << "  groupID" << m_groupID
            << "  startCount " << m_startCount);

        m_database_p->StartTransaction(this); //notify DB, and wait if it's necessary

        CleanUp();
    }
    m_startCount++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::UpdateDB (  )  [private]

Definition at line 486 of file fio_Transaction.cpp.

References fio_AlterJour::Clear(), fio_DataBase::Flush(), m_alteration, m_database_p, and fio_AlterJour::UpdateDB().

Referenced by EndTransaction(), and ReadTransactionFromLog().

                               {
//    log_FUNC_m(UpdateDB);

    //fio_Alteration* *ip = &(*m_alteration_v.begin());
    //fio_Alteration* *ep = &(*m_alteration_v.end()); // addres of past the end
    //for (; ip < ep; ++ip) {
    //    if (*ip != NULL) {
    //       (*ip)->UpdateRelFile();
    //       delete (*ip);
    //    }
    //}
    //m_alteration_v.clear();
    m_alteration.UpdateDB();
    m_alteration.Clear();
    m_database_p->Flush();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::VectorIsFreed ( const fio_UV_t a_uv  )  [inline]

Definition at line 271 of file fio_Transaction.h.

                                             {
        m_freedVec_m.push_back(a_uv);
    };

void fio_Transaction::VectorIsFreed ( const ivd_RelFileID_t  a_fileID,
const ivd_VectorSize_t  a_vectorSize,
const ivd_RecordIDX_t  a_idx 
)

VectorIsFreed method take care about vectors that were released from DB.

When transaction is finished then this released vectors are put to proper UV buffer.

Referenced by fio_uvListMgr::ReadUV(), ReadUVListFromJour(), and fio_RelFileTrans::ReleaseVectorIdx().

Here is the caller graph for this function:

void fio_Transaction::VectorIsUsed ( const fio_UV_t a_uv  )  [inline]

Definition at line 287 of file fio_Transaction.h.

                                            {
        m_usedVec_m.push_back(a_uv);
    };

void fio_Transaction::VectorIsUsed ( const ivd_RelFileID_t  a_fileID,
const ivd_VectorSize_t  a_vectorSize,
const ivd_RecordIDX_t  a_idx 
) [inline]

VectorIsUsed method take care about vectors that are got from UVbuffer and used in DB.

It is possible that such a vectors are released in next actions in the same transaction. This is not a problem, because they are going to released list.

Definition at line 280 of file fio_Transaction.h.

Referenced by fio_uvListMgr::GetBunchOfVectorIDXes(), fio_RelFileTrans::GetVectorIDX(), ReadUVListFromJour(), and fio_uvListMgr::WriteUV().

                                          {
        m_usedVec_m.push_back(fio_UV_t(a_fileID, a_vectorSize, a_idx));
    };

Here is the caller graph for this function:

void fio_Transaction::WriteAlterationToLog (  )  [private]

Definition at line 565 of file fio_Transaction.cpp.

References m_alteration, m_jourHnd_p, and fio_AlterJour::WriteToLog().

Referenced by EndTransaction().

                                           {
//    log_FUNC_m(WriteAlterationToLog);

    //fio_Alteration* *ip = &(*m_alteration_v.begin());
    //fio_Alteration* *ep = &(*m_alteration_v.end()); // addres of past the end
    //for (; ip < ep; ++ip) {
    //    if (*ip != NULL) {
    //       (*ip)->WriteToLog(m_jourHnd_p);
    //    }
    //}
    m_alteration.WriteToLog(m_jourHnd_p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::WriteEndHeader (  )  [private]

Definition at line 596 of file fio_Transaction.cpp.

References fio_JourHandle::JourWrite(), log_FUNC_m, m_jourHnd_p, and m_transNumber.

Referenced by EndTransaction().

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::WriteStartHeader (  )  [private]

Definition at line 580 of file fio_Transaction.cpp.

References fio_JourHandle::JourWrite(), log_FUNC_m, m_alterNumber, m_freedVec_m, m_jourHnd_p, m_transNumber, m_transSize, m_usedVec_m, and WriteUVListToJour().

Referenced by EndTransaction().

                                       {
    log_FUNC_m(WriteStartHeader);

    fio_StartTransaction_t start(m_transNumber, 
                                 m_transSize, 
                                 m_alterNumber, 
                                 m_freedVec_m.size(),
                                 m_usedVec_m.size());

    m_jourHnd_p->JourWrite(&start, sizeof(start));
    WriteUVListToJour();
    // TODO write freed and used vector 
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_Transaction::WriteUVListToJour (  )  [private]

Definition at line 901 of file fio_Transaction.cpp.

References fio_JourHandle::JourWrite(), m_freedVec_m, m_jourHnd_p, m_usedVec_m, and size.

Referenced by WriteStartHeader().

                                        {
    int size;
    if (0 < (size = m_freedVec_m.size())) {
        m_jourHnd_p->JourWrite(&*m_freedVec_m.begin(), 
                               sizeof(fio_UV_t) * size);
    }

    if (0 < (size = m_usedVec_m.size())) {
        m_jourHnd_p->JourWrite(&*m_usedVec_m.begin(), 
                               sizeof(fio_UV_t) * size);
    }
/*    fio_UV_v_i iter;
    for(iter  = m_freedVec_m.begin();
        iter != m_freedVec_m.end();
        iter++) 
    {
        if (iter->m_idx == 0) {
            log_FUNC_m(WriteUVListToJour);
            log_ERR_m("Free UV is going to write to jour. Idx = 0  RelFileID = " << iter->m_fileID
                   << "  vectorSize = " << iter->m_vectorSize);
        }
//        fio_UV_t uv(iter->first.fileID, iter->m_vectorSize, iter->m_idx);
        m_jourHnd_p->JourWrite(&(*iter), sizeof(fio_UV_t));
    }
*/
/*
    for(iter  = m_usedVec_m.begin();
        iter != m_usedVec_m.end();
        iter++) 
    {
        if (iter->m_idx == 0) {
            log_FUNC_m(WriteUVListToJour);
            log_ERR_m("Used UV is going to write to jour. Idx = 0  RelFileID = " << iter->m_fileID
                   << "  vectorSize = " << iter->m_vectorSize);
        }
//        fio_UV_t uv(iter->first.fileID, iter->first.vectorSize, iter->second);
        m_jourHnd_p->JourWrite(&(*iter), sizeof(fio_UV_t));
    }
*/
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class fio_DataBase [friend]

Definition at line 160 of file fio_Transaction.h.

friend class fio_uvListMgr [friend]

Definition at line 161 of file fio_Transaction.h.


Member Data Documentation

Reimplemented from cmn_LockOwn.

Definition at line 259 of file fio_Transaction.h.

journal of alterations

Definition at line 196 of file fio_Transaction.h.

Referenced by ClearAlterVector(), EndTransaction(), InsertAlteration(), UpdateDB(), and WriteAlterationToLog().

nujmber of alteration inside transaction, each InsertAlteration() increment this number by 1

Definition at line 225 of file fio_Transaction.h.

Referenced by AbortTransaction(), CleanUp(), EndTransaction(), InsertAlteration(), ReadTransactionFromLog(), and WriteStartHeader().

The transaction object is constructed by database and holds pointer to it.

The transaction is not responsible to destruct databse.

Definition at line 184 of file fio_Transaction.h.

Referenced by AbortTransaction(), EndTransaction(), PutVectorToBuffer(), ReplyAddVectorToBuffer(), ReplyRemoveVectorFromBuffer(), StartTransAnyType(), and UpdateDB().

Allow start transaction no mather of DB lock status.

Each start transaction event should ask DB to increase number of active transaction In case that DB is locked than DB stop StartTransaction() until unlock of DB. But lock database need to synchronize it and need a transaction for that.

Definition at line 231 of file fio_Transaction.h.

Referenced by AbortTransaction(), EndTransaction(), ExclusiveStartTransaction(), and StartTransaction().

In this map are UV that DB don't need any more.

All these freed vectors are available for DB to use them.

Definition at line 243 of file fio_Transaction.h.

Referenced by CleanUp(), EndTransaction(), PutVectorToBuffer(), ReplyAddVectorToBuffer(), WriteStartHeader(), and WriteUVListToJour().

Jounal handle is used to store start, end transaction header, and DB alterations between them into journal file.

Definition at line 193 of file fio_Transaction.h.

Referenced by EndTransaction(), ReadTransactionFromLog(), ReadUVListFromJour(), WriteAlterationToLog(), WriteEndHeader(), WriteStartHeader(), and WriteUVListToJour().

when transaction is use for get or put to UV then is mini prevent that mini trans not trig another mini transaction

Definition at line 253 of file fio_Transaction.h.

Referenced by AbortTransaction(), EndTransaction(), ExclusiveStartTransaction(), and StartTransaction().

This member is set to 0 by constructor and is increment by each StartTransaction method and is decremented by each EndTransaction method.

The first StratTransaction call realy write start header to log file and last EndTransaction call write end header and upade changes to DB.

Definition at line 212 of file fio_Transaction.h.

Referenced by AbortTransaction(), CleanUp(), EndTransaction(), InsertAlteration(), ReadTransactionFromLog(), and StartTransAnyType().

Is obtained by database. It is used to concurrently access to list of list of unused vectors.

Definition at line 187 of file fio_Transaction.h.

Referenced by EndTransaction(), and StartTransAnyType().

transaction number is set by journal manager through journal handle and it is stored in start and end transaction header.

Definition at line 218 of file fio_Transaction.h.

Referenced by AbortTransaction(), CleanUp(), EndTransaction(), ReadTransactionFromLog(), WriteEndHeader(), and WriteStartHeader().

now only ftt_CIRC_VECT is used

Definition at line 256 of file fio_Transaction.h.

Referenced by EndTransaction(), ExclusiveStartTransaction(), StartTransaction(), and StartTransAnyType().

In this map are UV that are got from UVbuffer.

Both maps will be released to proper UVbuffers after transaction commit.

Definition at line 249 of file fio_Transaction.h.

Referenced by CleanUp(), EndTransaction(), ReplyRemoveVectorFromBuffer(), WriteStartHeader(), and WriteUVListToJour().

bool fio_Transaction::m_valid [private]

Transaction is valid if is started and then ended.

In log file have to be stored strat and end header.

Definition at line 202 of file fio_Transaction.h.

Referenced by CleanUp(), EndTransaction(), and ReadTransactionFromLog().


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