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

fsc_nsElement Class Reference
[G_new_group]

#include <fsc_nsElement.h>

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

List of all members.

Public Member Functions

 fsc_nsElement (ivd_RecordIDX_t a_fileID)
 used if you know dir entry type (file or directory) Usualy when add split info.
 fsc_nsElement (ivd_RecordIDX_t a_fileID, fsc_nsElement_t &a_elRec, nse_Opentype_e a_openType=nse_STANDARD)
 used in FSC dump, when record is read first and then checked if file or directory is read.
virtual ~fsc_nsElement (void)
virtual void Write2DB (fio_Transaction &a_trans)
 Write element changes to DB and.
virtual void InsertSplit (df_SplitInfo &a_splitInfo, fsc_GenInsertAct_e a_genInsAct)
 Take care about element ownerID (fileID of owner) and element deletion.
void Remove ()
 remove entry
void CheckLastGen (string &a_status, i_FSCfileState_t &a_FSCFileState, const i_IvdfsFileInfo_t &a_ivdFSfileInfo, ivd_MigrationID_t &a_migID)
void CheckLastGen (string &a_status, df_SplitInfo &a_splitInfo, bool a_autoCorrect, UInt32_t a_fieldStatus)
ivd_RecordIDX_t GetOwnerFileID ()
ivd_RecordIDX_t GetFileID ()
ivd_MigrationID_t GetMigID ()
ivd_FileSize_t GetFileSize ()
virtual bool IsDirectory ()
fsc_nsElement_tGetElementRecRef ()
 write changes to DB before it's removed from cache
df_StandardAttr_tGetStandAttrPtr ()
virtual void Dump (ostream &os)
void Pack (df_Packer &a_packer, char a_pathSeparator)
 fill packer, but packer could have any writer.
int GetFullPath (string &a_path, char a_pathSeparator= '/')
 fill a_path string with file and its path path separator is a_pathSeparator return 1 if found not initialized owner in that case also path is modified differently instead unknown owner the "IVD-lost+found" directory is used and file name is extended by its fileID in following format -IVD-<fileID> Example: file1.txt with fileid(12345) has owner with fileID > 0, but owner's name is not known.

Public Attributes

 log_CLASSID_m

Protected Attributes

ivd_RecordIDX_t m_fileID
fsc_nsOwnerMgrm_ownerMgrProperty_p
fsc_nsAttrMgrm_attribMgrProperty_p
fsc_nsNameMgrm_nameMgrProperty_p
fsc_nsElement_t m_elementRec
int m_refCounter

Private Member Functions

void SetMemOfOwner (ivd_RecordIDX_t a_memFileID)
void ChgOwner (ivd_RecordIDX_t a_newOwnFileID)
void ChgAttrib (df_SplitInfo &a_splitInfo, fsc_GenInsertAct_e a_genInsAct)
void ChgName (const string &a_name)

Friends

class ut_fsc_nsElement
ostream & operator<< (ostream &a_os, fsc_nsElement &a_nsElem)

Detailed Description

Definition at line 63 of file fsc_nsElement.h.


Constructor & Destructor Documentation

fsc_nsElement::fsc_nsElement ( ivd_RecordIDX_t  a_fileID  ) 

used if you know dir entry type (file or directory) Usualy when add split info.

Definition at line 81 of file fsc_nsElement.cpp.

References log_FUNC_m.

fsc_nsElement::fsc_nsElement ( ivd_RecordIDX_t  a_fileID,
fsc_nsElement_t a_elRec,
nse_Opentype_e  a_openType = nse_STANDARD 
)

used in FSC dump, when record is read first and then checked if file or directory is read.

Definition at line 93 of file fsc_nsElement.cpp.

References fsc_nsCreateOwnerMgrObj(), GetOwnerFileID(), log_FUNC_m, m_ownerMgrProperty_p, and nse_CREATE_PARENT.

Here is the call graph for this function:

fsc_nsElement::~fsc_nsElement ( void   )  [virtual]

Definition at line 110 of file fsc_nsElement.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, m_attribMgrProperty_p, m_nameMgrProperty_p, m_ownerMgrProperty_p, and NULL.

                                  {    
    log_FUNC_m(~fsc_nsElement);
    
    log_DBG_m(dbg_DETAIL, " remove EL p= " << this);
#if TGT_OS_linux
    #warning "Check this."
#elif TGT_OS_windows
    #pragma message ("Check this.")
#endif
// CR
// CR Use auto_ptr?
// CR
    if (m_ownerMgrProperty_p != NULL) {
        delete m_ownerMgrProperty_p;
    };
    if (m_attribMgrProperty_p != NULL) {
        delete m_attribMgrProperty_p;
    };
    if (m_nameMgrProperty_p != NULL) {
        delete m_nameMgrProperty_p;
    }
}


Member Function Documentation

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

Definition at line 309 of file fsc_nsElement.cpp.

References ait_NOTALLATTR, fsc_nsElement_t::attribIdx, fsc_nsElement_t::attribType, cmn_HexDump(), dbg_DETAIL, i_IvdfsFileInfo_t::fileName, i_IvdfsFileInfo_t::fileSize, fmm_FILENAME, fmm_FILESIZE, fmm_MIGID, fmm_OWNERID, fsc_MissmatchTxt_d, fsc_nsCreateAttribMgrObj(), fsc_nsCreateNameObj(), fsc_nsNameMgr::GetNameRef(), fsc_nsAttrMgr::GetStandAttrRef(), log_DBG_m, log_FUNC_m, m_attribMgrProperty_p, m_elementRec, m_nameMgrProperty_p, fsc_nsElement_t::memberIdx, fsc_nsElement_t::migID, fsc_nsElement_t::nameIdx, fsc_nsElement_t::nameType, nit_NSCMISSING, ntoh(), NULL, fsc_nsElement_t::numOfAttrib, fsc_nsElement_t::numOfName, i_IvdfsFileInfo_t::ownerID, fsc_nsElement_t::ownerIdx, i_FSCfileState_t::ownerMismatch, and df_StandardAttr_t::size.

Referenced by fsc_VolumeCheck::Check(), CheckLastGen(), and fsc_DataL::CheckLastGen().

                                                                  {
    log_FUNC_m(CheckLastGen);
    i_FileSize_t fileSize = 0;

    if (m_elementRec.nameType == nit_NSCMISSING) {
        a_status += "    No NSC.\n";
        return;
    }
    UInt32_t fieldStatus = fmm_OK;

    if (m_elementRec.migID > a_migID) {
        fieldStatus |= fmm_MIGID;
    }
    if (m_elementRec.ownerIdx != a_ivdFSfileInfo.ownerID) {
        log_DBG_m(dbg_DETAIL, "Owner mismatch");
        a_FSCFileState.ownerMismatch = true;
        fieldStatus |= fmm_OWNERID;
    } 

    if (m_nameMgrProperty_p == NULL) {
        m_nameMgrProperty_p = fsc_nsCreateNameObj(m_elementRec.numOfName, m_elementRec.nameIdx);
    }

    string fsName(a_ivdFSfileInfo.fileName);
    
    if (fsName != m_nameMgrProperty_p->GetNameRef()) {
        string &fscStr = m_nameMgrProperty_p->GetNameRef();
        log_DBG_m(dbg_DETAIL, "FS.name = '" << fsName 
                        << "' Size " << fsName.size() 
                        << " DUMP: " << cmn_HexDump(fsName.data(), fsName.size()) << endl 
                        << " FSC name = '" << fscStr
                        << "' Size " << fscStr.size() 
                        << " DUMP: " << cmn_HexDump(fscStr.data(), fscStr.size()));
        fieldStatus |= fmm_FILENAME;
    }

    if (m_elementRec.attribType == ait_NOTALLATTR) {
        a_status += string("    Some or all file's meta data missing in NSC.\n");
        goto end;
    }

    if (   m_elementRec.memberIdx == 0 ) { // is a file, so check file size

        if (m_attribMgrProperty_p == NULL) {
            m_attribMgrProperty_p = fsc_nsCreateAttribMgrObj(m_elementRec.attribType,
                                                            m_elementRec.numOfAttrib,
                                                            m_elementRec.attribIdx);
        }
        df_StandardAttr_t &standAttr = m_attribMgrProperty_p->GetStandAttrRef();
        fileSize = ntoh(standAttr.size);
        if ( fileSize != a_ivdFSfileInfo.fileSize) {
            fieldStatus |= fmm_FILESIZE;
        }
    }
end:
    if (fieldStatus) {
        ostringstream sstr;
        sstr << "    DUMP:                 FSC           HSMFS Notes" << endl;

        sstr << "    MigID    " << setw(16) << m_elementRec.migID
             << setw(16) << a_migID
             << fsc_MissmatchTxt_d(fieldStatus & fmm_MIGID);

        if (m_elementRec.attribType != ait_NOTALLATTR) {
            sstr << "    FileSize " << setw(16) << fileSize
                << setw(16) << a_ivdFSfileInfo.fileSize
                << fsc_MissmatchTxt_d(fieldStatus & fmm_FILESIZE);
        }

        sstr << "    FileName " << m_nameMgrProperty_p->GetNameRef() 
             << fsc_MissmatchTxt_d(fieldStatus & fmm_FILENAME);

        sstr << "    OwnerID  " << setw(16) << m_elementRec.ownerIdx
             << setw(16) << a_ivdFSfileInfo.ownerID
             << fsc_MissmatchTxt_d(fieldStatus & fmm_OWNERID);

        a_status += sstr.str();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsElement::CheckLastGen ( string &  a_status,
df_SplitInfo a_splitInfo,
bool  a_autoCorrect,
UInt32_t  a_fieldStatus 
)

Definition at line 393 of file fsc_nsElement.cpp.

References ait_NOTALLATTR, fsc_nsElement_t::attribIdx, fsc_nsElement_t::attribType, CheckLastGen(), cmn_HexDump(), dbg_DETAIL, df_SplitInfo::fileName, df_SplitInfo::fileSize, fsc_nsCreateAttribMgrObj(), fsc_nsCreateNameObj(), fsc_nsNameMgr::GetNameRef(), fsc_nsAttrMgr::GetStandAttrRef(), giaNEWEST_GEN, InsertSplit(), log_DBG_m, log_FUNC_m, m_attribMgrProperty_p, m_elementRec, m_nameMgrProperty_p, fsc_nsElement_t::memberIdx, fsc_nsElement_t::migID, df_SplitInfo::migrationID, fsc_nsElement_t::nameIdx, fsc_nsElement_t::nameType, nit_NSCMISSING, ntoh(), NULL, fsc_nsElement_t::numOfAttrib, fsc_nsElement_t::numOfName, df_SplitInfo::ownerID, fsc_nsElement_t::ownerIdx, and df_StandardAttr_t::size.

                                                                     {

    log_FUNC_m(CheckLastGen(df_SplitInfo));
    if (m_elementRec.nameType == nit_NSCMISSING) {
        a_status += "    Not in NSC. Internal error this must be handled before. \n";
        return;
    }
    if (m_elementRec.migID > a_splitInfo.migrationID) {
        // OK, probably new generation was inserted in meantime
        return;
    }
    if (m_elementRec.migID < a_splitInfo.migrationID) {
        if (a_autoCorrect) {
            InsertSplit(a_splitInfo, giaNEWEST_GEN);
            a_status += "    No last gen. in NSC. NSC probably disabled for some time. [CORRECTED]\n";
        }
        else {
            a_status += "    No last gen. in NSC. NSC probably disabled for some time. \n";
        }
        return;
    }
    // to do check attributes.

    if (m_elementRec.ownerIdx != a_splitInfo.ownerID) {
        a_fieldStatus |= fmm_OWNERID;
    }

    if (m_nameMgrProperty_p == NULL) {
        m_nameMgrProperty_p = fsc_nsCreateNameObj(m_elementRec.numOfName, m_elementRec.nameIdx);
    }

    // not need to convert both are already in UTF8 format.
    if (string(a_splitInfo.fileName) != m_nameMgrProperty_p->GetNameRef()) {
        string &fscStr = m_nameMgrProperty_p->GetNameRef();
        log_DBG_m(dbg_DETAIL, "SplitInfo.name = '" << a_splitInfo.fileName 
                        << "' Size " << a_splitInfo.fileName.size() 
                        << " DUMP: " << cmn_HexDump(a_splitInfo.fileName.data(), a_splitInfo.fileName.size()) << endl 
                        << " FSC name = '" << fscStr
                        << "' Size " << fscStr.size() 
                        << " DUMP: " << cmn_HexDump(fscStr.data(), fscStr.size()));
    
        a_fieldStatus |= fmm_FILENAME;
    }

    if (m_elementRec.attribType == ait_NOTALLATTR) {
        a_status += string("    Some or all file's meta data missing in NSC.\n");
        return;
    }

    if (   m_elementRec.memberIdx == 0 ) { // is a file, so check file size

        if (m_attribMgrProperty_p == NULL) {
            m_attribMgrProperty_p = fsc_nsCreateAttribMgrObj(m_elementRec.attribType,
                                                            m_elementRec.numOfAttrib,
                                                            m_elementRec.attribIdx);
        }
        df_StandardAttr_t &standAttr = m_attribMgrProperty_p->GetStandAttrRef();
        if ( (ivd_FileSize_t)ntoh(standAttr.size) != a_splitInfo.fileSize) {
            a_fieldStatus |= fmm_FILESIZE;
        }
    }
}

Here is the call graph for this function:

void fsc_nsElement::ChgAttrib ( df_SplitInfo a_splitInfo,
fsc_GenInsertAct_e  a_genInsAct 
) [private]
void fsc_nsElement::ChgName ( const string &  a_name  )  [private]

Definition at line 517 of file fsc_nsElement.cpp.

References fsc_nsNameMgr::ChgName(), dbg_DETAIL, fsc_nsCreateNameObj(), log_DBG_m, log_FUNC_m, m_elementRec, m_nameMgrProperty_p, fsc_nsElement_t::nameIdx, NULL, and fsc_nsElement_t::numOfName.

Referenced by InsertSplit(), and Remove().

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsElement::ChgOwner ( ivd_RecordIDX_t  a_newOwnFileID  )  [private]

Definition at line 493 of file fsc_nsElement.cpp.

References fsc_nsOwnerMgr::ChgOwner(), fsc_nsCreateOwnerMgrObj(), GetOwnerFileID(), log_FUNC_m, fio_Vector::m_changed, m_elementRec, m_fileID, m_ownerMgrProperty_p, NULL, and fsc_nsElement_t::ownerIdx.

Referenced by InsertSplit().

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsElement::Dump ( ostream &  os  )  [virtual]

Reimplemented from fio_Vector.

Definition at line 529 of file fsc_nsElement.cpp.

References fsc_nsElement_t::attribIdx, fsc_nsElement_t::attribType, fsc_nsAttrMgr::Dump(), fsc_nsNameMgr::Dump(), fsc_nsCreateAttribMgrObj(), fsc_nsCreateNameObj(), log_FUNC_m, m_attribMgrProperty_p, m_elementRec, m_nameMgrProperty_p, fsc_nsElement_t::memberIdx, fsc_nsElement_t::migID, fsc_nsElement_t::nameIdx, fsc_nsElement_t::nameType, nit_DELETED, NULL, fsc_nsElement_t::numOfAttrib, fsc_nsElement_t::numOfMember, fsc_nsElement_t::numOfName, fsc_nsElement_t::ownerIdx, and fsc_nsElement_t::ownerType.

Referenced by fsc_RawScan::DirTreeWalk(), and fsc_DataL::Dump().

                                    {    
    log_FUNC_m(Dump);
    if (m_elementRec.nameType == nit_DELETED) {
    os << "   DELETED\n";
    }
    os << "   Owner fileID    = " << m_elementRec.ownerIdx;
    os << "   MigID = " << m_elementRec.migID;
    os << "\n   Attrib vec type = " << (int)m_elementRec.attribType 
                      << " size = " << (int)m_elementRec.numOfAttrib 
                       << " idx = " << m_elementRec.attribIdx;
    os << "\n   Name   vec type = " << (int)m_elementRec.nameType   
                      << " size = " << (int)m_elementRec.numOfName   
                       << " idx = " << m_elementRec.nameIdx;
    os << "\n   Member vec type = " << (int)m_elementRec.ownerType  
                      << " size = " << (int)m_elementRec.numOfMember 
                       << " idx = " << m_elementRec.memberIdx << endl;

//    log_DBG_m(dbg_DETAIL, " Attrib vec size =" << (short)m_elementRec.numOfAttrib << " Idx   = " << m_elementRec.attribIdx);

    if (m_nameMgrProperty_p == NULL) {
        m_nameMgrProperty_p = fsc_nsCreateNameObj(m_elementRec.numOfName, m_elementRec.nameIdx);        
    }
    m_nameMgrProperty_p->Dump(os);

    if (m_attribMgrProperty_p == NULL) {
        m_attribMgrProperty_p = fsc_nsCreateAttribMgrObj(m_elementRec.attribType,
                                                         m_elementRec.numOfAttrib,
                                                         m_elementRec.attribIdx);
    }
    m_attribMgrProperty_p->Dump(os);

/*    UInt8_t             ownerType  : 1; // 
    UInt8_t             memberType : 2;
    UInt8_t             attribType : 2;
    UInt8_t             nameType   : 3;
    UInt8_t             numOfMember;
    UInt8_t             numOfAttrib;
    UInt8_t             numOfName;
    ivd_RecordIDX_t     ownerIdx;
    ivd_RecordIDX_t     memberIdx; // used in directory only
    ivd_RecordIDX_t     attribIdx;
    ivd_RecordIDX_t     nameIdx;
*/
}

Here is the call graph for this function:

Here is the caller graph for this function:

fsc_nsElement_t& fsc_nsElement::GetElementRecRef (  )  [inline]

write changes to DB before it's removed from cache

Definition at line 117 of file fsc_nsElement.h.

{ return m_elementRec; };

ivd_RecordIDX_t fsc_nsElement::GetFileID ( void   )  [inline]

Definition at line 106 of file fsc_nsElement.h.

Referenced by fsc_nsDirectory::AddEntry(), fsc_nsRemoveElementObj(), fsc_nsDirectory::RemoveEntry(), and fsc_nsDirectory::Write2DB().

{ return m_fileID; };

Here is the caller graph for this function:

ivd_FileSize_t fsc_nsElement::GetFileSize ( void   ) 

Definition at line 460 of file fsc_nsElement.cpp.

References GetStandAttrPtr(), log_FUNC_m, ntoh(), NULL, and df_StandardAttr_t::size.

Referenced by fsc_DataL::GetCopiesPos().

                                           {
    log_FUNC_m(GetFileSize);
    df_StandardAttr_t *attr = GetStandAttrPtr();
    if (attr == NULL) {
        return 0;
    }
    return ntoh(attr->size);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fsc_nsElement::GetFullPath ( string &  a_path,
char  a_pathSeparator = '/' 
)

fill a_path string with file and its path path separator is a_pathSeparator return 1 if found not initialized owner in that case also path is modified differently instead unknown owner the "IVD-lost+found" directory is used and file name is extended by its fileID in following format -IVD-<fileID> Example: file1.txt with fileid(12345) has owner with fileID > 0, but owner's name is not known.

IVD-lost+found/file1.txt

NOTE a_path must be clean berfore use.

Definition at line 607 of file fsc_nsElement.cpp.

References c_lostAndFoundStr(), cmn_IsSpecialFile(), cmn_Num2Str(), dbg_DETAIL, dbg_NORM, fsc_nsCreateNameObj(), fsc_nsCreateOwnerMgrObj(), g_cmn, fsc_nsOwnerMgr::GetfullPath(), fsc_nsNameMgr::GetNameRef(), GetOwnerFileID(), ift_UNKNOWN, log_DBG_m, log_FUNC_A_m, m_elementRec, m_fileID, m_nameMgrProperty_p, ivd_Product::m_nameShort, m_ownerMgrProperty_p, fsc_nsElement_t::nameIdx, fsc_nsElement_t::nameType, nit_NSCMISSING, NULL, fsc_nsElement_t::numOfName, and cmn_Global::prod.

Referenced by fsc_nsOwnerMgr::GetfullPath(), fsc_DataL::GetFullPath(), Pack(), fsc_RawMedVolPathCollector::ProcRecMedPosMgr(), fsc_RawMediumContentCollector::ProcRecMedPosMgr(), and fsc_DataL::Write2DB().

                                                                   {
    log_FUNC_A_m(GetFullPath, " a_path = " << a_path);
    int ret = 0;
    string nameBuffer; 
    if (m_elementRec.nameType == nit_NSCMISSING) {
        nameBuffer = c_lostAndFoundStr +  "_" +  cmn_Num2Str(m_fileID);
        log_DBG_m(dbg_NORM, "Item not in NSC, put to " << c_lostAndFoundStr 
                       << " FileID = " << m_fileID );
        ret = 1;
    } else {
        if (m_nameMgrProperty_p == NULL) {
            m_nameMgrProperty_p = fsc_nsCreateNameObj(m_elementRec.numOfName, m_elementRec.nameIdx);        
        }
    
        nameBuffer = m_nameMgrProperty_p->GetNameRef();
        log_DBG_m(dbg_DETAIL, " FileID = " << m_fileID 
                       << " fileName = " << nameBuffer );
        if (cmn_IsSpecialFile(nameBuffer, ift_UNKNOWN)) {
            // added for bug 7721 
            nameBuffer = c_lostAndFoundStr + "_" + nameBuffer 
                                           + "_" + cmn_Num2Str(m_fileID);
            log_DBG_m(dbg_NORM, "Special file item found, put to " 
                                  << g_cmn.prod.m_nameShort << "lost+found FileID = "
                                  << m_fileID 
                                  << " fileName = " << nameBuffer );
            ret = 1;
        }
    }
    if (m_nameMgrProperty_p == NULL) {
        m_nameMgrProperty_p = fsc_nsCreateNameObj(m_elementRec.numOfName, m_elementRec.nameIdx);
    }
    log_DBG_m(dbg_DETAIL, " FileID = " << m_fileID
                       << " fileName = " << m_nameMgrProperty_p->GetNameRef());
    if(m_ownerMgrProperty_p == NULL) {
        log_DBG_m(dbg_DETAIL, "m_ownerMgrProperty_p is null. Created new.");
        m_ownerMgrProperty_p = fsc_nsCreateOwnerMgrObj(GetOwnerFileID());
    }
    if (GetOwnerFileID() == 0 ) {
       // we are at the root of the HSMFS so stop recursion
        a_path = nameBuffer;
        return ret;
    }

    // use / as internal DF path separator
    // recurse into until root is found
    ret = m_ownerMgrProperty_p->GetfullPath(a_path, a_pathSeparator);
    a_path += a_pathSeparator + nameBuffer;
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ivd_MigrationID_t fsc_nsElement::GetMigID (  )  [inline]

Definition at line 107 of file fsc_nsElement.h.

Referenced by fsc_DataL::GetFullPath().

{ return m_elementRec.migID; };

Here is the caller graph for this function:

ivd_RecordIDX_t fsc_nsElement::GetOwnerFileID (  )  [inline]

Definition at line 104 of file fsc_nsElement.h.

Referenced by ChgOwner(), fsc_nsElement(), GetFullPath(), InsertSplit(), and SetMemOfOwner().

Here is the caller graph for this function:

df_StandardAttr_t * fsc_nsElement::GetStandAttrPtr (  ) 
void fsc_nsElement::InsertSplit ( df_SplitInfo a_splitInfo,
fsc_GenInsertAct_e  a_genInsAct 
) [virtual]

Take care about element ownerID (fileID of owner) and element deletion.

All other fields are maintained by propriate managers: name, owner, and attribute.

Definition at line 174 of file fsc_nsElement.cpp.

References ChgAttrib(), ChgName(), ChgOwner(), dbg_DETAIL, df_SplitInfo::Dump(), df_SplitInfo::fileID, df_SplitInfo::fileName, fsc_nsCreateNameObj(), fsc_nsNameMgr::GetNameRef(), GetOwnerFileID(), giaINSERT_ONE_BEFORE_LAST_GEN, giaNEWEST_GEN, log_DBG_m, log_FUNC_m, log_WRN_m, fio_Vector::m_changed, m_elementRec, m_fileID, m_nameMgrProperty_p, fsc_nsElement_t::migID, df_SplitInfo::migrationID, fsc_nsElement_t::nameIdx, fsc_nsElement_t::nameType, nit_DELETED, nit_NSCMISSING, NULL, fsc_nsElement_t::numOfName, df_SplitInfo::oldFileName, df_SplitInfo::oldOwnerID, df_SplitInfo::ownerID, fsc_nsElement_t::ownerIdx, and SetMemOfOwner().

Referenced by CheckLastGen(), fsc_DataL::fsc_DataL(), and fsc_DataL::Insert().

                                                                                         {    
    log_FUNC_m(InsertSplit);

    log_DBG_m(dbg_DETAIL, "NSC insert fileID = " 
                            << a_splitInfo.fileID
                            << " gen act " << (int)a_genInsAct
                            << "  owner " << a_splitInfo.ownerID
                            << "  name '" << a_splitInfo.fileName << "'"
                            << "  old owner " << a_splitInfo.oldOwnerID
                            << "  old name '" << a_splitInfo.oldFileName << "'" << endl
                            << *this);
    // NSC is not yet updatted  -----------------------
    // update NSC only if last or one before last generation are come
    if (m_elementRec.nameType == nit_NSCMISSING
        && a_genInsAct <= giaINSERT_ONE_BEFORE_LAST_GEN) {

        m_changed = true;        

        log_DBG_m(dbg_DETAIL, "first time.");
        if (a_splitInfo.fileName.empty()) {  // file is deleted
            // deleted generation doesn't change migID
            ChgName(a_splitInfo.oldFileName);            
            // change attributes is nonsense when file is deletted
            // attributes will be set when one before last generation is inserted
            m_elementRec.nameType = nit_DELETED;            
            m_elementRec.ownerIdx = a_splitInfo.oldOwnerID;        
            m_elementRec.migID    = a_splitInfo.migrationID;
        }
        else {
            m_elementRec.migID = a_splitInfo.migrationID;
            ChgName(a_splitInfo.fileName);
            ChgAttrib(a_splitInfo, giaNEWEST_GEN);
            m_elementRec.nameType = nit_NAME;
            m_elementRec.ownerIdx = a_splitInfo.ownerID;        
        }
        SetMemOfOwner(a_splitInfo.fileID);
        goto exit;
    }

    fsc_GenInsertAct_e genInsAct;
    if (a_splitInfo.migrationID > m_elementRec.migID) {
        genInsAct = giaNEWEST_GEN;
        m_changed = true;        
        m_elementRec.migID = a_splitInfo.migrationID;
    }
    else if (a_splitInfo.migrationID == m_elementRec.migID) {
        genInsAct = giaLAST_GEN_UPDATED;
    }
    else {
        return;
    }
    // change Name  -----------------------
    // will pass at every copy of deted file generation
    if (    genInsAct == giaNEWEST_GEN) {
        if (m_nameMgrProperty_p == NULL) {
            m_nameMgrProperty_p = fsc_nsCreateNameObj(m_elementRec.numOfName, m_elementRec.nameIdx);        
        }
        if (a_splitInfo.fileName != m_nameMgrProperty_p->GetNameRef()) { 
            // name is changed or element is deletted
            if (    a_splitInfo.fileName.empty() ) {
                if (m_elementRec.nameType == nit_DELETED) {
                    goto exit; // already updated
                }
                log_DBG_m(dbg_DETAIL, "File is DELETED.");
                // just in case
                ChgName(a_splitInfo.oldFileName);
                if (a_splitInfo.oldOwnerID != GetOwnerFileID()) {
                    ChgOwner(a_splitInfo.oldOwnerID);
                }
                m_elementRec.nameType = nit_DELETED;
                m_changed = true;
                goto exit;
    //            return; // all other fields stay same
            }
            else {
                if (m_elementRec.nameType == nit_DELETED) {
                    string spltiInfoDump = a_splitInfo.Dump();
                    log_WRN_m("Element was DELETED, but new generation is inserting." << endl
                            << "splitInfo = " << spltiInfoDump << endl
                            << "fsc_nsElement::InsertSplit fileID = " << m_fileID << " " << endl
                                << *this);
                    m_elementRec.nameType = nit_NAME;
                }
                log_DBG_m(dbg_DETAIL, "Old name '" << a_splitInfo.oldFileName << "'");
                log_DBG_m(dbg_DETAIL, "Change name to '" << a_splitInfo.fileName << "'");
                ChgName(a_splitInfo.fileName);
            }
        }
    }

    // update Attributes  -----------------------
    // change attribute when new gen, or not comletted yet (many splits)
    // or use one before last gen in case that file is deletted

    ChgAttrib(a_splitInfo, genInsAct);

    // update Owner  -----------------------
    if (   genInsAct == giaNEWEST_GEN
        && a_splitInfo.ownerID != GetOwnerFileID()) {
        log_DBG_m(dbg_DETAIL, "Change own. old " << GetOwnerFileID() 
                             << "  new " << a_splitInfo.ownerID);
        // owner is changed
        ChgOwner(a_splitInfo.ownerID);
    }
exit:
    log_DBG_m(dbg_DETAIL, "after NSC insert fileID = " << m_fileID << " " << endl
                            << *this );
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool fsc_nsElement::IsDirectory (  )  [inline, virtual]

Definition at line 111 of file fsc_nsElement.h.

Referenced by fsc_nsRemoveElementObj(), fsc_DataL::GetCopiesPos(), and fsc_RawMediumContentCollector::ProcRecMedPosMgr().

{ return false; };

Here is the caller graph for this function:

void fsc_nsElement::Pack ( df_Packer a_packer,
char  a_pathSeparator 
)

fill packer, but packer could have any writer.

check user to see what kind of writer is used. For now a fsc_nsFSrecovery is used to recover IVDFS

Definition at line 575 of file fsc_nsElement.cpp.

References fsc_nsElement_t::attribIdx, fsc_nsElement_t::attribType, c_lostAndFoundStr(), cmn_Num2Str(), dbg_LOW, dbg_NORM, fsc_nsCreateAttribMgrObj(), GetFullPath(), fsc_nsAttrMgr::GetStandAttrRef(), log_DBG_m, log_FUNC_m, m_attribMgrProperty_p, m_elementRec, m_fileID, NULL, fsc_nsElement_t::numOfAttrib, fsc_nsElement_t::ownerIdx, fsc_nsAttrMgr::Pack(), df_Packer::WriteRecFile(), and df_Packer::WriteRecFileEnd().

Referenced by nsc_ScanForIVDFSRecovery().

                                                                  {
    log_FUNC_m(Pack);
    // write file header first
    // possible streams from attributes
    // finish with file end
    UInt32_t status = df_SS_COMPLETE;
    string fileName;
    if (GetFullPath(fileName, a_pathSeparator) == 1) { // lost+found file, append fileID to its name
        fileName = c_lostAndFoundStr + a_pathSeparator + fileName + "_" + cmn_Num2Str(m_fileID);
        log_DBG_m(dbg_LOW, "Lost+Found entry Pack FieID = " << m_fileID 
                           << " fileName = " << fileName);  
    } else {
        log_DBG_m(dbg_NORM, "Pack FileID = " << m_fileID 
                           << " fileName = " << fileName);
    };

    if (m_attribMgrProperty_p == NULL) {
        m_attribMgrProperty_p = fsc_nsCreateAttribMgrObj(m_elementRec.attribType,
                                                         m_elementRec.numOfAttrib,
                                                         m_elementRec.attribIdx);
    }
    a_packer.WriteRecFile(m_fileID, 
                          m_elementRec.ownerIdx, 
                          fileName, 
                          m_attribMgrProperty_p->GetStandAttrRef());

    m_attribMgrProperty_p->Pack(a_packer);

    a_packer.WriteRecFileEnd(status);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsElement::Remove (  ) 

remove entry

Definition at line 284 of file fsc_nsElement.cpp.

References fsc_nsElement_t::attribIdx, fsc_nsElement_t::attribType, ChgName(), fsc_nsCreateAttribMgrObj(), ie_FSC_NONSCELEMENTOBJ, log_FUNC_m, m_attribMgrProperty_p, m_elementRec, m_fileID, m_ownerMgrProperty_p, fsc_nsElement_t::nameType, nit_NSCMISSING, NULL, fsc_nsElement_t::numOfAttrib, fsc_nsAttrMgr::RemoveAttributes(), and fsc_nsOwnerMgr::RemoveMember().

Referenced by fsc_DataL::Write2DB().

                           {
    log_FUNC_m(Remove);
    if (m_elementRec.nameType == nit_NSCMISSING) {
        return;
    }
    
    if (m_ownerMgrProperty_p == NULL) {
        ostringstream sstr;
        sstr << "Parent object of FileID:" << m_fileID << " must be generated before Remove() method is called."
            << " Cannot remove NSC of this file.";
        throw ivd_InternalError(ie_FSC_NONSCELEMENTOBJ, sstr.str(), true);
    }
    m_ownerMgrProperty_p->RemoveMember(m_fileID);
    
    ChgName("");

    if (m_attribMgrProperty_p == NULL) {
        m_attribMgrProperty_p = fsc_nsCreateAttribMgrObj(m_elementRec.attribType,
                                                         m_elementRec.numOfAttrib,
                                                         m_elementRec.attribIdx);
    }
    m_attribMgrProperty_p->RemoveAttributes();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsElement::SetMemOfOwner ( ivd_RecordIDX_t  a_memFileID  )  [private]

Definition at line 483 of file fsc_nsElement.cpp.

References fsc_nsCreateOwnerMgrObj(), GetOwnerFileID(), log_FUNC_m, m_ownerMgrProperty_p, NULL, and fsc_nsOwnerMgr::SetMember().

Referenced by InsertSplit().

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsElement::Write2DB ( fio_Transaction a_trans  )  [virtual]

Write element changes to DB and.

Definition at line 134 of file fsc_nsElement.cpp.

References fsc_nsElement_t::attribIdx, fsc_nsElement_t::attribType, dbg_DETAIL, log_DBG_m, log_FUNC_m, m_attribMgrProperty_p, fio_Vector::m_changed, m_elementRec, m_fileID, m_nameMgrProperty_p, fsc_nsElement_t::nameIdx, fsc_nsElement_t::nameType, nit_DELETED, NULL, fsc_nsElement_t::numOfAttrib, fsc_nsElement_t::numOfName, fsc_nsNameMgr::Write2DB(), and fsc_nsAttrMgr::Write2DB().

Referenced by fsc_DataL::Write2DB().

                                                     {    
    log_FUNC_m(Write2DB);    
    // fields regarding member/owner is handled by inheritted class    
    // owner is updatted when all its members are released.    
    //if (m_ownerMgrProperty_p != NULL) {    
    //   m_ownerMgrProperty_p->Write2DB(a_trans);    
    //}    m_elementRec.ownerType = oit_OWNER;    
    
    if (m_attribMgrProperty_p != NULL) {
        UInt8_t flags = m_elementRec.attribType;  
//        log_DBG_m(dbg_DETAIL, " Update attributes ");
        if ( m_attribMgrProperty_p->Write2DB(flags,
                                          m_elementRec.numOfAttrib,
                                          m_elementRec.attribIdx,
                                          a_trans)) {            
            m_elementRec.attribType = flags;
            m_changed = true;        
        }
    }
    if (m_nameMgrProperty_p != NULL) {
        UInt8_t flags = m_elementRec.nameType;
        if (m_nameMgrProperty_p->Write2DB(flags,
                                       m_elementRec.numOfName,
                                       m_elementRec.nameIdx,
                                       a_trans)) {            
            m_changed = true;
        }
        if (m_elementRec.nameType != nit_DELETED ) {            
            m_elementRec.nameType = flags;        
        }    
    }    
    if (m_changed) {        
        fio_Vector::Write2DB(&m_elementRec, a_trans);    
    }

    log_DBG_m(dbg_DETAIL, "fsc_nsElement::Write2DB fileID = " << m_fileID << " " << endl
                            << *this);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

ostream& operator<< ( ostream &  a_os,
fsc_nsElement a_nsElem 
) [friend]

Definition at line 122 of file fsc_nsElement.h.

                                                                        {
        ostringstream str;
        a_nsElem.Dump(str);
        a_os << str.str();
        return a_os ;
    }

friend class ut_fsc_nsElement [friend]

Definition at line 64 of file fsc_nsElement.h.


Member Data Documentation

Reimplemented from fio_Vector.

Definition at line 135 of file fsc_nsElement.h.

Definition at line 162 of file fsc_nsElement.h.

Referenced by ChgOwner(), GetFullPath(), InsertSplit(), Pack(), Remove(), and Write2DB().

int fsc_nsElement::m_refCounter [protected]

Definition at line 169 of file fsc_nsElement.h.


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