#include <rmdb.h>

The MigID consists of timet and a 32 bit counter
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_Partition * | m_part |
| UInt64_t | m_lastId |
| bool | m_valid |
| log_CLASSID_m | |
Friends | |
| class | dbo_GetNewMigId |
| 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 }
| 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 }

| 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 }


| 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 }


| 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 }


friend class dbo_GetNewMigId [friend] |
rm_Partition* rm_MigIdGen::m_part [private] |
UInt64_t rm_MigIdGen::m_lastId [private] |
bool rm_MigIdGen::m_valid [private] |
Definition at line 655 of file rmdb.h.
Referenced by CheckInDB(), GenerateNew(), Init(), and UpdateInDB().
rm_MigIdGen::log_CLASSID_m [private] |
1.5.6