#include <i_la-m_impl.h>


Definition at line 36 of file i_la-m_impl.h.
Public Member Functions | |
| i_LibraryAgentManual_i (string a_libName) | |
| virtual | ~i_LibraryAgentManual_i () |
| void | Inventory (CORBA::Boolean a_force) |
| void | Load (const char *a_slot, const char *a_drive, const char *a_barcode, i_JobID_t a_jobID) |
| void | Unload (const char *a_drive, const char *a_slot, const char *a_barcode, i_JobID_t a_jobID) |
| void | ConfirmMountRequest (const char *a_drive, CORBA::Boolean a_ok) |
| void | Reconfigure (const i_Library_t &a_libCfg) |
| void | Remove () |
Private Member Functions | |
| void | ReadDriveInfo () |
Private Attributes | |
| log_CLASSID_m | |
| string | m_libName |
| string | m_libHost |
| vector< la_ManualDrive > | m_drives |
| i_ResourceManager_var | m_iRM |
| void(* | m_methodFunc )(string a_addr, string a_lib, string a_host, string a_what, string a_drive, string a_bc, string a_slot) |
| string | m_methodAddr |
Static Private Attributes | |
| static cmn_Mutex | m_lib_x |
| static cmn_Condition | m_lib_c |
| i_LibraryAgentManual_i::i_LibraryAgentManual_i | ( | string | a_libName | ) |
Definition at line 83 of file i_la-m_impl.cpp.
References dbg_LOW, ipc_EXEC_m, log_DBG_m, log_ERR_m, log_FUNC_A_m, m_iRM, Reconfigure(), and ipc_Corba::ResolveRM().
00084 : m_libName (a_libName) { 00085 00086 log_FUNC_A_m(i_LibraryAgentManual_i, "libName: " << a_libName); 00087 00088 ipc_EXEC_m( 00089 CORBA::Object_var obj = ipc_Corba::ResolveRM(); 00090 m_iRM = i_ResourceManager::_narrow(obj); 00091 ); 00092 00093 i_Library_t_var lib; 00094 try { 00095 ipc_EXEC_m( 00096 lib = m_iRM->SelectLibrary( CORBA::string_dup(a_libName.c_str()) ); 00097 ); 00098 } 00099 catch (...) { 00100 log_ERR_m( 00101 "Can't get library's control device for " << 00102 a_libName); 00103 00104 throw; 00105 } 00106 00107 Reconfigure(lib); 00108 00109 log_DBG_m(dbg_LOW, endl << 00110 "** Starting library agent **" << endl << 00111 " - Name : " << a_libName << endl ); 00112 }

| i_LibraryAgentManual_i::~i_LibraryAgentManual_i | ( | ) | [virtual] |
Definition at line 115 of file i_la-m_impl.cpp.
References log_FUNC_m, and ipc_Corba::Shutdown().
00115 { 00116 log_FUNC_m(~i_LibraryAgentManual_i); 00117 00118 ipc_Corba::Shutdown(); 00119 }

| void i_LibraryAgentManual_i::ReadDriveInfo | ( | ) | [private] |
Definition at line 39 of file i_la-m_impl.cpp.
References dbg_DETAIL, la_ManualDrive::driveIndex, i_Drive_t::driveIndex, la_ManualDrive::driveName, i_Drive_t::driveName, ipc_EXEC_m, i_Drive_t::libraryName, log_DBG_m, log_FUNC_m, log_WRN_m, m_drives, m_iRM, and m_libName.
Referenced by Inventory(), and Reconfigure().
00039 { 00040 log_FUNC_m(ReadDriveInfo); 00041 00042 try { 00043 m_drives.clear(); 00044 00045 i_DriveSeq_t_var drives; 00046 ipc_EXEC_m( 00047 drives = m_iRM->SelectAllDrives(); 00048 ); 00049 00050 for (UInt32_t i = 0; i < drives->length(); i++) { 00051 00052 i_Drive_t drive = drives[i]; 00053 00054 if (m_libName == string(drive.libraryName) ) { 00055 00056 log_DBG_m(dbg_DETAIL, 00057 "Got drive: " << drive.driveIndex << 00058 " : " << drive.driveName); 00059 00060 la_ManualDrive manDrive; 00061 00062 manDrive.driveName = drive.driveName; 00063 manDrive.driveIndex = drive.driveIndex; 00064 00065 m_drives.push_back(manDrive); 00066 } // if (m_lib 00067 } // for 00068 } 00069 catch (ivd_Exception &ie) { 00070 log_WRN_m( 00071 "Library Agent can't get tape drive info from RM." << 00072 endl << "Error: " << ie); 00073 throw; 00074 } 00075 catch (...) { 00076 log_WRN_m( 00077 "Library Agent can't get tape drive info from RM." << 00078 endl << "Error unknown."); 00079 throw; 00080 } 00081 }

| void i_LibraryAgentManual_i::Inventory | ( | CORBA::Boolean | a_force | ) |
Definition at line 123 of file i_la-m_impl.cpp.
References dbg_NORM, log_DBG_m, log_FUNC_A_m, and ReadDriveInfo().
00123 { 00124 log_FUNC_A_m(Inventory, "force: " << a_force); 00125 00126 log_DBG_m(dbg_NORM, "Inventory requested - rereading drives"); 00127 ReadDriveInfo(); 00128 }

| void i_LibraryAgentManual_i::Load | ( | const char * | a_slot, | |
| const char * | a_drive, | |||
| const char * | a_barcode, | |||
| i_JobID_t | a_jobID | |||
| ) |
Definition at line 131 of file i_la-m_impl.cpp.
References dbg_NORM, la_ManualDrive::driveName, evt_ERROR, ivd_BaseException::GetFriendly(), ie_FATAL_ERROR, ie_LA_MOUNTDENY, ie_LA_UNCONFIGURED, ipc_CATCH_IVD_THROW_CORBA_m, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_A_m, log_WriteEvent(), m_drives, m_iRM, m_lib_c, m_lib_x, m_libHost, m_libName, m_methodAddr, m_methodFunc, la_ManualDrive::mountConfirmed, la_ManualDrive::mountOK, NULL, and cmn_Condition::Wait().
00135 { 00136 00137 log_FUNC_A_m(Load, 00138 "slot: " << a_slot << 00139 " drive: " << a_drive << 00140 " barcode: " << a_barcode << 00141 " job: " << a_jobID); 00142 00143 cmn_MutexLock l(m_lib_x); 00144 00145 try { 00146 00147 la_ManualDrive *drive = NULL; 00148 for (UInt32_t i=0; i < m_drives.size(); ++i) { 00149 if (m_drives[i].driveIndex == a_drive) { 00150 drive = &m_drives[i]; 00151 break; 00152 } 00153 } 00154 00155 if (!drive) { 00156 log_DBG_m(dbg_NORM, "Drive not configured: " << a_drive); 00157 ostringstream sstr; 00158 sstr << "driveIdx: " << a_drive; 00159 throw ivd_Error(ie_LA_UNCONFIGURED, sstr.str().c_str()); 00160 } 00161 00162 try { 00163 string what = "load"; 00164 m_methodFunc(m_methodAddr, m_libName, m_libHost, what, 00165 drive->driveName, a_barcode, a_slot); 00166 00167 // now wait for signal the mount request passed 00168 log_DBG_m(dbg_NORM, "Wait mount confirmation for drive: " << a_drive); 00169 drive->mountConfirmed = false; 00170 drive->mountOK = false; 00171 00172 while (!drive->mountConfirmed) { 00173 m_lib_c.Wait(); 00174 log_DBG_m(dbg_NORM, "Got signal on drive: " << a_drive); 00175 } 00176 00177 log_DBG_m(dbg_NORM, "Got mount confirmation for drive: " << a_drive); 00178 00179 if (drive->mountOK) { 00180 ipc_EXEC_m( 00181 m_iRM->MediumLoaded( 00182 CORBA::string_dup(m_libName.c_str()), 00183 CORBA::string_dup(a_barcode), 00184 CORBA::string_dup(a_drive) ); 00185 ); 00186 00187 ostringstream sstr; 00188 sstr << "Move: D=" << a_drive << " <- S=none."; 00189 log_WriteEvent(sstr.str(), "", a_jobID, a_barcode); 00190 } 00191 else { 00192 throw ivd_Error(ie_LA_MOUNTDENY, "Load failed"); 00193 } 00194 } 00195 catch (ivd_Exception &ie) { 00196 ostringstream sstr; 00197 sstr 00198 << "Move: D=" << a_drive << " <- S=none FAILED (" 00199 << ie.GetFriendly() << ")."; 00200 log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode); 00201 00202 throw; 00203 } 00204 catch (...) { 00205 ostringstream sstr; 00206 sstr << "Move: D=" << a_drive << " <- S=none FAILED."; 00207 log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode); 00208 00209 throw ivd_Error( 00210 ie_FATAL_ERROR, "Unknown exception performing Load."); 00211 } 00212 } ipc_CATCH_IVD_THROW_CORBA_m 00213 }

| void i_LibraryAgentManual_i::Unload | ( | const char * | a_drive, | |
| const char * | a_slot, | |||
| const char * | a_barcode, | |||
| i_JobID_t | a_jobID | |||
| ) |
Definition at line 216 of file i_la-m_impl.cpp.
References dbg_NORM, evt_ERROR, ivd_BaseException::GetFriendly(), ie_FATAL_ERROR, ie_LA_UNCONFIGURED, ipc_CATCH_IVD_THROW_CORBA_m, ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_A_m, log_WriteEvent(), m_drives, m_iRM, m_lib_x, m_libName, NULL, and rmdb_REP_SLOT_TYPE_ID.
00220 { 00221 00222 log_FUNC_A_m(Unload, 00223 "drive: " << a_drive << 00224 " slot: " << a_slot << 00225 " barcode: " << a_barcode << 00226 " job: " << a_jobID); 00227 00228 cmn_MutexLock l(m_lib_x); 00229 try { 00230 00231 la_ManualDrive *drive = NULL; 00232 for (UInt32_t i=0; i < m_drives.size(); ++i) { 00233 if (m_drives[i].driveIndex == a_drive) { 00234 drive = &m_drives[i]; 00235 break; 00236 } 00237 } 00238 00239 if (!drive) { 00240 log_DBG_m(dbg_NORM, "Drive not configured: " << a_drive); 00241 ostringstream sstr; 00242 sstr << "driveIdx: " << a_drive; 00243 throw ivd_Error(ie_LA_UNCONFIGURED, sstr.str().c_str()); 00244 } 00245 00246 try { 00247 ipc_EXEC_m( 00248 m_iRM->MediumUnLoaded( 00249 CORBA::string_dup(m_libName.c_str()), 00250 CORBA::string_dup(a_barcode), 00251 CORBA::string_dup(a_slot), 00252 rmdb_REP_SLOT_TYPE_ID ); 00253 ); 00254 00255 ostringstream sstr; 00256 sstr << "Move: D=" << a_drive << " -> S=none."; 00257 log_WriteEvent(sstr.str(), "", a_jobID, a_barcode); 00258 } 00259 catch (ivd_Exception &ie) { 00260 ostringstream sstr; 00261 sstr 00262 << "Move: D=" << a_drive << " -> S=none FAILED (" 00263 << ie.GetFriendly() << ")."; 00264 log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode); 00265 00266 throw; 00267 } 00268 catch (...) { 00269 ostringstream sstr; 00270 sstr << "Move: D=" << a_drive << " -> S=none FAILED."; 00271 log_WriteEvent(evt_ERROR, sstr.str(), "", a_jobID, a_barcode); 00272 00273 throw ivd_Error( 00274 ie_FATAL_ERROR, "Unknown exception performing Unload."); 00275 } 00276 } ipc_CATCH_IVD_THROW_CORBA_m; 00277 }

| void i_LibraryAgentManual_i::ConfirmMountRequest | ( | const char * | a_drive, | |
| CORBA::Boolean | a_ok | |||
| ) |
Definition at line 280 of file i_la-m_impl.cpp.
References cmn_Condition::Broadcast(), dbg_NORM, ie_LA_UNCONFIGURED, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, log_DBG_m, log_FUNC_A_m, m_drives, m_lib_c, m_lib_x, la_ManualDrive::mountConfirmed, la_ManualDrive::mountOK, and NULL.
00281 { 00282 log_FUNC_A_m(ConfirmMountRequest, "drive: " << a_drive << " ok: " << a_ok); 00283 00284 cmn_MutexLock l(m_lib_x); 00285 try { 00286 la_ManualDrive *drive = NULL; 00287 for (UInt32_t i=0; i < m_drives.size(); ++i) { 00288 if (m_drives[i].driveName == a_drive) { 00289 drive = &m_drives[i]; 00290 break; 00291 } 00292 } 00293 00294 if (!drive) { 00295 log_DBG_m(dbg_NORM, "Drive not configured: " << a_drive); 00296 ostringstream sstr; 00297 sstr << "drive: " << a_drive; 00298 throw ivd_Error(ie_LA_UNCONFIGURED, sstr.str().c_str()); 00299 } 00300 00301 drive->mountConfirmed = true; 00302 drive->mountOK = a_ok; 00303 00304 log_DBG_m(dbg_NORM, "Sending signal for drive: " << a_drive); 00305 m_lib_c.Broadcast(); 00306 00307 } ipc_CATCH_IVD_THROW_CORBA_m; 00308 }

| void i_LibraryAgentManual_i::Reconfigure | ( | const i_Library_t & | a_libCfg | ) |
Definition at line 310 of file i_la-m_impl.cpp.
References i_Library_t::controlDevice, dbg_LOW, i_Library_t::host, ie_FATAL_ERROR, ipc_CATCH_IVD_THROW_CORBA_m, ivd_Error, log_DBG_m, log_ERR_m, log_FUNC_m, m_libHost, m_methodAddr, m_methodFunc, ReadDriveInfo(), SendEmail(), and SendMsg().
Referenced by i_LibraryAgentManual_i().
00310 { 00311 log_FUNC_m(Reconfigure); 00312 00313 try { 00314 m_libHost = string(a_libCfg.host); 00315 string methodStr = string(a_libCfg.controlDevice); 00316 00317 if (methodStr.substr(0, 7) == string("mailto:")) { 00318 m_methodFunc = SendEmail; 00319 m_methodAddr = methodStr.substr(7); 00320 } 00321 else if (methodStr.substr(0, 8) == string("writeto:")) { 00322 m_methodFunc = SendMsg; 00323 m_methodAddr = methodStr.substr(8); 00324 } 00325 else { 00326 log_ERR_m("Manual robot method not supported: " << methodStr); 00327 00328 throw ivd_Error( 00329 ie_FATAL_ERROR, "Invalid method for Manual Robot"); 00330 } 00331 00332 // now read all drive connected to this library 00333 ReadDriveInfo(); 00334 00335 log_DBG_m(dbg_LOW, endl << 00336 " - Method : " << methodStr ); 00337 00338 } ipc_CATCH_IVD_THROW_CORBA_m; 00339 }


| void i_LibraryAgentManual_i::Remove | ( | ) | [virtual] |
Reimplemented from i_Component_i.
Definition at line 341 of file i_la-m_impl.cpp.
References log_FUNC_m, and i_Component_i::Remove().
00341 { 00342 log_FUNC_m(Remove); 00343 00344 i_Component_i::Remove(); 00345 }

i_LibraryAgentManual_i::log_CLASSID_m [private] |
cmn_Mutex i_LibraryAgentManual_i::m_lib_x [static, private] |
Definition at line 43 of file i_la-m_impl.h.
Referenced by ConfirmMountRequest(), Load(), and Unload().
cmn_Condition i_LibraryAgentManual_i::m_lib_c [static, private] |
string i_LibraryAgentManual_i::m_libName [private] |
string i_LibraryAgentManual_i::m_libHost [private] |
vector<la_ManualDrive> i_LibraryAgentManual_i::m_drives [private] |
Definition at line 49 of file i_la-m_impl.h.
Referenced by ConfirmMountRequest(), Load(), ReadDriveInfo(), and Unload().
i_ResourceManager_var i_LibraryAgentManual_i::m_iRM [private] |
Definition at line 51 of file i_la-m_impl.h.
Referenced by i_LibraryAgentManual_i(), Load(), ReadDriveInfo(), and Unload().
void(* i_LibraryAgentManual_i::m_methodFunc)(string a_addr, string a_lib, string a_host, string a_what, string a_drive, string a_bc, string a_slot) [private] |
Referenced by Load(), and Reconfigure().
string i_LibraryAgentManual_i::m_methodAddr [private] |
1.5.6