#include <rm_dboperation.h>


Definition at line 22 of file rm_dboperation.h.
Public Member Functions | |
| rm_DBThread () | |
| ~rm_DBThread () | |
| void | Process (rm_DBOperation *a_operation) |
| rm_DBThread::Process() Processing one single incoming request | |
| Int32_t | Suspend (void) |
| rm_DBThread::Suspend() Suspend RMDB activity for backup proposes | |
| Int32_t | Resume (void) |
| rm_DBThread::Resume() Resume RMDB activity | |
Public Attributes | |
| rm_Operator | m_rmOp |
| bool | m_active |
| bool | m_shutdown |
| Int32_t | m_errNum |
| string | m_errDesc |
| UInt32_t | m_jobNum |
| log_CLASSID_m | |
Private Member Functions | |
| virtual void | Run (void *arg) |
| Main RMDB request loop. | |
Private Attributes | |
| cmn_Mutex | m_request_x |
| cmn_Condition | m_reqInput_c |
| cmn_Condition | m_reqOutput_c |
| cmn_Condition | m_reqFree_c |
| rm_DBOperation * | m_operation |
| bool | m_suspended |
Friends | |
| class | i_ResourceManager_i |
| rm_DBThread::rm_DBThread | ( | ) |
rm_dbthtread class serializes and processes all RMDB related operations File: rm_dbthread.cpp Author: Toni Pljakoski, HERMES SoftLab Documented: Eberhard Leba GDS Created: 13/3/2002 Package: N/A
Copyright (c) 2007 GRAU DataStorage AG
Definition at line 30 of file rm_dbthread.cpp.
00030 : 00031 00032 m_reqInput_c(&m_request_x), 00033 m_reqOutput_c(&m_request_x), 00034 m_reqFree_c(&m_request_x), 00035 m_operation(NULL), 00036 m_active(false), 00037 m_suspended(false), 00038 m_shutdown(false), 00039 m_errNum(0), 00040 m_jobNum(0) 00041 { 00042 /*empty*/ 00043 }
| rm_DBThread::~rm_DBThread | ( | ) |
| void rm_DBThread::Run | ( | void * | arg | ) | [private, virtual] |
Main RMDB request loop.
All RMDB operation pass here. They are submitted by a requestor.
We wait in a loop until a valid input request arrives indicated by m_reqInput_c or until we get a shutdown is signal.
In case we have been waked up we try to process the incoming request using m_operation->Process.
ivd exception Error handling is done in case a problem happened inside processing. In such a case we store the problem in m_errNum and m_errDesc
As a general Error handling for uncatched Exceptions we frankly ignore them. This case especialy occures if we have been waked up and there is no request. In such a case m_operation is NULL, so we stay inside the inner loop and no one is bothered.
Once the request has completed, the requestor is notified in the broadcast using m_reqOutput_c .
Reimplemented from cmn_Thread.
Definition at line 172 of file rm_dbthread.cpp.
References cmn_Condition::Broadcast(), dbg_DETAIL, ivd_BaseException::GetContext(), ivd_BaseException::GetError(), log_DBG_m, log_FUNC_m, m_errDesc, m_errNum, m_operation, m_reqInput_c, m_reqOutput_c, m_request_x, m_shutdown, NULL, rm_DBOperation::Process(), and cmn_Condition::Wait().
00172 { 00173 log_FUNC_m(Run); 00174 cmn_MutexLock l(m_request_x); 00175 while (!m_shutdown) { 00178 while (m_operation == NULL){ 00179 log_DBG_m(dbg_DETAIL,"Waiting for next request ..."); 00180 m_reqInput_c.Wait(); 00181 if (m_shutdown) return; 00182 } 00183 00184 try { 00185 log_DBG_m(dbg_DETAIL,"Processing ..."); 00188 m_operation->Process(); 00189 //log_DBG_m(dbg_DETAIL,"Processed"); 00190 } catch (ivd_Exception & e){ 00194 log_DBG_m(dbg_DETAIL,"Exception on Processed " << e); 00195 m_errNum = e.GetError(); 00196 m_errDesc = e.GetContext(); 00197 } catch (...){ 00198 //log_DBG_m(dbg_DETAIL,"Unknown on Processed"); 00204 m_errNum = 0; 00205 m_errDesc = "unknown"; 00206 } 00207 00208 m_operation = NULL; 00211 m_reqOutput_c.Broadcast(); 00212 00213 } 00214 }

| void rm_DBThread::Process | ( | rm_DBOperation * | a_operation | ) |
rm_DBThread::Process() Processing one single incoming request
A single request passed in a_operation is processed here In case a second process comes in, that one must wait.
In case a second process comes in, that one must wait.
The process passing the m_active gate is processed.
for this proposal we store the operation locally in the rm_DBThread instance.
Once the operation was stored we send a broadcast using m_reqInput_c notifying requestors that some other request may be made.
We then wait in a loop until the operation has cpmpleted.
Finally we open the m_active gate again to let the next operation pass in and check the result. In case of an error we throw ivd_Error.
Definition at line 122 of file rm_dbthread.cpp.
References cmn_Condition::Broadcast(), dbg_DETAIL, ivd_Error, log_DBG_m, log_FUNC_m, m_active, m_errDesc, m_errNum, m_jobNum, m_operation, m_reqFree_c, m_reqInput_c, m_reqOutput_c, m_request_x, NULL, and cmn_Condition::Wait().
Referenced by rm_DBOperation::Execute().
00122 { 00123 log_FUNC_m(Process); 00124 00125 cmn_MutexLock l(m_request_x); 00127 while (m_active){ 00128 log_DBG_m(dbg_DETAIL,"Waiting for other active job .."); 00129 m_reqFree_c.Wait(); 00130 } 00131 m_active = true; 00133 // EL: Why do we a doulbe lock here ? 00134 00135 log_DBG_m(dbg_DETAIL,"Job:[" << ++m_jobNum << "] Active"); 00136 00139 m_operation = a_operation; 00142 m_reqInput_c.Broadcast(); 00143 00144 while (m_operation != NULL){ 00146 log_DBG_m(dbg_DETAIL,"Waiting for results ..."); 00147 m_reqOutput_c.Wait(); 00148 } 00149 m_active = false; 00152 if (m_errNum == 0 ){ 00153 log_DBG_m(dbg_DETAIL,"Job:[" << m_jobNum << "] Finished"); 00154 m_reqFree_c.Broadcast(); 00155 return; 00156 } 00157 else { 00158 Int32_t errNum = m_errNum; 00159 m_errNum = 0; 00160 string errdesc(m_errDesc); 00161 log_DBG_m(dbg_DETAIL,"Job:[" << m_jobNum << "] Finished"); 00162 m_reqFree_c.Broadcast(); 00163 throw ivd_Error(errNum, m_errDesc); 00164 } 00165 }


| Int32_t rm_DBThread::Suspend | ( | void | ) |
rm_DBThread::Suspend() Suspend RMDB activity for backup proposes
Method waits for a running request to complete and intercepts the other pending requests holding m_active.
Definition at line 56 of file rm_dbthread.cpp.
References dbg_DETAIL, dbg_LOW, rm_DB::Disconnect(), ie_NO_ERROR, ie_RMDB_ERROR, log_DBG_m, log_FUNC_m, m_active, rm_Operator::m_dataBase, m_reqFree_c, m_request_x, m_rmOp, m_suspended, and cmn_Condition::Wait().
Referenced by i_ResourceManager_i::Suspend().
00056 { 00057 log_FUNC_m(Suspend); 00058 cmn_MutexLock l(m_request_x); 00059 if (m_suspended) { 00060 log_DBG_m(dbg_DETAIL,"RMDB already suspended ! Ignoring call"); 00061 return ie_RMDB_ERROR; 00062 } 00063 00064 while (m_active){ 00065 log_DBG_m(dbg_DETAIL,"Suspend is waiting for other active job .."); 00066 m_reqFree_c.Wait(); 00067 } 00068 m_active = true; 00069 m_suspended = true; 00070 m_rmOp.m_dataBase.Disconnect(); 00071 log_DBG_m(dbg_LOW, "RMDB Suspended"); 00072 return ie_NO_ERROR; 00073 }


| Int32_t rm_DBThread::Resume | ( | void | ) |
rm_DBThread::Resume() Resume RMDB activity
Definition at line 79 of file rm_dbthread.cpp.
References cmn_Condition::Broadcast(), rm_DB::Connect(), dbg_DETAIL, dbg_LOW, ivd_BaseException::GetContext(), ivd_BaseException::GetError(), ie_NO_ERROR, ie_RMDB_CONNECTPROBLEM, ie_RMDB_ERROR, log_DBG_m, log_ERR_m, log_FUNC_m, m_active, rm_Operator::m_dataBase, m_errDesc, m_errNum, m_reqFree_c, m_reqInput_c, m_request_x, m_rmOp, m_shutdown, and m_suspended.
Referenced by i_ResourceManager_i::Resume().
00079 { 00080 log_FUNC_m(Resume); 00081 cmn_MutexLock l(m_request_x); 00082 00083 if (! m_suspended) { 00084 log_DBG_m(dbg_DETAIL,"RMDB not suspended ! Ignoring call"); 00085 return ie_RMDB_ERROR; 00086 } 00087 00088 if ( ! m_active){ 00089 log_DBG_m(dbg_DETAIL,"Resume of already active RMDB skipped"); 00090 return ie_RMDB_ERROR; 00091 } 00092 try { 00093 m_rmOp.m_dataBase.Connect(); 00094 m_active = false; 00095 m_suspended = false; 00096 log_DBG_m(dbg_LOW, "RMDB Resumed"); 00097 m_reqFree_c.Broadcast(); // notify waiting threads that the gate is free 00098 } catch (ivd_DBException & e){ 00099 log_DBG_m(dbg_DETAIL,"Exception on Resume" << e); 00100 m_errNum = e.GetError(); 00101 m_errDesc = e.GetContext(); 00102 log_ERR_m("Exception occured resuming the Database, correct the error" 00103 " and restart the system. Details: " << m_errDesc ); 00104 m_active = false; 00105 m_suspended = false; 00106 m_shutdown = true; 00107 log_DBG_m(dbg_LOW, "RMDB Resume: Shutting down RM"); 00108 m_reqInput_c.Broadcast(); 00109 return ie_RMDB_CONNECTPROBLEM; 00110 } 00111 return ie_NO_ERROR; 00112 }


friend class i_ResourceManager_i [friend] |
Definition at line 25 of file rm_dboperation.h.
cmn_Mutex rm_DBThread::m_request_x [private] |
cmn_Condition rm_DBThread::m_reqInput_c [private] |
Definition at line 33 of file rm_dboperation.h.
Referenced by Process(), Resume(), Run(), and i_ResourceManager_i::~i_ResourceManager_i().
cmn_Condition rm_DBThread::m_reqOutput_c [private] |
cmn_Condition rm_DBThread::m_reqFree_c [private] |
Definition at line 42 of file rm_dboperation.h.
Referenced by dbo_ClearReorgScan::Process(), dbo_SetReorgScan::Process(), dbo_PoolInfo::Process(), dbo_ReleaseResources::Process(), dbo_ClearPartitionStatus::Process(), dbo_SetPartitionStatus::Process(), dbo_EnablePartition::Process(), dbo_DisablePartition::Process(), dbo_SelectAllPartition::Process(), dbo_UpdatePartition::Process(), dbo_RemovePartition::Process(), dbo_InsertPartition::Process(), dbo_SelectPartitionByUuid::Process(), dbo_SelectPartition::Process(), dbo_GetHost::Process(), dbo_AllocateAdmin::Process(), dbo_AllocateRec::Process(), dbo_AllocateMig::Process(), dbo_InitAllResource::Process(), dbo_InventoryUpdate::Process(), dbo_LibraryStatusClear::Process(), dbo_LibraryStatusSet::Process(), dbo_DriveStatusClear::Process(), dbo_DriveStatusSet::Process(), dbo_VolumeListStatusSet::Process(), dbo_MedVolStatusClear::Process(), dbo_MedVolStatusSet::Process(), dbo_MediumStatusClear::Process(), dbo_MediumStatusSet::Process(), dbo_MediumUnusable::Process(), dbo_MediumUnreliable::Process(), dbo_DriveError::Process(), dbo_VolumeError::Process(), dbo_VolumeUsage::Process(), dbo_VolumeEmpty::Process(), dbo_VolumeFull::Process(), dbo_MediumUnloaded::Process(), dbo_MediumLoaded::Process(), dbo_GetBestCopy::Process(), dbo_UpdateDataSize::Process(), dbo_ClearRecoveryFlag::Process(), dbo_SetRecoveryFlag::Process(), dbo_GetMediaInfo::Process(), dbo_SelectAllMediumVolByBarcode::Process(), dbo_IsSomeVolumeUsed::Process(), dbo_SelectAllMediaByPart::Process(), dbo_SelectAllMediumVolByPart::Process(), dbo_SelectAllMediumVol::Process(), dbo_RemoveMediumVol::Process(), dbo_AddMediumVol::Process(), dbo_UpdateMediumVol::Process(), dbo_SelectMediumVolByUUID::Process(), dbo_SelectMediumVolByKey::Process(), dbo_SelectMediumVol::Process(), dbo_SelectAllMedium::Process(), dbo_RemoveMedium::Process(), dbo_AddMedium::Process(), dbo_UpdateMedium::Process(), dbo_SelectMediumByDrive::Process(), dbo_SelectMediumByKey::Process(), dbo_SelectMedium::Process(), dbo_SelectAllMediaPool::Process(), dbo_RemoveMediaPool::Process(), dbo_AddMediaPool::Process(), dbo_UpdateMediaPool::Process(), dbo_SelectMediaPoolByKey::Process(), dbo_SelectMediaPoolbyUUID::Process(), dbo_SelectMediaPool::Process(), dbo_SelectAllSlots::Process(), dbo_RemoveSlot::Process(), dbo_AddSlot::Process(), dbo_UpdateSlot::Process(), dbo_SelectSlotByKey::Process(), dbo_SelectSlot::Process(), dbo_SelectAllDiskSubsys::Process(), dbo_RemoveDiskSubsys::Process(), dbo_AddDiskSubsys::Process(), dbo_UpdateDiskSubsys::Process(), dbo_SelectDiskSubsysByKey::Process(), dbo_SelectDiskSubsys::Process(), dbo_SelectAllDriveHosts::Process(), dbo_RemoveDriveHost::Process(), dbo_AddDriveHost::Process(), dbo_UpdateDriveHost::Process(), dbo_SelectDriveHostByKey::Process(), dbo_SelectDriveHost::Process(), dbo_SelectAllDrives::Process(), dbo_RemoveDrive::Process(), dbo_AddDrive::Process(), dbo_UpdateDrive::Process(), dbo_SelectDriveByKey::Process(), dbo_SelectDrive::Process(), dbo_SelectAllColVolumes::Process(), dbo_SelectAllMinorCol::Process(), dbo_SelectAllMajorCol::Process(), dbo_UpdateMinorCol::Process(), dbo_UpdateMajorCol::Process(), dbo_SelectMinColByMajCol::Process(), dbo_SelectMinorCol::Process(), dbo_SelectMajorCol::Process(), dbo_RemoveColIDs::Process(), dbo_RemoveColMediaVol::Process(), dbo_RemoveMinorCol::Process(), dbo_RemoveMajorCol::Process(), dbo_CheckAndAddColMediaVol::Process(), dbo_AddColMediaVol::Process(), dbo_AddMinorCol::Process(), dbo_AddMajorCol::Process(), dbo_RemoveLibrary::Process(), dbo_AddLibrary::Process(), dbo_UpdateLibrary::Process(), dbo_SelectAllLibraries::Process(), dbo_SelectLibraryByKey::Process(), dbo_SelectLibrary::Process(), Resume(), and Suspend().
rm_DBOperation* rm_DBThread::m_operation [private] |
bool rm_DBThread::m_suspended [private] |
Definition at line 51 of file rm_dboperation.h.
Referenced by Resume(), Run(), and i_ResourceManager_i::~i_ResourceManager_i().
| string rm_DBThread::m_errDesc |
1.5.6