rm_MigIdGen Class Reference
[Resource Manager Database Library]

#include <rmdb.h>

Collaboration diagram for rm_MigIdGen:

Collaboration graph
[legend]

List of all members.


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 638 of file rmdb.h.


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

Constructor & Destructor Documentation

rm_MigIdGen::rm_MigIdGen (  ) 

Default constructor.

Definition at line 35 of file rm_migidgen.cpp.

References log_FUNC_m.

00035                         : 
00036     m_part(NULL),
00037     m_valid(false) {
00038     
00039     log_FUNC_m(rm_MigIdGen);
00040 
00041 }

rm_MigIdGen::~rm_MigIdGen (  )  [virtual]

Definition at line 43 of file rm_migidgen.cpp.

References log_FUNC_m.

00043                          {
00044     log_FUNC_m(~rm_MigIdGen);
00045     //empty
00046 }


Member Function Documentation

void rm_MigIdGen::Init ( rm_Partition a_part  ) 

Definition at line 49 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().

00049                                           {
00050     log_FUNC_m(Init);
00051     if (a_part != NULL){
00052         m_part = a_part;
00053         m_valid = true;
00054     } else {
00055         throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
00056     }
00057 }

Here is the caller graph for this function:

UInt64_t rm_MigIdGen::CheckInDB (  )  [private]

Definition at line 93 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().

00093                                {
00094     log_FUNC_m(CheckInDB);
00095     
00096     if (!m_valid) {
00097         throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
00098     }
00099 
00100     m_part->Select(m_part->partitionUUIDString);
00101 
00102     UInt64_t migId ;
00103     UInt64_t migTime = m_part->migIdTime;
00104     UInt64_t migCount = m_part->migIdCount;
00105 
00106     migId = (migTime << 8) | migCount;
00107     log_DBG_m(dbg_DETAIL,"got migId " << hex << migId);
00108     return migId;
00109 }

Here is the call graph for this function:

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 112 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().

00112                                             {
00113     log_FUNC_m(UpdateInDB);
00114 
00115     if (!m_valid) {
00116         throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
00117     }
00118 
00119     m_lastId = a_newId;
00120 
00121     m_part->migIdTime = (UInt32_t)(a_newId >> 8);
00122     m_part->migIdCount = (UInt32_t)(a_newId & 0x000000FF);
00123     
00124     log_DBG_m(dbg_DETAIL
00125         ,"updating last mig Id to migTime:" << 
00126         hex << m_part->migIdTime << 
00127         " migCount:" << m_part->migIdCount );
00128 
00129     m_part->Update();
00130 }

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 60 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().

00060                                  {
00061     log_FUNC_m(GenerateNew);
00062     if (!m_valid) {
00063         throw ivd_InternalError(ie_NO_MIG_ID_INIT, "init rm_MigIdGen first");
00064     }
00065     cmn_MutexLock l(g_migIdGen_x);
00066     
00067     time_t tTime;
00068     time(&tTime); 
00069     log_DBG_m(dbg_DETAIL,"Time_t now is " << hex << tTime);
00070 
00071     UInt64_t nowId = 0;
00072     nowId = tTime;
00073     nowId = nowId << 8;
00074     log_DBG_m(dbg_DETAIL,"generated nowId:" << hex << nowId);
00075 
00076 
00077     m_lastId = CheckInDB();
00078     log_DBG_m(dbg_DETAIL,"mLastId after CheckDB:" << hex << m_lastId);
00079 
00080 
00081     if (m_lastId >= nowId) {
00082         UpdateInDB(++m_lastId);
00083         log_DBG_m(dbg_DETAIL,"mLastId before Return:" << hex << m_lastId);
00084     } else {
00085         
00086         UpdateInDB(nowId);
00087         log_DBG_m(dbg_DETAIL,"mLastId before Return:" << hex << nowId);
00088     }
00089     return m_lastId;    
00090 }

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 640 of file rmdb.h.


Member Data Documentation

Definition at line 651 of file rmdb.h.

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

Definition at line 653 of file rmdb.h.

Referenced by GenerateNew(), and UpdateInDB().

bool rm_MigIdGen::m_valid [private]

Definition at line 655 of file rmdb.h.

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

Definition at line 663 of file rmdb.h.


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

Generated on Mon Feb 27 19:47:19 2012 for OPENARCHIVE by  doxygen 1.5.6