Static Public Member Functions | Static Private Member Functions | Private Attributes

Collocation Class Reference
[Classes for managing events]

#include <hsm_helpers.h>

List of all members.

Static Public Member Functions

static void CheckPreconditions (string &a_path, ivd_FS_FileProperty_t &a_fileProp, UInt64_t a_majColId, UInt64_t a_minColId, bool a_doReplication)
static void TrigMigration (ivd_FS_File &a_file, ivd_GenInode_t a_inode, UInt64_t a_majColId, UInt64_t a_minColId)

Static Private Member Functions

static bool IsReplicated (string &a_path, ivd_FS_FileProperty_t &a_fileProp)

Private Attributes

 log_CLASSID_m

Detailed Description

Definition at line 44 of file hsm_helpers.h.


Member Function Documentation

void Collocation::CheckPreconditions ( string &  a_path,
ivd_FS_FileProperty_t a_fileProp,
UInt64_t  a_majColId,
UInt64_t  a_minColId,
bool  a_doReplication 
) [static]

Definition at line 50 of file hsm_helpers.cpp.

References dbg_DETAIL, ie_HSM_COLLOCATION, ie_PRECONDITION, IsReplicated(), ivd_Error, log_DBG_m, log_FUNC_m, ivd_FS_FileProperty_t::m_majColId, and ivd_FS_FileProperty_t::m_minColId.

Referenced by MigrateTreewalk::CheckDir(), and i_HSM_i::MigrateByAPI().

                                                           {
    log_FUNC_m(CheckPreconditions);

    log_DBG_m(dbg_DETAIL, "Is Collocation IDs changed?");
    if (    (a_fileProp.m_majColId != 0) && (a_fileProp.m_minColId != 0)
            && ((a_fileProp.m_majColId != a_majColId) || (a_fileProp.m_minColId != a_minColId))) {
        log_DBG_m(dbg_DETAIL, "IDs changed."
            << " Current: " << a_fileProp.m_majColId << "," << a_fileProp.m_minColId
            << " New: " << a_majColId << "," << a_minColId);
        throw ivd_Error(ie_HSM_COLLOCATION, "ID change is not allowed.");
    }

    log_DBG_m(dbg_DETAIL, "Was replicated?");
    if (a_doReplication && !IsReplicated(a_path, a_fileProp)) {
        throw ivd_Error(ie_PRECONDITION, "Not replicated.");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Collocation::IsReplicated ( string &  a_path,
ivd_FS_FileProperty_t a_fileProp 
) [static, private]

Definition at line 70 of file hsm_helpers.cpp.

References cmn_File::CloseF(), dbg_DETAIL, fom_READ, FSR_ADS_NAME, FSR_REPLICATION_VERSION, ivd_BaseException::GetError(), log_DBG_m, log_FUNC_m, cmn_File::OpenF(), cmn_File::ReadF(), _REPLICATION_METADATA::replicationTimestamp, size, _REPLICATION_METADATA::srcFileId, cmn_File::StatF(), _REPLICATION_METADATA::tgtFileId, and _REPLICATION_METADATA::version.

Referenced by CheckPreconditions().

                                                                                {
    log_FUNC_m(IsReplicated);
    string adsPath(a_path + string(":") + string(FSR_ADS_NAME));
    bool retVal(false);

    REPLICATION_METADATA data;
    ivd_FileInfo_t fileInfo;
    cmn_File f(a_path);
    f.StatF(fileInfo);

    ivd_FileRetSize_t size;
    cmn_File ads(adsPath);
    try {
        ads.OpenF(fom_READ);
        size = ads.ReadF(&data, sizeof(REPLICATION_METADATA));
        if (size == sizeof(REPLICATION_METADATA)) {
            if (data.version == FSR_REPLICATION_VERSION) {
                log_DBG_m(dbg_DETAIL, "Replication data: Version: " << data.version
                    << " SrcFileID: 0x" << hex << data.srcFileId
                    << " TgtFileID: 0x" << data.tgtFileId << dec
                    << " Time: " << hex << data.replicationTimestamp);
                log_DBG_m(dbg_DETAIL, "File write time: " << hex << fileInfo.timeModify);
                // we use fileInfo.timeModify rather than fileInfo.timeChange because
                // the latter seems not to be modifyable by an app (may be a Windows bug)
                // As a result we just focus on changes in the stream data now.
                if (fileInfo.timeModify <= data.replicationTimestamp) {
                    log_DBG_m(dbg_DETAIL, "Replicated.");
                    retVal = true;
                }
            }
            else {
                log_DBG_m(dbg_DETAIL, "Invalid structure version: " << data.version
                    << " (expected: " << FSR_REPLICATION_VERSION << ")");
            }
        }
        ads.CloseF();
    }
    catch (ivd_SysError &ise) {
        log_DBG_m(dbg_DETAIL, "Caught " << ise);
        if (ise.GetError() == ERROR_FILE_NOT_FOUND) {
            log_DBG_m(dbg_DETAIL, "ADS does not exist: " << adsPath);
        }
        else if (ise.GetError() == ERROR_INVALID_NAME) {
            log_DBG_m(dbg_DETAIL, "Invalid name " << adsPath);
        }
        else {
            throw;
        }
    }
    return retVal;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Collocation::TrigMigration ( ivd_FS_File a_file,
ivd_GenInode_t  a_inode,
UInt64_t  a_majColId,
UInt64_t  a_minColId 
) [static]

Definition at line 122 of file hsm_helpers.cpp.

References ivd_FS_File::e_MigrateEvt, hsm_MigByAPI::InsertInputInode(), log_FUNC_m, ivd_FS_File::SetCollocationId(), and ivd_FS_File::TriggerEvent().

Referenced by MigrateTreewalk::CheckDir().

                                                                          {
    log_FUNC_m(TrigMigration);
    a_file.SetCollocationId(a_majColId, a_minColId);
    a_file.TriggerEvent(ivd_FS_File::e_MigrateEvt);
    g_mig.InsertInputInode(a_inode);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 53 of file hsm_helpers.h.


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