i_BackupJob_i Class Reference
[Management Interface]

#include <i_adminjob_impl.h>

Inheritance diagram for i_BackupJob_i:

Inheritance graph
[legend]
Collaboration diagram for i_BackupJob_i:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 153 of file i_adminjob_impl.h.


Public Member Functions

 i_BackupJob_i (mif_JobManager &jobManager, const char *a_barcode)
virtual ~i_BackupJob_i ()
void MediumOperationComplete (i_Index_t beaNumber, i_CompletionStatus_e a_status)
virtual void CompleteJob (i_CompletionStatus_e status)
virtual void Remove ()
void GetNewResources (i_Index_t resourceNumber)
void PrepareResource ()
void AllocateDiskBuffer (i_FileSize_t a_size)

Private Member Functions

i_JobRequestList_tGetFiles ()
i_FSC_ptr GetFSC ()
void Execute ()

Private Attributes

 log_CLASSID_m
cmn_Mutex m_backupJob_x
cmn_Condition m_backupJob_c
UInt64_t m_diskBufferSize
i_MediaPool_t m_bkpPool
bool m_toSpecificMedium

Constructor & Destructor Documentation

i_BackupJob_i::i_BackupJob_i ( mif_JobManager jobManager,
const char *  a_barcode 
)

Definition at line 41 of file i_backupjob_impl.cpp.

References i_JobParams::bufType, dbg_LOW, evt_BACKUPJOB, i_Job_i::GetResources(), i_DISK_BUF, i_SUCCEDED, ie_PRECONDITION, ipc_EXEC_m, ivd_Error, i_JobParams::jobID, i_JobParams::jobType, jt_BACKUP, log_DBG_m, log_FUNC_m, log_WriteEvent(), log_WRN_m, ipc_Log::LogJobParams(), ipc_Log::LogResources(), i_Job_i::m_activeBeas, m_bkpPool, i_Job_i::m_iJobParams, i_Job_i::m_rm, m_toSpecificMedium, i_MediaPool_t::mediaPoolKey, i_MediaPool_t::mediaPoolName, i_JobParams::partUUID, pt_Backup, ipc_Init::ResourceInit(), rmdb_MEDIUM_UNRELIABLE, rmdb_MEDIUM_UNUSABLE, i_Job_i::SetCompletionStatus(), and i_Job_i::SetResources().

00042     :   i_Job_i(a_jobManager),
00043         m_backupJob_c(&m_backupJob_x),
00044         m_diskBufferSize(0)
00045         {
00046     log_FUNC_m(i_BackupJob_i);
00047 
00048     m_iJobParams.jobType          = jt_BACKUP;
00049     m_iJobParams.bufType          = i_DISK_BUF;
00050     
00051     SetCompletionStatus(i_SUCCEDED);
00052 
00053     if (strlen(a_barCode) > 0) {
00054         m_toSpecificMedium = true;
00055     }
00056     else {
00057         m_toSpecificMedium = false;
00058     }
00059 
00060     i_ResourceList_t resources;
00061     resources.length(1);
00062     ipc_Init::ResourceInit(resources[0]);
00063 
00064     i_MediaPoolSeq_t_var allPools;
00065     try {
00066         ipc_EXEC_m(allPools = m_rm->SelectAllMediaPools();)
00067     } catch (ivd_Exception &e){
00068         log_DBG_m(dbg_LOW,e);
00069         throw;
00070     }
00071 
00072     bool foundFirst(false);
00073     for (UInt32_t i(0); i < allPools->length(); i++){
00074         if (allPools[i].mediaPoolType == pt_Backup) {
00075             if (foundFirst){
00076                 log_WRN_m("There are two Backup pools defined in RMDB. Only first will be used.")
00077             }
00078             foundFirst = true;
00079             m_iJobParams.partUUID       = allPools[i].partitionUUIDString;
00080             m_bkpPool = allPools[i];
00081         }
00082     }
00083     resources[0].poolKey = m_bkpPool.mediaPoolKey;
00084     
00085     if (strlen(a_barCode) > 0) {
00086         resources[0].barcode = CORBA::string_dup(a_barCode);
00087 
00088         //Check if medium exists
00089         i_Medium_t_var medium;
00090         try {
00091             ipc_EXEC_m(medium = m_rm->SelectMedium(a_barCode);)
00092         }
00093         catch (ivd_Exception &e){
00094             log_DBG_m(dbg_LOW,e);
00095             throw ivd_Error(ie_PRECONDITION, "Requested medium does not exist.");
00096         }
00097         resources[0].mediumKey = medium->mediumKey;
00098         //Check if medium is usable
00099         if (medium->status & rmdb_MEDIUM_UNRELIABLE ){
00100             throw ivd_Error(ie_PRECONDITION, "Medium is marked as UNRELIABLE.", true);
00101         }
00102         if (medium->status & rmdb_MEDIUM_UNUSABLE){
00103             throw ivd_Error(ie_PRECONDITION, "Medium is marked as UNUSABLE.", true);
00104         }
00105         if (strcmp(medium->mediaPoolName, m_bkpPool.mediaPoolName) != 0 ){
00106             throw ivd_Error(ie_PRECONDITION, "Medium does not belong to backup pool.", true);
00107         }
00108 
00109         //Check if medium is initialized
00110         i_MediumVolSeq_t_var mediumVols;
00111         try {
00112             ipc_EXEC_m(mediumVols = m_rm->SelectAllMediumVolByBarcode(a_barCode);)
00113         }
00114         catch (ivd_Exception &e){
00115             log_DBG_m(dbg_LOW,e);
00116             throw ivd_Error(ie_PRECONDITION, "Selecting volumes failed.");
00117         }
00118         if (mediumVols->length() == 0 ){
00119             throw ivd_Error(ie_PRECONDITION, "Medium does not have initialized volumes.", true);
00120         }
00121     }
00122     
00123     SetResources(resources);
00124 
00125     m_activeBeas.resize(GetResources().length());
00126 
00127     log_DBG_m(dbg_LOW, "" << endl <<
00128         "Backup Job Created:" << endl <<
00129         ipc_Log::LogJobParams(m_iJobParams) << endl <<
00130         ipc_Log::LogResources(GetResources()) << endl);
00131 
00132     log_WriteEvent("Started.", evt_BACKUPJOB, m_iJobParams.jobID);
00133 
00134 } //i_BackupJob_i::i_BackupJob_i

Here is the call graph for this function:

i_BackupJob_i::~i_BackupJob_i (  )  [virtual]

Definition at line 137 of file i_backupjob_impl.cpp.

References log_FUNC_m.

00137                               {
00138     log_FUNC_m(~i_BackupJob_i);
00139 } // i_BackupJob_i::~i_BackupJob_i


Member Function Documentation

void i_BackupJob_i::MediumOperationComplete ( i_Index_t  beaNumber,
i_CompletionStatus_e  a_status 
) [virtual]

Implements i_Job_i.

void i_BackupJob_i::CompleteJob ( i_CompletionStatus_e  status  )  [virtual]

Implements i_Job_i.

Definition at line 278 of file i_backupjob_impl.cpp.

References i_Job_i::IsAborted(), log_FUNC_m, and Remove().

00278                                                            {
00279     log_FUNC_m(CompleteJob);
00280         if (IsAborted()) {
00281         Remove();
00282     }
00283 }

Here is the call graph for this function:

void i_BackupJob_i::Remove (  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 285 of file i_backupjob_impl.cpp.

References cmn_Condition::Broadcast(), evt_BACKUPJOB, evt_ERROR, evt_WARNING, i_SUCCEDED, ipc_CATCH_IVD_THROW_CORBA_m, i_JobParams::jobID, log_FUNC_m, log_WriteEvent(), i_Job_i::m_aborted, i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_backupJob_c, m_backupJob_x, i_Job_i::m_iJobParams, i_Job_i::m_status, and i_Job_i::Remove().

Referenced by CompleteJob().

00285                            {
00286     log_FUNC_m(Remove);
00287 
00288     try {
00289 
00290         {
00291             //unlock backup waiting mutex
00292             cmn_MutexLock l(m_backupJob_x);
00293             m_backupJob_c.Broadcast();
00294         }
00295         
00296         {
00297             //unlock main waiting mutex
00298             cmn_MutexLock l(m_activate_x);
00299             m_activate_c.Broadcast();
00300         }
00301 
00302         if (m_status == i_SUCCEDED) {
00303             log_WriteEvent("Finished.", evt_BACKUPJOB, m_iJobParams.jobID);
00304         } 
00305         else if (m_aborted) {
00306             log_WriteEvent(evt_WARNING, "Aborted.",
00307                            evt_BACKUPJOB, m_iJobParams.jobID);
00308         }
00309         else {
00310             ostringstream msg;
00311             msg << "Failed (" << m_status << ").";
00312             log_WriteEvent(evt_ERROR, msg.str(),
00313                            evt_BACKUPJOB, m_iJobParams.jobID);
00314         }
00315         i_Job_i::Remove();
00316     }
00317     ipc_CATCH_IVD_THROW_CORBA_m
00318 } // i_BackupJob_i::Remove

Here is the call graph for this function:

Here is the caller graph for this function:

void i_BackupJob_i::GetNewResources ( i_Index_t  resourceNumber  )  [virtual]

Implements i_Job_i.

Definition at line 206 of file i_backupjob_impl.cpp.

References i_Job_i::GetResources(), i_RESOURCE_ERROR, ie_PRECONDITION, ipc_CATCH_IVD_THROW_CORBA_m, ipc_EXEC_m, ivd_Error, job_MED_PROC, log_ERR_m, log_FUNC_m, m_backupJob_c, m_backupJob_x, i_Job_i::m_iJobParams, i_Job_i::m_rm, i_Job_i::m_status, i_JobParams::phase, i_Job_i::SetResRequested(), i_Job_i::SetStatus(), and cmn_Condition::Wait().

00206                                                       {
00207     log_FUNC_m(GetNewResources);
00208 
00209     //a_resNum is always 0 for Backup job
00210     try {
00211         ipc_EXEC_m(
00212 
00213             if( GetResources()[0].resRequested == true ||
00214                 GetResources()[0].resAllocated == true){
00215                     throw ivd_Error(ie_PRECONDITION, "Previous resources were not freed yet.");
00216                 }
00217             m_iJobParams.phase++;
00218         )
00219         try {
00220             SetStatus(job_MED_PROC);
00221 
00222             ipc_EXEC_m(
00223                 SetResRequested(0);
00224                 m_rm->GetResources(this->_this(), m_iJobParams, GetResources());
00225             );
00226         }
00227         catch (ivd_Exception &ex) {
00228             log_ERR_m("Catched Exception when calling RM GetResources " << ex);
00229             m_status = i_RESOURCE_ERROR;
00230             throw;
00231         }
00232 
00233         //wait for resources to be allocated and prepared
00234 
00235         cmn_MutexLock l(m_backupJob_x);
00236         m_backupJob_c.Wait();
00237 
00238     } ipc_CATCH_IVD_THROW_CORBA_m
00239 } // i_BackupJob_i::GetResources

Here is the call graph for this function:

void i_BackupJob_i::PrepareResource (  ) 

Definition at line 142 of file i_backupjob_impl.cpp.

References i_Job_i::GetResources(), i_LA_ERROR, i_RESOURCE_ERROR, ipc_EXEC_m, i_Job_i::LoadUnload(), log_ERR_m, log_FUNC_m, i_Job_i::m_rm, i_Job_i::m_status, i_Job_i::SetDriveProperties(), i_Job_i::SetResources(), and i_Job_i::SetResProcessed().

Referenced by Execute().

00142                                    {
00143     log_FUNC_m(PrepareResource);
00144 
00145     try {
00146         // Select the medium volume to use
00147         // Assumption: Backup medium has only one volume
00148         i_MediumVol_t_var volume;
00149 
00150         i_ResourceList_t resources;
00151         resources.length(1);
00152         resources[0] = GetResources()[0];
00153 
00154         ipc_EXEC_m(
00155             volume = m_rm->SelectMediumVol(
00156                 CORBA::string_dup(resources[0].barcode),
00157                 1);
00158         );
00159         resources[0].medVolNr = volume->medVolNr;
00160         resources[0].medVolId = CORBA::string_dup(volume->medVolId);
00161         resources[0].medVolType = volume->volType;
00162         SetResources(resources);
00163     }
00164     catch (ivd_Error& e) {
00165         log_ERR_m("Caught Exception when selecting volume ID" << e);
00166         m_status = i_RESOURCE_ERROR;
00167         throw;
00168     }
00169 
00170     try {
00171         ipc_EXEC_m(
00172             LoadUnload(0);
00173         )
00174     }
00175     catch (ivd_Error& e) {
00176         log_ERR_m("Caught Exception when calling Library Agent " << e);
00177         m_status = i_LA_ERROR;
00178         throw;
00179     }
00180 
00181     try {
00182         SetDriveProperties(0);
00183         SetResProcessed(0);
00184     }
00185     catch (ivd_Error& e) {
00186         log_ERR_m("Caught Exception when setting Drive properties" << e);
00187         m_status = i_RESOURCE_ERROR;
00188         throw;
00189     }
00190 }

Here is the call graph for this function:

Here is the caller graph for this function:

void i_BackupJob_i::AllocateDiskBuffer ( i_FileSize_t  a_size  )  [virtual]

Reimplemented from i_Job_i.

Definition at line 193 of file i_backupjob_impl.cpp.

References ipc_CATCH_IVD_THROW_CORBA_m, log_FUNC_m, i_Job_i::m_rm, and i_Job_i::RequestDiskBuffer().

00193                                                          {
00194     log_FUNC_m(AllocateDiskBuffer);
00195     UInt64_t allocated(0);
00196 
00197     try {
00198         string mif("mif");
00199         UInt64_t maxDiskBuff = m_rm->GetMaxDiskBufferSize(mif.c_str());
00200         RequestDiskBuffer(a_size, a_size, allocated, maxDiskBuff);
00201     }
00202     ipc_CATCH_IVD_THROW_CORBA_m;
00203 }

Here is the call graph for this function:

i_JobRequestList_t * i_BackupJob_i::GetFiles (  )  [private, virtual]

Implements i_Job_i.

Definition at line 366 of file i_backupjob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, and log_FUNC_m.

00366                                             {
00367     log_FUNC_m(GetFiles);
00368     try {
00369         throw ivd_Error(ie_IMPOSSIBLE);
00370     }
00371     ipc_CATCH_IVD_THROW_CORBA_m
00372 } // i_BackupJob_i::GetFiles

i_FSC_ptr i_BackupJob_i::GetFSC (  )  [private, virtual]

Implements i_Job_i.

Definition at line 375 of file i_backupjob_impl.cpp.

References ie_IMPOSSIBLE, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, and log_FUNC_m.

00375                                 {
00376     log_FUNC_m(GetFSC);
00377     try {
00378         i_FSC_ptr dummy;
00379         throw ivd_Error(ie_IMPOSSIBLE);
00380         return dummy;
00381     }
00382     ipc_CATCH_IVD_THROW_CORBA_m
00383 } // i_BackupJob_i::GetFSC

void i_BackupJob_i::Execute (  )  [private, virtual]

Implements i_Job_i.

Definition at line 321 of file i_backupjob_impl.cpp.

References cmn_Condition::Broadcast(), dbg_DETAIL, i_Job_i::GetResources(), ipc_EXEC_m, i_Job_i::IsAborted(), i_Job_i::IsFinished(), i_JobParams::jobID, log_DBG_m, log_ERR_m, log_FUNC_m, i_Job_i::m_activate_c, i_Job_i::m_activate_x, m_backupJob_c, m_backupJob_x, i_Job_i::m_iJobParams, PrepareResource(), and cmn_Condition::Wait().

00321                             {
00322     log_FUNC_m(Execute);
00323 
00324     try {
00325 
00326         ipc_EXEC_m(
00327             cmn_MutexLock l(m_activate_x);
00328 
00329             while ( !IsFinished() &&!IsAborted() ) {
00330 
00331                 if (GetResources()[0].resAssigned &&
00332                     !GetResources()[0].resProcessed &&
00333                     !IsAborted()){
00334                     
00335                     PrepareResource();
00336                     log_DBG_m(dbg_DETAIL,"Will unlock m_backupJob_x");
00337 
00338                     cmn_MutexLock l(m_backupJob_x);
00339                     m_backupJob_c.Broadcast();
00340                 }
00341                 if ( !IsFinished() && !IsAborted() ) {
00342                     log_DBG_m(dbg_DETAIL,"[" << m_iJobParams.jobID <<
00343                         "] " <<  " waiting for resources ...");
00344                     m_activate_c.Wait();
00345                     log_DBG_m(dbg_DETAIL,"m_activate_c.Wait() retuned");
00346 
00347                 }
00348             }
00349         )
00350     }
00351     catch (ivd_Exception &ex) {
00352         log_ERR_m("Caught exception in executor->Run(): " << ex);
00353         throw;
00354     }
00355     catch (ivd_InternalError &ie){
00356         log_ERR_m("Caught internal Error in executor->Run(): " << ie);
00357         throw;
00358     }
00359     catch (...) {
00360         log_ERR_m("Caught unknown error in executor->Run().");
00361         throw;
00362     }
00363 }

Here is the call graph for this function:


Member Data Documentation

Reimplemented from i_Job_i.

Definition at line 175 of file i_adminjob_impl.h.

Definition at line 181 of file i_adminjob_impl.h.

Referenced by Execute(), GetNewResources(), and Remove().

Definition at line 182 of file i_adminjob_impl.h.

Referenced by Execute(), GetNewResources(), and Remove().

Definition at line 184 of file i_adminjob_impl.h.

Definition at line 185 of file i_adminjob_impl.h.

Referenced by i_BackupJob_i().

Definition at line 186 of file i_adminjob_impl.h.

Referenced by i_BackupJob_i().


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

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