#include <jobs.h>


Definition at line 78 of file jobs.h.
Public Member Functions | |
| job_Manager () | |
| virtual | ~job_Manager () |
| i_ResourceManager_ptr | GetRM () |
| UInt32_t | GetJobCount () |
| void | AbortJob (UInt64_t a_JobId) |
| Removing Job from List of active. | |
| void | AbortAllJobs () |
| void | ForceEndJob (UInt64_t a_jobId) |
| i_JobList_t * | GetAllJobs () |
| i_JobParamsSeq_t * | GetAllJobParams () |
| i_Job_i * | FindJob (UInt64_t a_jobId) |
| Finding Job in active Job List. | |
| void | AddJobToList (i_Job_i *a_job) |
| inserting Job from List of active | |
| void | RemoveFromList (UInt64_t a_jobID, i_CompletionStatus_e a_status) |
| void | SetMaxRunningJobs (UInt32_t a_maxJobs) |
| i_Status_t | GetJobStatus (UInt64_t a_jobId) |
Protected Attributes | |
| UInt64_t | m_createBufSize |
| cmn_Mutex | m_diskBuf_x |
Private Attributes | |
| log_CLASSID_m | |
| cmn_Mutex | m_jobMap_x |
| job_JobList_v_t | m_jobList |
| list< job_finishedStatus > | m_finishedJobList |
| UInt32_t | m_maxRunningJobs |
| UInt32_t | m_maxRecallJobs |
| UInt32_t | m_runningJobs |
| i_ResourceManager_var | m_rm |
| job_Manager::job_Manager | ( | ) |
Definition at line 35 of file job_manager.cpp.
References log_FUNC_m.
00035 : 00036 m_maxRunningJobs(job_COUNT_NO_LIMITS), 00037 m_maxRecallJobs(0), 00038 m_runningJobs(0), 00039 m_createBufSize(0) { 00040 00041 log_FUNC_m(job_Manager); 00042 00043 }
| job_Manager::~job_Manager | ( | ) | [virtual] |
Definition at line 45 of file job_manager.cpp.
References AbortAllJobs(), dbg_LOW, ivd_Sleep, log_DBG_m, log_FUNC_m, m_jobList, and m_jobMap_x.
00045 { 00046 log_FUNC_m(~job_Manager); 00047 00048 AbortAllJobs(); 00049 UInt32_t jobMapSize(1); 00050 do { 00051 { 00052 cmn_MutexLock l(m_jobMap_x); 00053 jobMapSize = m_jobList.size(); 00054 }// Unlock here 00055 00056 if (jobMapSize > 0) { 00057 log_DBG_m(dbg_LOW,"JobManager Shutdown: Jobs are still active waiting ..."); 00058 ivd_Sleep(1); 00059 } 00060 } while ( jobMapSize > 0 ) ; 00061 00062 }

| i_ResourceManager_ptr job_Manager::GetRM | ( | ) |
Definition at line 309 of file job_manager.cpp.
References ipc_EXEC_m, log_FUNC_m, m_rm, and ipc_Corba::ResolveRM().
00309 { 00310 log_FUNC_m(GetRM); 00311 00312 ipc_EXEC_m ( 00313 if (CORBA::is_nil(m_rm)) { 00314 CORBA::Object_var obj = ipc_Corba::ResolveRM(); 00315 m_rm = i_ResourceManager::_narrow(obj); 00316 } 00317 return i_ResourceManager::_duplicate(m_rm); 00318 ); 00319 }

| UInt32_t job_Manager::GetJobCount | ( | ) |
Definition at line 261 of file job_manager.cpp.
References m_jobList, and m_jobMap_x.
Referenced by i_PartitionManager_i::GetJobCount(), and i_ManagementInterface_i::SystemStatus().
00261 { 00262 cmn_MutexLock l(m_jobMap_x); 00263 00264 return m_jobList.size(); 00265 00266 }

| void job_Manager::AbortJob | ( | UInt64_t | a_JobId | ) |
Removing Job from List of active.
Definition at line 105 of file job_manager.cpp.
References dbg_NORM, ie_JOB_NOT_FOUND, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, m_jobList, and m_jobMap_x.
Referenced by i_PartitionManager_i::AbortJob().
00105 { 00106 log_FUNC_m(AbortJob); 00107 00108 cmn_MutexLock l(m_jobMap_x); 00109 00110 // find job by its ID 00111 job_Iterator_t iter = find_if( m_jobList.begin(), 00112 m_jobList.end(), 00113 JobIDEqual(a_jobID)); 00114 00115 if (iter == m_jobList.end()) { 00116 throw ivd_Error(ie_JOB_NOT_FOUND, "Can not abort nonexistent job"); 00117 } 00118 00119 ipc_EXEC_m ( 00120 if ((*iter)->Started()){ 00121 (*iter)->AbortJob(); 00122 log_DBG_m(dbg_NORM, 00123 "Job " << a_jobID << 00124 " aborting. " ); 00125 } else { 00126 (*iter)->AbortJob(); 00127 (*iter)->Start(); 00128 log_DBG_m(dbg_NORM, 00129 "Job " << a_jobID << 00130 " job was not started yet. Removing pending job. " ); 00131 } 00132 ); 00133 }

| void job_Manager::AbortAllJobs | ( | ) |
Definition at line 209 of file job_manager.cpp.
References dbg_NORM, jt_RECOVERY, log_DBG_m, log_FUNC_m, m_jobList, and m_jobMap_x.
Referenced by i_PartitionManager_i::AbortAllJobs(), and ~job_Manager().
00209 { 00210 log_FUNC_m(AbortAllJobs); 00211 00212 cmn_MutexLock l(m_jobMap_x); 00213 00214 if (m_jobList.begin() == m_jobList.end()){ 00215 //nothing to do 00216 return; 00217 } 00218 00219 job_Iterator_t iter; 00220 for (iter = m_jobList.begin(); iter != m_jobList.end(); iter++) { 00221 try { 00222 i_Job_var job = (*iter)->GetJob(); 00223 i_JobParams_var jobParams = job->GetJobParams(); 00224 if (jobParams->jobType != jt_RECOVERY) { 00225 // Cancel all migration and recall jobs 00226 00227 log_DBG_m(dbg_NORM, "Cancelling Job:" << jobParams->jobID); 00228 (*iter)->AbortJob(); 00229 }; 00230 } 00231 catch (...) { 00232 // Ignore all exceptions and try to do as much cleanup as possible 00233 } 00234 }; 00235 00236 }

| void job_Manager::ForceEndJob | ( | UInt64_t | a_jobId | ) |
| i_JobList_t * job_Manager::GetAllJobs | ( | ) |
Definition at line 268 of file job_manager.cpp.
References log_FUNC_m, m_jobList, and m_jobMap_x.
Referenced by i_ManagementInterface_i::GetAllAdminJobs(), and i_PartitionManager_i::GetAllJobs().
00268 { 00269 00270 log_FUNC_m(GetAllJobs); 00271 00272 cmn_MutexLock l(m_jobMap_x); 00273 00274 i_JobList_t_var jobList(new i_JobList_t(m_jobList.size())); 00275 jobList->length(m_jobList.size()); 00276 00277 { 00278 job_Iterator_t i; 00279 int j; 00280 for (i = m_jobList.begin(), j = 0; i != m_jobList.end(); i++, j++) { 00281 jobList[j] = (*i)->GetJob(); 00282 }; 00283 } 00284 00285 return jobList._retn(); 00286 }

| i_JobParamsSeq_t * job_Manager::GetAllJobParams | ( | ) |
Definition at line 289 of file job_manager.cpp.
References log_FUNC_m, m_jobList, and m_jobMap_x.
Referenced by i_PartitionManager_i::GetAllJobsParam().
00289 { 00290 00291 log_FUNC_m(GetAllJobParams); 00292 00293 cmn_MutexLock l(m_jobMap_x); 00294 00295 i_JobParamsSeq_t_var jobParams(new i_JobParamsSeq_t(m_jobList.size())); 00296 jobParams->length(m_jobList.size()); 00297 00298 { 00299 job_Iterator_t i; 00300 UInt32_t j; 00301 for (i = m_jobList.begin(), j = 0; i != m_jobList.end(); i++, j++) { 00302 jobParams[j] = *((*i)->GetJobParams()); 00303 } 00304 }; 00305 00306 return jobParams._retn(); 00307 }

Finding Job in active Job List.
Definition at line 244 of file job_manager.cpp.
References ie_JOB_NOT_FOUND, ivd_Error, log_FUNC_m, m_jobList, and m_jobMap_x.
Referenced by i_ManagementInterface_i::AbortJob(), i_PartitionManager_i::GetJob(), and i_ManagementInterface_i::ListJob().
00244 { 00245 log_FUNC_m(FindJob); 00246 00247 cmn_MutexLock l(m_jobMap_x); 00248 00249 job_Iterator_t jobIter = find_if(m_jobList.begin(), 00250 m_jobList.end(), 00251 JobIDEqual(a_jobId)); 00252 00253 if (jobIter == m_jobList.end()){ 00254 throw ivd_Error(ie_JOB_NOT_FOUND); 00255 } else { 00256 return *jobIter; 00257 } 00258 }

| void job_Manager::AddJobToList | ( | i_Job_i * | a_job | ) |
inserting Job from List of active
Definition at line 68 of file job_manager.cpp.
References i_Job_i::ActivateJob(), i_Job_i::CheckJobValid(), dbg_NORM, i_Job_i::GetJobId(), i_Job_i::GetJobTypeEnum(), i_Job_i::InitJob(), job_COUNT_NO_LIMITS, jt_RECALL, log_DBG_m, log_FUNC_m, m_jobList, m_jobMap_x, m_maxRecallJobs, m_maxRunningJobs, m_runningJobs, and i_Job_i::Start().
Referenced by pm_JobMgr::CheckFSCvsIVDFS(), mif_JobManager::CreateBackupJob(), pm_JobMgr::CreateCheckFSCvsMediaJob(), pm_JobMgr::CreateCheckFSCvsMediumJob(), mif_JobManager::CreateCloseVolumeJob(), pm_JobMgr::CreateCopyContentsJob(), pm_JobMgr::CreateDelExpiredFilesJob(), mif_JobManager::CreateDuplMedJob(), pm_JobMgr::CreateEfficientRecallJobs(), mif_JobManager::CreateFormatAndInitJob(), pm_JobMgr::CreateFSCRecoveryJob(), pm_JobMgr::CreateIVDFSRecoveryJob(), pm_JobMgr::CreateMigrationJob(), pm_JobMgr::CreateRecallJob(), mif_JobManager::CreateRecreateFriAndMicJob(), pm_JobMgr::CreateReorgJob(), and pm_JobMgr::CreateReorgScanJob().
00068 { 00069 log_FUNC_m(AddJobToList); 00070 00071 a_job->InitJob(); 00072 a_job->CheckJobValid(); 00073 00074 cmn_MutexLock l(m_jobMap_x); 00075 m_jobList.push_back(a_job); 00076 00077 a_job->ActivateJob(); 00078 00079 log_DBG_m(dbg_NORM, 00080 "Job " << a_job->GetJobId() << 00081 " inserted to the map. " << 00082 m_jobList.size() << " jobs in the map."); 00083 00084 if (m_maxRunningJobs == job_COUNT_NO_LIMITS || 00085 m_runningJobs < m_maxRunningJobs) { 00086 00087 a_job->Start(); 00088 ++m_runningJobs; 00089 00090 } else if ( a_job->GetJobTypeEnum() == jt_RECALL && 00091 m_runningJobs < m_maxRecallJobs ){ 00092 00093 a_job->Start(); 00094 ++m_runningJobs; 00095 00096 } 00097 00098 log_DBG_m(dbg_NORM, "Running jobs: " << m_runningJobs); 00099 }


| void job_Manager::RemoveFromList | ( | UInt64_t | a_jobID, | |
| i_CompletionStatus_e | a_status | |||
| ) |
Definition at line 135 of file job_manager.cpp.
References cfg_DAY, dbg_LOW, dbg_NORM, ivd_BaseException::GetFriendly(), cmn_Time::GetTime_t(), ie_JOB_NOT_FOUND, ivd_Error, job_COUNT_NO_LIMITS, jt_RECALL, log_DBG_m, log_ERR_m, log_FUNC_m, m_finishedJobList, m_jobList, m_jobMap_x, m_maxRecallJobs, m_maxRunningJobs, m_runningJobs, and cmn_Time::Time2YMDhmsm().
Referenced by i_Job_i::Remove().
00135 { 00136 log_FUNC_m(RemoveFromList); 00137 00138 cmn_MutexLock l(m_jobMap_x); 00139 00140 // find job by its ID 00141 job_Iterator_t iter = find_if( m_jobList.begin(), 00142 m_jobList.end(), 00143 JobIDEqual(a_jobID)); 00144 if (iter == m_jobList.end()) { 00145 log_ERR_m("Trying to remove unexisting job. ID == " << a_jobID); 00146 throw ivd_Error(ie_JOB_NOT_FOUND, "Can not remove nonexistent job"); 00147 } 00148 00149 (void)m_jobList.erase(iter); 00150 00151 log_DBG_m(dbg_NORM, 00152 "Job " << a_jobID << " removed from the list. " << m_jobList.size() << " jobs remaining."); 00153 00154 //add job to list of finished jobs 00155 00156 job_finishedStatus job(a_jobID, a_status); 00157 m_finishedJobList.push_back(job); 00158 00159 cmn_Time nowTime; 00160 nowTime = nowTime.GetTime_t() - 2*cfg_DAY; 00161 00162 log_DBG_m(dbg_NORM, "remove Job nowTime: " << nowTime.Time2YMDhmsm()); 00163 00164 while ( m_finishedJobList.size() > 1 ){ 00165 log_DBG_m(dbg_NORM, "m_finishedJobList.size(): " << m_finishedJobList.size()); 00166 log_DBG_m(dbg_NORM, "m_finishedJobList.front().m_finishedTime: " << m_finishedJobList.front().m_finishedTime.Time2YMDhmsm()); 00167 00168 if (m_finishedJobList.front().m_finishedTime.GetTime_t() < nowTime.GetTime_t()){ 00169 log_DBG_m(dbg_NORM, "m_finishedJobList.popFront: " << m_finishedJobList.front().m_jobID); 00170 m_finishedJobList.pop_front(); 00171 00172 } else { 00173 break; 00174 } 00175 } 00176 00177 // Running jobs will be counted again 00178 m_runningJobs = 0; 00179 00180 log_DBG_m(dbg_NORM, "Will try to start any waiting jobs.."); 00181 00182 for (iter = m_jobList.begin(); iter != m_jobList.end(); iter++) { 00183 UInt64_t jobID = (*iter)->GetJobId(); 00184 00185 if ((*iter)->Started()) { 00186 ++m_runningJobs; 00187 } 00188 else if ( m_maxRunningJobs == job_COUNT_NO_LIMITS 00189 || m_runningJobs < m_maxRunningJobs 00190 || (((*iter)->GetJobTypeEnum() == jt_RECALL) && 00191 m_runningJobs < m_maxRecallJobs)) { 00192 // Start waiting jobs up to the limit. 00193 log_DBG_m(dbg_NORM, "Starting job: " << jobID); 00194 00195 try { 00196 (*iter)->Start(); 00197 ++m_runningJobs; 00198 } 00199 catch (const ivd_Exception& ie) { 00200 log_DBG_m(dbg_LOW, 00201 "Can't start job: " << jobID << ": " << ie.GetFriendly()); 00202 } 00203 } 00204 } // for 00205 00206 log_DBG_m(dbg_NORM, "Running jobs: " << m_runningJobs); 00207 }


| void job_Manager::SetMaxRunningJobs | ( | UInt32_t | a_maxJobs | ) |
Definition at line 322 of file job_manager.cpp.
References dbg_LOW, job_RECALL_FACTOR, log_DBG_m, log_FUNC_A_m, m_jobMap_x, m_maxRecallJobs, and m_maxRunningJobs.
Referenced by i_PartitionManager_i::ParseConfig().
00322 { 00323 log_FUNC_A_m(SetMaxRunningJobs, "maxJobs: " << a_maxJobs); 00324 00325 cmn_MutexLock l(m_jobMap_x); 00326 00327 const UInt32_t lowerLimit_c(3); 00328 const UInt32_t upperLimit_c(60); 00329 00330 if (a_maxJobs == 0) { 00331 log_DBG_m(dbg_LOW, "Unlimited number of jobs allowed."); 00332 m_maxRunningJobs = a_maxJobs; 00333 } 00334 else { 00335 if (a_maxJobs < lowerLimit_c) { 00336 a_maxJobs = lowerLimit_c; 00337 } 00338 else if (a_maxJobs > upperLimit_c) { 00339 a_maxJobs = upperLimit_c; 00340 } 00341 00342 log_DBG_m(dbg_LOW, "Changing job limit to: " << a_maxJobs); 00343 m_maxRunningJobs = a_maxJobs; 00344 m_maxRecallJobs = m_maxRunningJobs * job_RECALL_FACTOR; 00345 } 00346 }

| i_Status_t job_Manager::GetJobStatus | ( | UInt64_t | a_jobId | ) |
Definition at line 348 of file job_manager.cpp.
References API_JOB_IS_IN_PROGRESS, API_JOB_NOT_FOUND, dbg_LOW, log_DBG_m, log_FUNC_m, m_finishedJobList, m_jobList, and m_jobMap_x.
Referenced by i_PartitionManager_i::GetJobStatus().
00348 { 00349 log_FUNC_m(GetJobStatus); 00350 00351 cmn_MutexLock l(m_jobMap_x); 00352 00353 job_Iterator_t jobIter = find_if(m_jobList.begin(), 00354 m_jobList.end(), 00355 JobIDEqual(a_jobId)); 00356 00357 i_Status_t jobStatus; 00358 if (jobIter == m_jobList.end()){ 00359 //job is not active any more 00360 //search in finished jobs 00361 log_DBG_m(dbg_LOW, "Job finished"); 00362 00363 list<job_finishedStatus>::iterator it; 00364 log_DBG_m(dbg_LOW, "finished job list size" << m_finishedJobList.size()); 00365 bool found = false; 00366 00367 for ( it = m_finishedJobList.begin(); it != m_finishedJobList.end(); it++) { 00368 log_DBG_m(dbg_LOW, "finished job list " << it->m_jobID); 00369 if (it->m_jobID == a_jobId){ 00370 log_DBG_m(dbg_LOW, "Found job: " << a_jobId << " in finished job list" << 00371 " with status:" << it->m_status ); 00372 jobStatus = it->m_status; 00373 found = true; 00374 break; 00375 } 00376 } 00377 00378 if (!found){ 00379 log_DBG_m(dbg_LOW, "job is not active and is not in history"); 00380 jobStatus = API_JOB_NOT_FOUND; 00381 } 00382 } else { 00383 log_DBG_m(dbg_LOW, "Job Active"); 00384 jobStatus = API_JOB_IS_IN_PROGRESS; 00385 } 00386 00387 log_DBG_m(dbg_LOW, "Status:" << jobStatus); 00388 return jobStatus; 00389 }

job_Manager::log_CLASSID_m [private] |
cmn_Mutex job_Manager::m_jobMap_x [private] |
Definition at line 86 of file jobs.h.
Referenced by AbortAllJobs(), AbortJob(), AddJobToList(), FindJob(), GetAllJobParams(), GetAllJobs(), GetJobCount(), GetJobStatus(), RemoveFromList(), SetMaxRunningJobs(), and ~job_Manager().
job_JobList_v_t job_Manager::m_jobList [private] |
Definition at line 87 of file jobs.h.
Referenced by AbortAllJobs(), AbortJob(), AddJobToList(), FindJob(), GetAllJobParams(), GetAllJobs(), GetJobCount(), GetJobStatus(), RemoveFromList(), and ~job_Manager().
list<job_finishedStatus> job_Manager::m_finishedJobList [private] |
UInt32_t job_Manager::m_maxRunningJobs [private] |
Definition at line 91 of file jobs.h.
Referenced by AddJobToList(), RemoveFromList(), and SetMaxRunningJobs().
UInt32_t job_Manager::m_maxRecallJobs [private] |
Definition at line 92 of file jobs.h.
Referenced by AddJobToList(), RemoveFromList(), and SetMaxRunningJobs().
UInt32_t job_Manager::m_runningJobs [private] |
i_ResourceManager_var job_Manager::m_rm [private] |
UInt64_t job_Manager::m_createBufSize [protected] |
cmn_Mutex job_Manager::m_diskBuf_x [protected] |
1.5.6