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

fsc_DataL Class Reference
[File System Catalog]

<Description:> A more elaborate class description that describes all aspects of class usage etc. More...

#include <fsc_DataL.h>

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

List of all members.

Public Member Functions

 fsc_DataL ()
 fsc_DataL (df_SplitInfo &a_splitInfo)
 fsc_DataL (ivd_RecordIDX_t a_fileID)
 ~fsc_DataL ()
virtual void RemoveNotification ()
 write changes to DB before it's removed from cache
fsc_DataL_tGetDataLPtr ()
bool IsFree ()
void Insert (df_SplitInfo &a_splitInfo)
 Insert a split into Data location tree.
void Remove (ivd_MediaKey_t a_mediumKey, ivd_MedVolNum_t a_medVolNum)
 Remove all entries from particular volume.
bool Remove (ivd_MediaKey_t a_mediumKey, ivd_MedVolNum_t a_medVolNum, UInt32_t a_blockOffs)
 Remove one particular entry.
void WriteToBuff (fsc_DataL_t *a_datal_p)
void GetCopiesPos (ivd_CopiesPos_v_t &a_copiesPos_v, ivd_MigrationID_t &a_migID, ivd_FileSize_t a_fileSize)
void CheckLastGen (string &a_status, i_FSCfileState_t &a_FSCFileState, const i_IvdfsFileInfo_t &a_ivdFSfileInfo, ivd_MigrationID_t &a_migID)
void ReadMembers ()
void Dump (ostream &os)
bool TreeWalk (fsc_Collector &a_collector)
void GetFullPath (ivd_MigrationID_t &a_nscMigID, string &a_path)

Public Attributes

 log_CLASSID_m

Private Member Functions

void Write2DB (fio_Transaction &a_trans)
 Write is called at remove from cache Write2DB method count unused media position records reserved for many copies or splits.

Private Attributes

fsc_GenerationMgrm_generationMgr_p
bool m_changed
ivd_RecordIDX_t m_fileID
fsc_DataL_t m_dataL
fsc_nsElementm_nsElement

Friends

class fsc_SplitInfoCollector

Detailed Description

<Description:> A more elaborate class description that describes all aspects of class usage etc.

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

Definition at line 65 of file fsc_DataL.h.


Constructor & Destructor Documentation

fsc_DataL::fsc_DataL (  ) 

Definition at line 53 of file fsc_DataL.cpp.

Referenced by fsc_DataL().

Here is the caller graph for this function:

fsc_DataL::fsc_DataL ( df_SplitInfo a_splitInfo  ) 

Definition at line 66 of file fsc_DataL.cpp.

References df_SplitInfo::fileID, df_SplitInfo::fileType, fsc_nsCreateElementObj(), g_updateNSC, giaNEWEST_GEN, ift_DIR, fsc_nsElement::InsertSplit(), m_dataL, m_generationMgr_p, m_nsElement, and fsc_DataL_t::numOfMigration.

            :
            stx_CacheEl(a_splitInfo.fileID),
            m_generationMgr_p(NULL),
            m_changed(false),
            m_fileID(a_splitInfo.fileID)
{
//    log_FUNC_m(fsc_DataL(df_SplitInfo));
    m_dataL.numOfMigration = 1;  // history reasons
    //if (a_splitInfo.fileType == ift_DIR) {
    //    m_dataL.flags = dlfDirectory;
    //}

    m_generationMgr_p = new fsc_GenerationMgr(a_splitInfo);

    if (g_updateNSC) {
        m_nsElement = fsc_nsCreateElementObj(a_splitInfo.fileID, 
                                             a_splitInfo.fileType == ift_DIR);
        m_nsElement->InsertSplit(a_splitInfo, giaNEWEST_GEN); // new gen
    }
    else {
        m_nsElement = NULL;
    }
}

Here is the call graph for this function:

fsc_DataL::fsc_DataL ( ivd_RecordIDX_t  a_fileID  ) 

Definition at line 93 of file fsc_DataL.cpp.

References cmn_HexDump(), dbg_DETAIL, fsc_DataL_t::flags, fsc_DataL(), fsc_DataL_t::generationIdx, log_DBG_m, log_FUNC_m, m_dataL, m_fileID, fsc_DataL_t::numOfAllGen, and fsc_DataL_t::numOfElement.

            :
            stx_CacheEl(a_fileID),
            m_generationMgr_p(NULL),
            m_changed(false),
            m_fileID(a_fileID),
            m_dataL(a_fileID),
            m_nsElement(NULL)
{
    log_FUNC_m(fsc_DataL(fsc_DataL));
    log_DBG_m(dbg_DETAIL, "R DataL from idx (fileID) = " << m_fileID << endl 
             << "  flags         " << hex << (int)m_dataL.flags << dec << endl
             << "  numOfAllGen   " << m_dataL.numOfAllGen << endl
             << "  numOfElement  " << (int)m_dataL.numOfElement << endl
             << "  generationIdx " << m_dataL.generationIdx << endl
     << cmn_HexDump(&m_dataL, sizeof(fsc_DataL_t), sizeof(fsc_DataL_t), false) );
}

Here is the call graph for this function:

fsc_DataL::~fsc_DataL (  )  [inline]

Definition at line 72 of file fsc_DataL.h.

References fsc_nsRemoveElementObj(), m_generationMgr_p, m_nsElement, and NULL.

                 {
        if (m_generationMgr_p != NULL) {
            delete m_generationMgr_p;
        }
        if (m_nsElement != NULL) {
            // todo call fsc_nsRemoveElementObj
            fsc_nsRemoveElementObj(m_nsElement);
        }
    };

Here is the call graph for this function:


Member Function Documentation

void fsc_DataL::CheckLastGen ( string &  a_status,
i_FSCfileState_t a_FSCFileState,
const i_IvdfsFileInfo_t a_ivdFSfileInfo,
ivd_MigrationID_t a_migID 
)

Definition at line 233 of file fsc_DataL.cpp.

References fsc_nsElement::CheckLastGen(), fsc_GenerationMgr::CheckLastGen(), i_IvdfsFileInfo_t::fileID, fsc_nsCreateElementObj(), g_updateNSC, fsc_DataL_t::generationIdx, log_FUNC_m, m_dataL, m_generationMgr_p, m_nsElement, NULL, and ReadMembers().

Referenced by fsc_DataLMgr::CheckLastGen().

                                                              {
    log_FUNC_m(CheckLastGen);

    if (m_dataL.generationIdx == 0) {
        a_status += "    Missing in FSC.\n";
    }
    else {
        ReadMembers();
        if (m_generationMgr_p == NULL) { 
            a_status += "    Missing in FSC.\n";
        }
        else {
            m_generationMgr_p->CheckLastGen(a_status, a_migID);
            if (!a_status.empty()) {
                return;
            }

            if (g_updateNSC) {
                if (m_nsElement == NULL) {
                    m_nsElement = fsc_nsCreateElementObj(a_ivdFSfileInfo.fileID);
                }
                // a_migID is updated by m_generationMgr_p->CheckLastGen() call
                m_nsElement->CheckLastGen(a_status, a_FSCFileState, a_ivdFSfileInfo, a_migID);
            }
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataL::Dump ( ostream &  os  ) 

Definition at line 311 of file fsc_DataL.cpp.

References fsc_nsElement::Dump(), fsc_GenerationMgr::Dump(), fsc_nsCreateElementObj(), fsc_DataL_t::generationIdx, log_FUNC_m, m_dataL, m_fileID, m_generationMgr_p, m_nsElement, NULL, fsc_DataL_t::numOfAllGen, fsc_DataL_t::numOfElement, and ReadMembers().

Referenced by fsc_DataLMgr::DumpTree().

                                {    
    log_FUNC_m(Dump);
/*    if (m_dataL.flags & dlfDirectory) {
        os << "  DIR\n";
    }
    else {
        os << "  FILE\n";
    } 
*/
    os << "   Generation idx     = " << m_dataL.generationIdx << endl;
//    os << "   First vec size     = " << (int)m_dataL.numOfElement << endl;
    os << "   Number of all gen  = " << m_dataL.numOfAllGen << endl;

    ReadMembers();
    if (m_generationMgr_p == NULL) {
        os << "   No generations for this file. size = " << m_dataL.numOfElement 
            << " idx = " << m_dataL.generationIdx << endl;
    }
    else {
        m_generationMgr_p->Dump(os);
    }
    os << "  NSC\n";
    if (m_nsElement == NULL) {
        m_nsElement = fsc_nsCreateElementObj(m_fileID);
    }
    m_nsElement->Dump(os);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataL::GetCopiesPos ( ivd_CopiesPos_v_t a_copiesPos_v,
ivd_MigrationID_t a_migID,
ivd_FileSize_t  a_fileSize 
)

Definition at line 171 of file fsc_DataL.cpp.

References dbg_DETAIL, dbg_NORM, evt_ERROR, fsc_nsCreateElementObj(), g_updateNSC, fsc_GenerationMgr::GetCopiesPos(), fsc_nsElement::GetFileSize(), fsc_nsElement::IsDirectory(), log_DBG_m, log_ERR_m, log_FUNC_m, log_WriteEvent(), m_fileID, m_generationMgr_p, m_nsElement, NULL, ReadMembers(), and size.

Referenced by fsc_DataLMgr::CheckLastGen(), and fsc_DataLMgr::GetCopiesPos().

                                                            {
    log_FUNC_m(GetCopiesPos);

    ReadMembers();
    if (   a_migID == 0   // get copies from newest generation
        && g_updateNSC) {
        if (m_nsElement == NULL) {
            m_nsElement = fsc_nsCreateElementObj(m_fileID);
        }
        // check if file Sizematch
        ivd_FileSize_t size = m_nsElement->GetFileSize();
        if (   size > 0  // maybe attributes not set yet
            && a_fileSize > 0 // not need to check if is 0
            && size != a_fileSize) {
            string a_type = m_nsElement->IsDirectory()? "Dir" : "File";
            ostringstream sstr;
            sstr << "File size for " << a_type
                 << " item doesn't match. fileID = " << m_fileID
                 << " HSMFS size = " << a_fileSize
                 << " NSC size = " << size;
            if (m_nsElement->IsDirectory()) {
                log_DBG_m(dbg_NORM, sstr.str());
            }
            else {
                log_ERR_m(sstr.str());
                log_DBG_m(dbg_NORM, sstr.str());
                log_WriteEvent(evt_ERROR, sstr.str());
                return; // no copies possition found
            }
        }
        else {
            log_DBG_m(dbg_DETAIL, "FileID = " << m_fileID
                               << " NSC size = " << size);
        }
    }

    fsc_MigInfo_t migInfo(m_fileID);
    if (m_generationMgr_p != NULL) { 
        m_generationMgr_p->GetCopiesPos(a_copiesPos_v, a_migID, migInfo);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

fsc_DataL_t* fsc_DataL::GetDataLPtr (  )  [inline]

Definition at line 102 of file fsc_DataL.h.

References m_dataL.

{ return &m_dataL; };

void fsc_DataL::GetFullPath ( ivd_MigrationID_t a_nscMigID,
string &  a_path 
)

Definition at line 340 of file fsc_DataL.cpp.

References fsc_nsCreateElementObj(), fsc_nsElement::GetFullPath(), fsc_nsElement::GetMigID(), m_fileID, m_nsElement, and NULL.

Referenced by fsc_DataLMgr::GetHistory().

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataL::Insert ( df_SplitInfo a_splitInfo  ) 

Insert a split into Data location tree.

Definition at line 113 of file fsc_DataL.cpp.

References cmn_Global::dbg, dbg_DETAIL, dbg_NORM, df_SplitInfo::Dump(), df_SplitInfo::fileID, df_SplitInfo::fileType, fsc_nsCreateElementObj(), g_cmn, g_updateNSC, fsc_GenerationMgr::GetGenInsertAct(), log_Debugger::GetLevel(), ift_DIR, fsc_GenerationMgr::Insert(), fsc_nsElement::InsertSplit(), log_DBG_m, log_FUNC_m, m_generationMgr_p, m_nsElement, NULL, and ReadMembers().

Referenced by fsc_DataLMgr::FastInsert().

                                                 {
    log_FUNC_m(Insert);

    if (g_cmn.dbg.GetLevel() == dbg_DETAIL) {
        log_DBG_m(dbg_DETAIL, a_splitInfo.Dump());
    }
    else {
        log_DBG_m(dbg_NORM, "InsertSplit FileID = " << a_splitInfo.fileID);
    }
    
    ReadMembers();
    if (m_generationMgr_p == NULL) { 
        m_generationMgr_p = new fsc_GenerationMgr(a_splitInfo);
    }
    else {  
        m_generationMgr_p->Insert(a_splitInfo);
    }

    if (g_updateNSC) {
        if (m_nsElement == NULL) {
            m_nsElement = fsc_nsCreateElementObj(a_splitInfo.fileID, 
                                                    a_splitInfo.fileType == ift_DIR);
        }
        m_nsElement->InsertSplit(a_splitInfo, m_generationMgr_p->GetGenInsertAct());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool fsc_DataL::IsFree (  )  [inline]

Definition at line 104 of file fsc_DataL.h.

References fsc_DataL_t::generationIdx, m_dataL, and m_generationMgr_p.

Referenced by fsc_DataLMgr::FastInsert().

                  { return m_dataL.generationIdx == 0 
                        && m_generationMgr_p     == NULL; };

Here is the caller graph for this function:

void fsc_DataL::ReadMembers (  )  [inline]

Definition at line 132 of file fsc_DataL.h.

References fsc_DataL_t::generationIdx, m_dataL, m_generationMgr_p, and NULL.

Referenced by CheckLastGen(), Dump(), GetCopiesPos(), Insert(), Remove(), and TreeWalk().

Here is the caller graph for this function:

bool fsc_DataL::Remove ( ivd_MediaKey_t  a_mediumKey,
ivd_MedVolNum_t  a_medVolNum,
UInt32_t  a_blockOffs 
)

Remove one particular entry.

Definition at line 155 of file fsc_DataL.cpp.

References fsc_nsCreateElementObj(), log_FUNC_m, m_fileID, m_generationMgr_p, m_nsElement, nse_CREATE_PARENT, NULL, ReadMembers(), fsc_GenerationMgr::Remove(), and Remove().

                                                        {
    log_FUNC_m(Remove(split));
    
    ReadMembers();
    if (m_nsElement == NULL) {
        m_nsElement = fsc_nsCreateElementObj(m_fileID, nse_CREATE_PARENT);
    }
    if (m_generationMgr_p != NULL) { 
        return m_generationMgr_p->Remove(a_mediumKey, a_medVolNum, a_blockOffs);
    }
    return false;
}

Here is the call graph for this function:

void fsc_DataL::Remove ( ivd_MediaKey_t  a_mediumKey,
ivd_MedVolNum_t  a_medVolNum 
)

Remove all entries from particular volume.

Remove entries from particular volume.

Definition at line 142 of file fsc_DataL.cpp.

References fsc_nsCreateElementObj(), log_FUNC_m, m_fileID, m_generationMgr_p, m_nsElement, nse_CREATE_PARENT, NULL, ReadMembers(), and fsc_GenerationMgr::Remove().

Referenced by fsc_DataLMgr::Remove(), and Remove().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void fsc_DataL::RemoveNotification (  )  [inline, virtual]

write changes to DB before it's removed from cache

Reimplemented from stx_CacheEl.

Definition at line 84 of file fsc_DataL.h.

References g_fsc_trans_p, and Write2DB().

Here is the call graph for this function:

bool fsc_DataL::TreeWalk ( fsc_Collector a_collector  ) 

Definition at line 217 of file fsc_DataL.cpp.

References m_generationMgr_p, NULL, fsc_Collector::ProcObjDataL(), ReadMembers(), and fsc_GenerationMgr::TreeWalk().

Referenced by fsc_DataLMgr::GetHistory().

                                                     {
//    log_FUNC_m(TreeWalk);

    ReadMembers();

    if (!a_collector.ProcObjDataL(this)){
        return false;
    }
    if (m_generationMgr_p != NULL) { 
        return m_generationMgr_p->TreeWalk(a_collector);
    }
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataL::Write2DB ( fio_Transaction a_trans  )  [private]

Write is called at remove from cache Write2DB method count unused media position records reserved for many copies or splits.

If nothing is reaserved then DataLMgr could free DataL tree.

See also:
fsc_DataLMgr Insert method

Definition at line 266 of file fsc_DataL.cpp.

References g_cmn, g_dataLRF_p, g_fsLog, g_updateNSC, fsc_DataL_t::generationIdx, fsc_nsElement::GetFullPath(), ie_FSC_NONSCELEMENTOBJ, m_changed, m_dataL, m_fileID, m_generationMgr_p, ivd_Product::m_nameShort, m_nsElement, NULL, fsc_DataL_t::numOfElement, path, cmn_Global::prod, fsc_nsElement::Remove(), log_ivdfs::Write(), fsc_nsElement::Write2DB(), fsc_GenerationMgr::Write2DB(), and fio_RelFile::WriteRec().

Referenced by RemoveNotification().

                                                {
//    log_FUNC_m(Write2DB);

    bool change = m_changed;
    if (  m_generationMgr_p != NULL 
       && m_generationMgr_p->Write2DB(m_dataL, 
                                      a_trans)) {        
        change = true;
        if (  m_dataL.generationIdx == 0
           && m_dataL.numOfElement  == 0) {
            string path;
            if (g_updateNSC) {
                if (m_nsElement == NULL) {
                    ostringstream sstr;
                    sstr << "FileID:" << m_fileID << " has no more generations and NSC object is not created."
                        << " Cannot remove NSC of this file.";
                    throw ivd_InternalError(ie_FSC_NONSCELEMENTOBJ, sstr.str(), true);
                }
                // element will be updated below 
                // but owner will be updatted when no members point to it 
                m_nsElement->GetFullPath(path);
                m_nsElement->Remove();
            }        
            else {
                path = "NSC is not available.";
            }
            string log_msg = "Deleted from " + g_cmn.prod.m_nameShort + " System by reorganization.";
            g_fsLog.Write(m_fileID, 0, path, log_msg.c_str());
        }
    }

    if (change) {
//        log_DBG_m(dbg_DETAIL, "W DataL : idx = " << m_fileID << endl <<
//            cmn_HexDump(&m_dataL, sizeof(fsc_DataL_t), sizeof(fsc_DataL_t), false) );
        g_dataLRF_p->WriteRec(m_fileID, &m_dataL, 1, &a_trans);
    }        
    if (m_nsElement != NULL) {
        m_nsElement->Write2DB(a_trans);
    }
         
    m_changed = false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataL::WriteToBuff ( fsc_DataL_t a_datal_p  )  [inline]

Definition at line 118 of file fsc_DataL.h.

                                                     {
    };


Friends And Related Function Documentation

friend class fsc_SplitInfoCollector [friend]

Definition at line 66 of file fsc_DataL.h.


Member Data Documentation

Reimplemented from stx_CacheEl.

Definition at line 99 of file fsc_DataL.h.

bool fsc_DataL::m_changed [private]

Definition at line 90 of file fsc_DataL.h.

Referenced by Write2DB().

Definition at line 93 of file fsc_DataL.h.

Referenced by CheckLastGen(), Dump(), fsc_DataL(), GetDataLPtr(), IsFree(), ReadMembers(), and Write2DB().


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