Public Member Functions | Private Attributes

fsc_DataLMgr Class Reference
[File System Catalog]

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

#include <fsc_DataLMgr.h>

Collaboration diagram for fsc_DataLMgr:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fsc_DataLMgr (fio_Transaction *a_trans_p)
 Default constructor.
 fsc_DataLMgr (int a_cacheSize, fio_Transaction *a_trans_p)
void FastInsert (df_SplitInfo &a_splitInfo)
 NOTE! used only for one thread at once.
void FlushChangesAndCleanCache ()
 Every now and then is good to flush data, most common time is when number of different fileID are near to cache size.
void Insert (df_SplitInfo &a_splitInfo)
 Insert a split into Data location tree.
void Remove (const string &a_partName, ivd_MediaKey_t a_mediumKey, ivd_MedVolNum_t a_medVolNum)
 Remove all entries from particular volume.
bool Remove (ivd_RecordIDX_t a_fileID, ivd_MediaKey_t a_mediumKey, ivd_MedVolNum_t a_medVolNum, UInt32_t a_blockOffs)
 Remove one particular entry.
fsc_DataLFindDataL (ivd_RecordIDX_t a_fileID)
void GetBunchOfFileIDs (ivd_RecIdxVec_t &a_recIdxVec, UInt32_t a_num, fio_Transaction &a_trans)
void GetCopiesPos (ivd_CopiesPos_v_t &a_copiesPos_v, ivd_FileID_t a_fileID, 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, UInt32_t a_numPools, const fsc_MediumStatus_v &a_ms)
void DumpTree (ostream &os, ivd_FileID_t a_fileID)
bool TreeWalk (ivd_FileID_t a_fileID, fsc_Collector &a_collector)
void GetHistory (ivd_FileID_t a_fileID, fsc_GenIDsize_v &a_generations, ivd_MigrationID_t &a_nscMigID, string &a_path)
UInt32_t GetNumOfUsedFileID ()
void NumCopiesVsNumPoolsCheck (i_FSCNumCopVsNumPoolsCheckStatus_t &state, ivd_CopiesPos_v_t tmpCopiesPos_v, UInt32_t a_numPools, const fsc_MediumStatus_v &a_ms)
fsc_DataLGetDataL (ivd_RecordIDX_t a_fileID)

Private Attributes

fio_RelFileTransm_relFile
 this is pointer to relative file "fsc_xxxx.lrf" object.
 log_CLASSID_m

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 71 of file fsc_DataLMgr.h.


Constructor & Destructor Documentation

fsc_DataLMgr::fsc_DataLMgr ( fio_Transaction a_trans_p  ) 

Default constructor.

construct for recall the FileID

Definition at line 60 of file fsc_DataLMgr.cpp.

References g_fsc_trans_p, and log_FUNC_m.

        :
        m_relFile(*g_dataLRF_p)
{
    log_FUNC_m(fsc_DataLMgr);
    g_fsc_trans_p = a_trans_p;
    //empty
}

fsc_DataLMgr::fsc_DataLMgr ( int  a_cacheSize,
fio_Transaction a_trans_p 
)

Definition at line 70 of file fsc_DataLMgr.cpp.

References g_fsc_trans_p, and log_FUNC_m.


Member Function Documentation

void fsc_DataLMgr::CheckLastGen ( string &  a_status,
i_FSCfileState_t a_FSCFileState,
const i_IvdfsFileInfo_t a_ivdFSfileInfo,
ivd_MigrationID_t a_migID,
UInt32_t  a_numPools,
const fsc_MediumStatus_v a_ms 
)

Definition at line 269 of file fsc_DataLMgr.cpp.

References fsc_DataL::CheckLastGen(), i_IvdfsFileInfo_t::fileID, i_IvdfsFileInfo_t::fileSize, i_FSCfileState_t::fscNumCopVsNumPoolsCheckStatus, fsc_DataL::GetCopiesPos(), GetDataL(), ivd_BaseException::GetError(), log_FUNC_m, and NumCopiesVsNumPoolsCheck().

Referenced by i_FSC_i::CheckWithIVDFS().

                                                                              {
    log_FUNC_m(CheckLastGen);

    ivd_FileID_t fileID = a_ivdFSfileInfo.fileID;
    fsc_fileIDLock l(fileID);

    fsc_DataL *data_p = GetDataL(fileID);
    data_p->CheckLastGen(a_status, a_FSCFileState, a_ivdFSfileInfo, a_migID);
    
    // Calling getCopiesPos on directory always rises exception because Dir has no DATA
    // IMPROVMENT: IvdFSfile info could be extended to contain type info (DIR, FILE,...)
    // can be done by extending the structure IvdfsFileInfo on HSM side see treewalk.cpp
    if (a_status.empty() ) {
        ivd_MigrationID_t tmpMigID = 0;
        ivd_CopiesPos_v_t tmpCopiesPos_v;
        try {
            data_p->GetCopiesPos(tmpCopiesPos_v, tmpMigID, a_ivdFSfileInfo.fileSize);
            NumCopiesVsNumPoolsCheck(
                a_FSCFileState.fscNumCopVsNumPoolsCheckStatus, 
                tmpCopiesPos_v, 
                a_numPools, 
                a_ms);
        }
        catch (ivd_Error &ie) {
            // if the error thrown is because file has no data just "ignore" it
            if (ie.GetError() != ie_FSC_NOCOPIES) {
                throw;
            }
        }
    }

    delete data_p;   
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataLMgr::DumpTree ( ostream &  os,
ivd_FileID_t  a_fileID 
)

Definition at line 319 of file fsc_DataLMgr.cpp.

References fsc_DataL::Dump(), g_DataLcache, stx_CacheArray< _MaxCacheSize >::Get(), GetDataL(), log_FUNC_m, and NULL.

Referenced by Interactive(), and main().

                                                              {
    log_FUNC_m(DumpTree);

    fsc_fileIDLock l(a_fileID);

    bool dumpCreateIt = false;
    fsc_DataL* data_p = static_cast<fsc_DataL*>(g_DataLcache.Get(a_fileID));
    if (data_p == NULL) {
        data_p = GetDataL(a_fileID);
        dumpCreateIt = true;
    }
//    fsc_DataL *data_p = GetDataL(a_fileID);
    if (data_p == NULL) {
        os << "No data for fileID " << a_fileID << endl;
        return;
    }
    os << "================================" << endl;
    os << "Tree for fileID " << a_fileID << endl;

    data_p->Dump(os);
    if (dumpCreateIt) {
        delete data_p;   
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataLMgr::FastInsert ( df_SplitInfo a_splitInfo  ) 

NOTE! used only for one thread at once.

Definition at line 386 of file fsc_DataLMgr.cpp.

References df_SplitInfo::fileID, g_DataLcache, stx_CacheArray< _MaxCacheSize >::Get(), GetDataL(), fsc_DataL::Insert(), stx_CacheArray< _MaxCacheSize >::Insert(), fsc_DataL::IsFree(), and NULL.

Referenced by Insert(), and fsc_FRIunpacker::ProcSplitInfo().

                                                       {    
//    log_FUNC_m(FastInsert);

    ivd_RecordIDX_t fileID = a_splitInfo.fileID;
    fsc_fileIDLock l(fileID);

    fsc_DataL* data_p = static_cast<fsc_DataL*>(g_DataLcache.Get(fileID));
    if (data_p == NULL) {
        data_p = GetDataL(fileID);
        g_DataLcache.Insert(data_p);
    }

    if (data_p->IsFree()) { // element is freee to use
        new (data_p) fsc_DataL(a_splitInfo);
    }
    else {
        data_p->Insert(a_splitInfo);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

fsc_DataL* fsc_DataLMgr::FindDataL ( ivd_RecordIDX_t  a_fileID  ) 
void fsc_DataLMgr::FlushChangesAndCleanCache (  ) 

Every now and then is good to flush data, most common time is when number of different fileID are near to cache size.

transaction is startted before flush and stopped soon after.

Definition at line 409 of file fsc_DataLMgr.cpp.

References stx_CacheArray< _MaxCacheSize >::CleanUpAndNotify(), fio_Transaction::EndTransaction(), g_DataLcache, g_fsc_trans_p, log_FUNC_m, and fio_Transaction::StartTransaction().

Referenced by i_FSC_i::FSCRecovery(), Insert(), i_FSC_i::InsertSplitFromFRIBlock(), fsc_FRIunpacker::ProcSplitInfo(), and Remove().

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataLMgr::GetBunchOfFileIDs ( ivd_RecIdxVec_t &  a_recIdxVec,
UInt32_t  a_num,
fio_Transaction a_trans 
)

Definition at line 173 of file fsc_DataLMgr.cpp.

References fio_Transaction::AbortTransaction(), fio_Transaction::EndTransaction(), fio_RelFileTrans::GetBunchOfVectorIDXes(), log_FUNC_m, m_relFile, fio_Transaction::StartTransaction(), and fio_RelFile::WriteRec().

Referenced by i_FSC_i::GetFileIDs().

                                                               {
    log_FUNC_m(GetBunchOfFileIDs);

    a_recIdxVec.clear();
    a_recIdxVec.resize(a_num);

    a_trans.StartTransaction();
    
    try {
        m_relFile.GetBunchOfVectorIDXes(a_recIdxVec, 
                                        1,  // vector size
                                        &a_trans);

        fsc_DataL_t dataL;  // some empty record to reset into DataL relative file

        // write empty records to all indeces
        for (ivd_RecIdxVec_i iter = a_recIdxVec.begin();
             iter != a_recIdxVec.end();
             iter++) {
            m_relFile.WriteRec(*iter, &dataL, 1, &a_trans);
        }
    }
    catch (...) {
        a_trans.AbortTransaction();
        throw;
    }

    a_trans.EndTransaction();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataLMgr::GetCopiesPos ( ivd_CopiesPos_v_t a_copiesPos_v,
ivd_FileID_t  a_fileID,
ivd_MigrationID_t a_migID,
ivd_FileSize_t  a_fileSize 
)

Definition at line 206 of file fsc_DataLMgr.cpp.

References fsc_DataL::GetCopiesPos(), GetDataL(), and log_FUNC_m.

Referenced by i_FSC_i::EfficientRecallGetLocations(), and i_FSC_i::GetCopiesPos().

                                                               {
    log_FUNC_m(GetCopiesPos);

    fsc_fileIDLock l(a_fileID);

    fsc_DataL *data_p = GetDataL(a_fileID);
    data_p->GetCopiesPos(a_copiesPos_v, a_migID, a_fileSize);
    delete data_p;   
}

Here is the call graph for this function:

Here is the caller graph for this function:

fsc_DataL* fsc_DataLMgr::GetDataL ( ivd_RecordIDX_t  a_fileID  )  [inline]

Definition at line 146 of file fsc_DataLMgr.h.

Referenced by CheckLastGen(), DumpTree(), FastInsert(), GetCopiesPos(), GetHistory(), and Remove().

                                                  {
        return new fsc_DataL(a_fileID);
    };

Here is the caller graph for this function:

void fsc_DataLMgr::GetHistory ( ivd_FileID_t  a_fileID,
fsc_GenIDsize_v a_generations,
ivd_MigrationID_t a_nscMigID,
string &  a_path 
)

Definition at line 368 of file fsc_DataLMgr.cpp.

References GetDataL(), fsc_DataL::GetFullPath(), log_FUNC_m, and fsc_DataL::TreeWalk().

Referenced by i_FSC_i::GetFileHistory().

                                                         {
    log_FUNC_m(GetHistory);
    
    fsc_ColGeneration colGen(a_fileID, a_generations);

    fsc_DataL *data_p = GetDataL(a_fileID);

    fsc_fileIDLock l(a_fileID);

    data_p->TreeWalk(colGen);
    data_p->GetFullPath(a_nscMigID, a_path);
    delete data_p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt32_t fsc_DataLMgr::GetNumOfUsedFileID (  )  [inline]

Definition at line 138 of file fsc_DataLMgr.h.

References fio_RelFile::GetNumOfRecord().

{ return m_relFile.GetNumOfRecord(); };

Here is the call graph for this function:

void fsc_DataLMgr::Insert ( df_SplitInfo a_splitInfo  ) 

Insert a split into Data location tree.

Definition at line 80 of file fsc_DataLMgr.cpp.

References FastInsert(), FlushChangesAndCleanCache(), g_DataLcache, g_fscUpdate_x, log_FUNC_m, and stx_CacheArray< _MaxCacheSize >::Resize().

Referenced by fsc_VolumeCheck::Check().

                                                   {
    log_FUNC_m(Insert);

    cmn_MutexLock l(g_fscUpdate_x);
    // cache size will return at destructor
    g_DataLcache.Resize(1);
    FastInsert(a_splitInfo);
    FlushChangesAndCleanCache();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_DataLMgr::NumCopiesVsNumPoolsCheck ( i_FSCNumCopVsNumPoolsCheckStatus_t state,
ivd_CopiesPos_v_t  tmpCopiesPos_v,
UInt32_t  a_numPools,
const fsc_MediumStatus_v a_ms 
)

Definition at line 220 of file fsc_DataLMgr.cpp.

References i_FSCNumCopVsNumPoolsCheckStatus_t::changed, i_FSCNumCopVsNumPoolsCheckStatus_t::copiesExpected, i_FSCNumCopVsNumPoolsCheckStatus_t::copiesFound, log_FUNC_m, i_FSCNumCopVsNumPoolsCheckStatus_t::splitInWrongPool, and i_FSCNumCopVsNumPoolsCheckStatus_t::tooMuchCopiesPerPool.

Referenced by CheckLastGen().

                                                                                       {
    log_FUNC_m(NumCopiesVsNumPoolsCheck);

    vector <UInt32_t> copyCounter_v; //vector index = pool number, vector contents = copies per pool
    UInt32_t numOfCopies(0);  //only first copy from a pool is counted

    for (UInt32_t i = 0; i < tmpCopiesPos_v.size(); ++i) {
        UInt32_t poolKey(0);
        for (UInt32_t j = 0; j < tmpCopiesPos_v[i].size(); ++j) {
            UInt32_t msPoolKey = a_ms[tmpCopiesPos_v[i][j].mediaKey].mediaPoolKey;
            if (poolKey == 0) {
                poolKey = msPoolKey;
            }
            else if (poolKey != msPoolKey && !state.splitInWrongPool) {
                state.splitInWrongPool = true;
                state.changed = true;
           }
        }

        UInt32_t copyCounter_v_Size;

        while(poolKey + 1 > copyCounter_v.size()) {
            copyCounter_v_Size = copyCounter_v.size();
            copyCounter_v.resize(copyCounter_v_Size + 1);
            copyCounter_v[copyCounter_v_Size] = 0;
        }
        ++copyCounter_v[poolKey];

        //count only first copy in pool, other copy is skipped from count
        if (copyCounter_v[poolKey] == 1) {
            ++numOfCopies;
        }
        else if (copyCounter_v[poolKey] > 2) {
            state.tooMuchCopiesPerPool = true;
            state.changed = true;
        }
    }

    if (numOfCopies != a_numPools) {
        state.copiesFound = numOfCopies;
        state.copiesExpected = a_numPools;
        state.changed = true;
    }
}

Here is the caller graph for this function:

bool fsc_DataLMgr::Remove ( ivd_RecordIDX_t  a_fileID,
ivd_MediaKey_t  a_mediumKey,
ivd_MedVolNum_t  a_medVolNum,
UInt32_t  a_blockOffs 
)

Remove one particular entry.

Definition at line 146 of file fsc_DataLMgr.cpp.

References FlushChangesAndCleanCache(), g_DataLcache, g_fscUpdate_x, stx_CacheArray< _MaxCacheSize >::Get(), GetDataL(), stx_CacheArray< _MaxCacheSize >::Insert(), log_FUNC_A_m, NULL, fsc_DataL::Remove(), Remove(), and stx_CacheArray< _MaxCacheSize >::Resize().

                                                           {
    log_FUNC_A_m(Remove(), "a_fileID" << a_fileID );
    
    cmn_MutexLock l(g_fscUpdate_x);
    bool ret = false;
    
    g_DataLcache.Resize(1);
    
        fsc_DataL* data_p;  
        {  // lock and auto unlock
            fsc_fileIDLock l(a_fileID);
            data_p = static_cast<fsc_DataL*>(g_DataLcache.Get(a_fileID));
            if (data_p == NULL) {
                data_p = GetDataL(a_fileID);
                g_DataLcache.Insert(data_p);
            }
            ret = data_p->Remove(a_mediumKey, a_medVolNum, a_blockOffs);
        }
        
    FlushChangesAndCleanCache();
    return ret;
}

Here is the call graph for this function:

void fsc_DataLMgr::Remove ( const string &  a_partName,
ivd_MediaKey_t  a_mediumKey,
ivd_MedVolNum_t  a_medVolNum 
)

Remove all entries from particular volume.

Definition at line 91 of file fsc_DataLMgr.cpp.

References ivd_FileLocationData_t::fileID, FlushChangesAndCleanCache(), g_DataLcache, g_fscUpdate_x, stx_CacheArray< _MaxCacheSize >::Get(), GetDataL(), fsc_DataCollectorStorage::GetNextRecord(), stx_CacheArray< _MaxCacheSize >::Insert(), cmn_Mutex::Lock(), log_FUNC_m, NULL, fsc_DataL::Remove(), stx_CacheArray< _MaxCacheSize >::Resize(), and cmn_Mutex::Unlock().

Referenced by fsc_VolumeCheck::Check(), fsc_CollectorDelete::ProcRecMedPosMgr(), i_FSC_i::ReleaseVolEntries(), Remove(), and fsc_VolumeCheck::RestDataHandle().

                                                           {
    log_FUNC_m(Remove);
    // cache size will return at destructor
    
    fsc_ReorgScanContentVolStorage volCont( 0,
                                            a_partName, 
                                            a_mediumKey, 
                                            a_medVolNum,
                                            false);
    //false == do not create files, they already exist
    
                                                    
    int transCount = 0;
    int cachSize = 1024;
    
    g_fscUpdate_x.Lock();
    g_DataLcache.Resize(cachSize);
    
    ivd_FileLocationData_t locData;
    ivd_RecordIDX_t lastFileID = 0;
    while (!volCont.GetNextRecord(locData)) {

        if (lastFileID == locData.fileID) {
            continue;
        }
        else {
            lastFileID = locData.fileID;
        }
        
        fsc_DataL* data_p;  
        {  // lock and auto unlock
            fsc_fileIDLock l(locData.fileID);
            data_p = static_cast<fsc_DataL*>(g_DataLcache.Get(locData.fileID));
            if (data_p == NULL) {
                data_p = GetDataL(locData.fileID);
                g_DataLcache.Insert(data_p);
            }
            data_p->Remove(a_mediumKey, a_medVolNum);
        }
        
        if (++transCount >= cachSize) {
            transCount = 0;
            FlushChangesAndCleanCache();
            g_fscUpdate_x.Unlock(); // let others to take a breath
            g_fscUpdate_x.Lock();
            g_DataLcache.Resize(cachSize);  // cache may resize
        }        
    };    
    FlushChangesAndCleanCache();
    g_fscUpdate_x.Unlock();
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool fsc_DataLMgr::TreeWalk ( ivd_FileID_t  a_fileID,
fsc_Collector a_collector 
)

Member Data Documentation

Definition at line 85 of file fsc_DataLMgr.h.

this is pointer to relative file "fsc_xxxx.lrf" object.

It's not need to delete it in destructor

Definition at line 83 of file fsc_DataLMgr.h.

Referenced by GetBunchOfFileIDs().


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