Public Member Functions | Public Attributes | Private Attributes

hsm_ReleaseCandRec Class Reference
[Classes for managing object list]

#include <hsm_FHrelc.h>

Collaboration diagram for hsm_ReleaseCandRec:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 hsm_ReleaseCandRec (fio_CirFileTrans &a_cirFile, ivd_Time32_t a_retaintionTime)
void FindNextClearCurrRec (fio_Transaction &a_trans)
 NULL trans is used only in constructor, cause not need to clean already read record Method FindNextRec find first record that have removeTime != 0 in circular file if circular file is empty then releasedrecord is filled with zeroes and m_idx is set to zero.
void FindNextRec ()
ivd_RecordIDX_t Append (hsm_FileHeader *a_fh_p, fio_Transaction &a_trans)
ivd_RecordIDX_t Append (hdb_ReleaseCand_t &a_rc, fio_Transaction &a_trans)
void Release (hsm_FileHeader *a_fh_p, fio_Transaction &a_trans)
bool IsValid ()
void MoveToEnd (hsm_FileHeader *a_fh_p, fio_Transaction &a_trans)
hdb_ReleaseCand_tGetRefRleaseCandRec ()
ivd_Time32_t GetRemoveTime ()
void Reconfigure (ivd_Time32_t a_RetentionTime)

Public Attributes

 log_CLASSID_m

Private Attributes

fio_CirFileTransm_cirFile
ivd_Time32_t m_retaintionTime
 how much time must files wait on release candidate list
ivd_RecordIDX_t m_idx
hdb_ReleaseCand_t m_releaseCandRec
cmn_Mutex m_releaseCandRec_x

Detailed Description

Definition at line 44 of file hsm_FHrelc.h.


Constructor & Destructor Documentation

hsm_ReleaseCandRec::hsm_ReleaseCandRec ( fio_CirFileTrans a_cirFile,
ivd_Time32_t  a_retaintionTime 
)

Definition at line 73 of file hsm_FHrelc.cpp.

References FindNextRec(), and log_FUNC_m.

        :
        m_cirFile(a_cirFile),
        m_retaintionTime(a_retaintionTime),
        m_idx(0)
{
    log_FUNC_m(hsm_ReleaseCandRec);
    // dont need transaction cause m_idx is zerro
    FindNextRec();
}

Here is the call graph for this function:


Member Function Documentation

ivd_RecordIDX_t hsm_ReleaseCandRec::Append ( hsm_FileHeader a_fh_p,
fio_Transaction a_trans 
)

Definition at line 140 of file hsm_FHrelc.cpp.

References dbg_NORM, hsm_FileHeader::GetFileID(), fio_File::GetFileName(), hsm_FileHeader::GetFileSize(), hsm_FileHeader::GetFName(), hsm_FileHeader::GetfType(), hsm_FileHeader::GetInode(), hsm_FileHeader::GetNameOwnIdx(), log_DBG_m, log_FUNC_m, m_cirFile, m_retaintionTime, and cmn_Time::Time2YMDhms().

Referenced by hsm_FHrelc::Append(), and Append().

                                      {
    log_FUNC_m(Append(FH*));
    hdb_ReleaseCand_t rc(a_fh_p->GetfType(),
                         a_fh_p->GetNameOwnIdx(),  // nameOwnerIdx
                         a_fh_p->GetInode(),
                         a_fh_p->GetFileID());

    ivd_RecordIDX_t idx = Append(rc, a_trans);

    cmn_Time remTime(rc.appendTime +  m_retaintionTime );
    log_DBG_m(dbg_NORM, "Add file " << a_fh_p->GetFName()
                          << " size " << a_fh_p->GetFileSize()
                          << " time to remove " << remTime.Time2YMDhms()
                          << " to " << m_cirFile.GetFileName());
    return idx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ivd_RecordIDX_t hsm_ReleaseCandRec::Append ( hdb_ReleaseCand_t a_rc,
fio_Transaction a_trans 
)

Definition at line 119 of file hsm_FHrelc.cpp.

References Append(), hdb_ReleaseCand_t::appendTime, dbg_DETAIL, log_DBG_m, log_FUNC_m, m_cirFile, m_idx, m_releaseCandRec, m_releaseCandRec_x, NULL, and fio_CirFileTrans::WriteBack().

                                        {

    log_FUNC_m(Append(rc&));

    a_rc.appendTime = time(NULL);
    log_DBG_m(dbg_DETAIL, a_rc);
    
    ivd_RecordIDX_t idx = m_cirFile.WriteBack(&a_rc, a_trans);

    cmn_MutexLock l(m_releaseCandRec_x);
    if (m_releaseCandRec.appendTime == 0) {
        m_releaseCandRec = a_rc; // first record is set immediately
        m_idx = idx;           // and is skipped by FindNexRec
    }        
    return idx;
}

Here is the call graph for this function:

void hsm_ReleaseCandRec::FindNextClearCurrRec ( fio_Transaction a_trans  ) 

NULL trans is used only in constructor, cause not need to clean already read record Method FindNextRec find first record that have removeTime != 0 in circular file if circular file is empty then releasedrecord is filled with zeroes and m_idx is set to zero.

Definition at line 88 of file hsm_FHrelc.cpp.

References FindNextRec(), log_FUNC_m, m_cirFile, m_idx, m_releaseCandRec_x, and fio_CirFileTrans::WriteRec().

Referenced by hsm_FHrelc::Truncate().

                                                                      {
    log_FUNC_m(FindNextClearCurrRec);
    cmn_MutexLock l(m_releaseCandRec_x);
    if (m_idx != 0) {
        hdb_ReleaseCand_t rc; // release previous cand record with zeroes
        m_cirFile.WriteRec(m_idx, &rc, 1, a_trans);
    }
    FindNextRec();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hsm_ReleaseCandRec::FindNextRec (  ) 

Definition at line 100 of file hsm_FHrelc.cpp.

References hdb_ReleaseCand_t::appendTime, hdb_ReleaseCand_t::Clear(), dbg_DETAIL, log_DBG_m, log_FUNC_m, m_cirFile, m_idx, m_releaseCandRec, and fio_CirFileTrans::ReadFront().

Referenced by FindNextClearCurrRec(), hsm_ReleaseCandRec(), IsValid(), and Release().

                                     {
    log_FUNC_m(FindNextRec);
    ivd_RecordIDX_t idx = 0;
    log_DBG_m(dbg_DETAIL, "Current index is " << m_idx);
    do { // read util no more records or found actual record 
        idx = m_cirFile.ReadFront(&m_releaseCandRec); 
        log_DBG_m(dbg_DETAIL, " ReadFront from idx " << idx);
        // first record is already truncate so skip it (idx == m_idx)
    } while (idx != 0 && (m_releaseCandRec.appendTime == 0 || idx == m_idx));
    if (idx == 0) {
//        log_DBG_m(dbg_DETAIL, "No more records in circ file.");
        m_releaseCandRec.Clear();
    }
    m_idx = idx;
    log_DBG_m(dbg_DETAIL, " New RF idx " << m_idx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

hdb_ReleaseCand_t& hsm_ReleaseCandRec::GetRefRleaseCandRec (  )  [inline]

Definition at line 89 of file hsm_FHrelc.h.

References m_releaseCandRec.

Referenced by hsm_FHrelc::ChoiceOldestList(), and hsm_FHrelc::Truncate().

{ return m_releaseCandRec;};

Here is the caller graph for this function:

ivd_Time32_t hsm_ReleaseCandRec::GetRemoveTime (  )  [inline]

Definition at line 91 of file hsm_FHrelc.h.

References hdb_ReleaseCand_t::appendTime, m_releaseCandRec, and m_retaintionTime.

Referenced by hsm_FHrelc::ChoiceOldestList(), and hsm_FHrelc::Truncate().

Here is the caller graph for this function:

bool hsm_ReleaseCandRec::IsValid (  ) 

Definition at line 181 of file hsm_FHrelc.cpp.

References hdb_ReleaseCand_t::appendTime, dbg_NORM, hdb_ReleaseCand_t::fileID, hdb_ReleaseCand_t::fileType, FindNextRec(), hdb_ReleaseCand_t::generalInode, fio_File::GetFileName(), ie_HSMDB_ERROR, log_DBG_m, log_FUNC_m, m_cirFile, m_idx, m_releaseCandRec, m_releaseCandRec_x, hdb_ReleaseCand_t::nameOwnIdx, and fio_CirFileTrans::ReadRec().

Referenced by hsm_FHrelc::Truncate().

                                 {
    log_FUNC_m(IsRelCandValid);

    hdb_ReleaseCand_t relCand; // record with zerroes
    cmn_MutexLock l(m_releaseCandRec_x);
    m_cirFile.ReadRec(m_idx, &relCand, 1);
    if (relCand.appendTime == 0) {
        // record removed recently
        log_DBG_m(dbg_NORM, "Release candidate on idx " << m_idx
            << " removed recently " << m_releaseCandRec);
        FindNextRec();
        return false;
    } 
    else if (  (relCand.fileID       != m_releaseCandRec.fileID)
            || (relCand.generalInode != m_releaseCandRec.generalInode) 
            || (relCand.nameOwnIdx   != m_releaseCandRec.nameOwnIdx
            || (relCand.fileType)    != m_releaseCandRec.fileType)) {
        // strange not same file, throw internal error
        ostringstream sstr;
        sstr << " Not the same record in circular file " << m_cirFile.GetFileName() << endl
             << " In memory : " << m_releaseCandRec << endl
             << " read from index " << m_idx << endl
             << relCand;
             
        throw ivd_InternalError(ie_HSMDB_ERROR, sstr.str(), true);
    }
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void hsm_ReleaseCandRec::MoveToEnd ( hsm_FileHeader a_fh_p,
fio_Transaction a_trans 
)

Definition at line 211 of file hsm_FHrelc.cpp.

References log_FUNC_m.

void hsm_ReleaseCandRec::Reconfigure ( ivd_Time32_t  a_RetentionTime  )  [inline]

Definition at line 99 of file hsm_FHrelc.h.

References m_retaintionTime.

Referenced by hsm_FHrelc::Reconfigure().

{m_retaintionTime = a_RetentionTime;};

Here is the caller graph for this function:

void hsm_ReleaseCandRec::Release ( hsm_FileHeader a_fh_p,
fio_Transaction a_trans 
)

Definition at line 161 of file hsm_FHrelc.cpp.

References dbg_DETAIL, FindNextRec(), fio_File::GetFileName(), hsm_FileHeader::GetFName(), hsm_ListPos::GetRelCandIdx(), log_DBG_m, log_FUNC_m, m_cirFile, m_idx, m_releaseCandRec_x, and fio_CirFileTrans::WriteRec().

Referenced by hsm_FHrelc::Release().

                                                           {
    log_FUNC_m(Release);

    ivd_RecordIDX_t idx = a_fh_p->GetRelCandIdx();

    log_DBG_m(dbg_DETAIL, "remove file " << a_fh_p->GetFName() 
                          << " from " << m_cirFile.GetFileName());

    hdb_ReleaseCand_t relCand; // record with zerroes
    m_cirFile.WriteRec(idx, &relCand, 1, a_trans);

    cmn_MutexLock l(m_releaseCandRec_x);
    
    if (m_idx == idx) { // if current record is released, then read next
        FindNextRec();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 51 of file hsm_FHrelc.h.

Definition at line 54 of file hsm_FHrelc.h.

Referenced by Append(), FindNextClearCurrRec(), FindNextRec(), IsValid(), and Release().

Definition at line 58 of file hsm_FHrelc.h.

Referenced by Append(), FindNextClearCurrRec(), FindNextRec(), IsValid(), and Release().

Definition at line 59 of file hsm_FHrelc.h.

Referenced by Append(), FindNextRec(), GetRefRleaseCandRec(), GetRemoveTime(), and IsValid().

Definition at line 61 of file hsm_FHrelc.h.

Referenced by Append(), FindNextClearCurrRec(), IsValid(), and Release().

how much time must files wait on release candidate list

Definition at line 56 of file hsm_FHrelc.h.

Referenced by Append(), GetRemoveTime(), and Reconfigure().


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