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

rm_MigIdGen Class Reference
[Resource Manager Database Library]

Migration Id Generator Generates a new Migration ID per IVD-Partition on request. More...

#include <rmdb.h>

Collaboration diagram for rm_MigIdGen:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 rm_MigIdGen ()
 Default constructor.
virtual ~rm_MigIdGen ()
void Init (rm_Partition *a_part)

Private Member Functions

UInt64_t CheckInDB ()
UInt32_t InsertIntoDB ()
void UpdateInDB (UInt64_t a_newId)
UInt64_t GenerateNew ()

Private Attributes

rm_Partitionm_part
UInt64_t m_lastId
bool m_valid
 log_CLASSID_m

Friends

class dbo_GetNewMigId

Detailed Description

Migration Id Generator Generates a new Migration ID per IVD-Partition on request.

The MigID consists of timet and a 32 bit counter

Author:
Toni Pljakoski, HERMES SoftLab
See also:
<reference>

Definition at line 652 of file rmdb.h.


Constructor & Destructor Documentation

rm_MigIdGen::rm_MigIdGen (  ) 

Default constructor.

Definition at line 49 of file rm_migidgen.cpp.

References log_FUNC_m.

rm_MigIdGen::~rm_MigIdGen (  )  [virtual]

Definition at line 57 of file rm_migidgen.cpp.

References log_FUNC_m.

                         {
    log_FUNC_m(~rm_MigIdGen);
    //empty
}


Member Function Documentation

UInt64_t rm_MigIdGen::CheckInDB (  )  [private]

Definition at line 107 of file rm_migidgen.cpp.

References dbg_DETAIL, ie_NO_MIG_ID_INIT, log_DBG_m, log_FUNC_m, m_part, m_valid, rm_Partition::migIdCount, rm_Partition::migIdTime, rm_Partition::partitionUUIDString, and rm_Partition::Select().

Referenced by GenerateNew().

                               {
    log_FUNC_m(CheckInDB);
    
    if (!m_valid) {
        throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
    }

    m_part->Select(m_part->partitionUUIDString);

    UInt64_t migId ;
    UInt64_t migTime = m_part->migIdTime;
    UInt64_t migCount = m_part->migIdCount;

    migId = (migTime << 8) | migCount;
    log_DBG_m(dbg_DETAIL,"got migId " << hex << migId);
    return migId;
}

Here is the call graph for this function:

Here is the caller graph for this function:

UInt64_t rm_MigIdGen::GenerateNew (  )  [private]

Definition at line 74 of file rm_migidgen.cpp.

References CheckInDB(), dbg_DETAIL, ie_NO_MIG_ID_INIT, log_DBG_m, log_FUNC_m, m_lastId, m_valid, and UpdateInDB().

Referenced by dbo_GetNewMigId::Process().

                                 {
    log_FUNC_m(GenerateNew);
    if (!m_valid) {
        throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
    }
    cmn_MutexLock l(g_migIdGen_x);
    
    time_t tTime;
    time(&tTime); 
    log_DBG_m(dbg_DETAIL,"Time_t now is " << hex << tTime);

    UInt64_t nowId = 0;
    nowId = tTime;
    nowId = nowId << 8;
    log_DBG_m(dbg_DETAIL,"generated nowId:" << hex << nowId);


    m_lastId = CheckInDB();
    log_DBG_m(dbg_DETAIL,"mLastId after CheckDB:" << hex << m_lastId);


    if (m_lastId >= nowId) {
        UpdateInDB(++m_lastId);
        log_DBG_m(dbg_DETAIL,"mLastId before Return:" << hex << m_lastId);
    } else {
        
        UpdateInDB(nowId);
        log_DBG_m(dbg_DETAIL,"mLastId before Return:" << hex << nowId);
    }
    return m_lastId;    
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rm_MigIdGen::Init ( rm_Partition a_part  ) 

Definition at line 63 of file rm_migidgen.cpp.

References ie_NO_MIG_ID_INIT, log_FUNC_m, m_part, m_valid, and NULL.

Referenced by rm_PartitionStatus::Init(), rm_Partition::Init(), rm_Partition::operator=(), and rm_Partition::rm_Partition().

                                          {
    log_FUNC_m(Init);
    if (a_part != NULL){
        m_part = a_part;
        m_valid = true;
    } else {
        throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
    }
}

Here is the caller graph for this function:

UInt32_t rm_MigIdGen::InsertIntoDB (  )  [private]
void rm_MigIdGen::UpdateInDB ( UInt64_t  a_newId  )  [private]

Definition at line 126 of file rm_migidgen.cpp.

References dbg_DETAIL, ie_NO_MIG_ID_INIT, log_DBG_m, log_FUNC_m, m_lastId, m_part, m_valid, rm_Partition::migIdCount, rm_Partition::migIdTime, and rm_Partition::Update().

Referenced by GenerateNew().

                                            {
    log_FUNC_m(UpdateInDB);

    if (!m_valid) {
        throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
    }

    m_lastId = a_newId;

    m_part->migIdTime = (UInt32_t)(a_newId >> 8);
    m_part->migIdCount = (UInt32_t)(a_newId & 0x000000FF);
    
    log_DBG_m(dbg_DETAIL
        ,"updating last mig Id to migTime:" << 
        hex << m_part->migIdTime << 
        " migCount:" << m_part->migIdCount );

    m_part->Update();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class dbo_GetNewMigId [friend]

Definition at line 654 of file rmdb.h.


Member Data Documentation

Definition at line 677 of file rmdb.h.

Definition at line 667 of file rmdb.h.

Referenced by GenerateNew(), and UpdateInDB().

Definition at line 665 of file rmdb.h.

Referenced by CheckInDB(), Init(), and UpdateInDB().

bool rm_MigIdGen::m_valid [private]

Definition at line 669 of file rmdb.h.

Referenced by CheckInDB(), GenerateNew(), Init(), and UpdateInDB().


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