bea_TapeVolume Class Reference
[IVD Back-End Agent]

#include <bea_tapevolume.h>

Inheritance diagram for bea_TapeVolume:

Inheritance graph
[legend]
Collaboration diagram for bea_TapeVolume:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 32 of file bea_tapevolume.h.


Public Member Functions

 bea_TapeVolume (scsi_IO *const a_scsiIO_p, bea_Medium *const a_medium_p, UInt32_t a_volNumber, UInt32_t a_size)
virtual UInt32_t GetPosition ()
virtual void Erase ()
virtual void WriteFileMarks (UInt32_t a_count=1)
virtual void Flush ()
virtual void SeekEOD ()
virtual void Rewind ()
virtual void SeekBlock (UInt32_t a_block)
virtual void SeekFileMark (Int32_t a_relativeFM)

Protected Member Functions

virtual ~bea_TapeVolume ()
virtual void WriteRaw (const UInt8_t *a_buf, UInt32_t a_size)
virtual void ReadRaw (UInt8_t *a_buf, UInt32_t a_size)
virtual void ReadEstimSizes ()
 Reads estimated overall and remaining capacity of this medium volume.

Private Attributes

 log_CLASSID_m
scsi_IO *const m_scsiIO_p

Constructor & Destructor Documentation

bea_TapeVolume::bea_TapeVolume ( scsi_IO *const   a_scsiIO_p,
bea_Medium *const   a_medium_p,
UInt32_t  a_volNumber,
UInt32_t  a_size 
)

Definition at line 38 of file bea_tapevolume.cpp.

References log_FUNC_A_m.

00043   : bea_Volume(a_medium_p, a_volNumber, a_size),
00044     m_scsiIO_p(a_scsiIO_p) {
00045 
00046     log_FUNC_A_m(bea_TapeVolume,
00047         "num: " << a_volNumber << " size: " << a_size);
00048 }

bea_TapeVolume::~bea_TapeVolume (  )  [protected, virtual]

Definition at line 52 of file bea_tapevolume.cpp.

References log_FUNC_m.

00052                                 {
00053     log_FUNC_m(~bea_TapeVolume);
00054 }


Member Function Documentation

UInt32_t bea_TapeVolume::GetPosition (  )  [virtual]

Implements bea_Volume.

Definition at line 58 of file bea_tapevolume.cpp.

References ivd_BaseException::GetError(), data_Position::GetPosition(), cdb_ReadPosition::GetPosition(), ie_SCSI_NOT_READY, scsi_IO::IOCtl(), log_FUNC_m, m_scsiIO_p, and scsi_IO::WaitToBecomeReady().

Referenced by SeekEOD().

00058                                      {
00059     log_FUNC_m(GetPosition);
00060     cdb_ReadPosition  position;
00061 
00062     try {
00063         m_scsiIO_p->IOCtl(position);
00064     }
00065     catch (ivd_Error &ie) {
00066         if (ie.GetError() == ie_SCSI_NOT_READY) {
00067             m_scsiIO_p->WaitToBecomeReady();
00068             m_scsiIO_p->IOCtl(position);
00069         }
00070         else {
00071             throw;
00072         }
00073     }
00074     return position.GetPosition().GetPosition();
00075 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_TapeVolume::Erase (  )  [virtual]

Implements bea_Volume.

Definition at line 95 of file bea_tapevolume.cpp.

References ivd_BaseException::GetError(), ie_MEDIUM_MEDERR, ie_MEDIUM_OVERFLOW, bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), ivd_Error, log_FUNC_m, log_MARKLINE_m, and m_scsiIO_p.

00095                            {
00096     log_FUNC_m(Erase);
00097 
00098     InvalidateSizes();
00099     try {
00100         cdb_Erase erase;
00101         m_scsiIO_p->IOCtl(erase);
00102     }
00103     catch(const ivd_Error &ie) {
00104         if (ie.GetError() == ie_MEDIUM_OVERFLOW) {
00105             log_MARKLINE_m;
00106             throw ivd_Error(ie_MEDIUM_MEDERR, "Volume overflow on erase.", true);
00107         }
00108         else {
00109             throw;
00110         }
00111     }
00112 
00113     InvalidateEOD();
00114 }

Here is the call graph for this function:

void bea_TapeVolume::WriteFileMarks ( UInt32_t  a_count = 1  )  [virtual]

Implements bea_Volume.

Definition at line 118 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), ie_SCSI_EOM, bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_A_m, log_WriteEvent(), bea_Volume::m_atEOD, bea_Volume::m_medium_p, and m_scsiIO_p.

Referenced by Flush().

00118                                                     {
00119     log_FUNC_A_m(WriteFileMarks, "count: " << a_count);
00120 
00121     if (DoMediumLogging()) {
00122         ostringstream sstr;
00123         sstr << "Vol " << GetVolumeNumber()
00124             << ": Writing filemark(s) "<< a_count << "...";
00125 
00126         log_WriteEvent(
00127             sstr.str(), "",
00128             GetJobID(),
00129             m_medium_p->GetBarcode());
00130     }
00131 
00132     InvalidateSizes();
00133 
00134     cdb_WriteFileMarks  fm(a_count);
00135     try {
00136         m_scsiIO_p->IOCtl(fm);
00137     }
00138     catch (const ivd_Error& ie) {
00139         if (ie.GetError() == ie_SCSI_EOM) {
00140             // File mark was written successfully.
00141             log_DBG_m(dbg_NORM,
00142                 "Ignored early EOM when writing file marks.");
00143         }
00144         else {
00145             throw;
00146         }
00147     }
00148 
00149     if (a_count > 0) {
00150         m_atEOD = true;
00151     }
00152 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_TapeVolume::Flush (  )  [virtual]

Implements bea_Volume.

Definition at line 156 of file bea_tapevolume.cpp.

References log_FUNC_m, and WriteFileMarks().

00156                            {
00157     log_FUNC_m(Flush);
00158     bea_TapeVolume::WriteFileMarks(0);
00159 }

Here is the call graph for this function:

void bea_TapeVolume::SeekEOD (  )  [virtual]

Implements bea_Volume.

Definition at line 163 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), GetPosition(), bea_Volume::GetVolumeNumber(), ie_SCSI_EOM, ie_SCSI_NOT_READY, scsi_IO::IOCtl(), log_DBG_m, log_FUNC_m, log_WriteEvent(), bea_Volume::m_atEOD, bea_Volume::m_medium_p, m_scsiIO_p, spaceEndOfData, and scsi_IO::WaitToBecomeReady().

Referenced by ReadEstimSizes().

00163                              {
00164     log_FUNC_m(SeekEOD);
00165     cdb_Space  eod(spaceEndOfData, 0);
00166 
00167     if (DoMediumLogging()) {
00168         ostringstream sstr;
00169         sstr << "Vol " << GetVolumeNumber()
00170             << ": Seeking to EOD...";
00171 
00172         log_WriteEvent(
00173             sstr.str(), "",
00174             GetJobID(),
00175             m_medium_p->GetBarcode());
00176     }
00177 
00178     try {
00179         m_scsiIO_p->IOCtl(eod);
00180     }
00181     catch (ivd_Error &ie) {
00182         if (ie.GetError() == ie_SCSI_NOT_READY) {
00183             m_scsiIO_p->WaitToBecomeReady();
00184             m_scsiIO_p->IOCtl(eod);
00185         }
00186         else if (ie.GetError() == ie_SCSI_EOM) {
00187             log_DBG_m(dbg_NORM,
00188                 "Ignored early EOM when seeking to EOD.");
00189         }
00190         else {
00191             throw;
00192         }
00193     }
00194     m_atEOD = true;
00195 
00196     if (DoMediumLogging()) {
00197         ostringstream sstr;
00198         sstr << "Vol " << GetVolumeNumber()
00199             << ": At EOD (" << GetPosition() << ")";
00200 
00201         log_WriteEvent(
00202             sstr.str(), "",
00203             GetJobID(),
00204             m_medium_p->GetBarcode());
00205     }
00206 }

Here is the call graph for this function:

Here is the caller graph for this function:

void bea_TapeVolume::Rewind (  )  [virtual]

Implements bea_Volume.

Definition at line 250 of file bea_tapevolume.cpp.

References bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), ie_SCSI_NOT_READY, bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_FUNC_m, log_WriteEvent(), bea_Volume::m_medium_p, m_scsiIO_p, and scsi_IO::WaitToBecomeReady().

00250                             {
00251     log_FUNC_m(Rewind);
00252 
00253     if (DoMediumLogging()) {
00254         ostringstream sstr;
00255         sstr << "Vol " << GetVolumeNumber()
00256             << ": Rewind...";
00257 
00258         log_WriteEvent(
00259             sstr.str(), "",
00260             GetJobID(),
00261             m_medium_p->GetBarcode());
00262     }
00263 
00264     InvalidateSizes();
00265     InvalidateEOD();
00266 
00267     cdb_Rewind rewind;
00268 
00269     try {
00270         m_scsiIO_p->IOCtl(rewind);
00271     }
00272     catch (ivd_Error &ie) {
00273         if (ie.GetError() == ie_SCSI_NOT_READY) {
00274             m_scsiIO_p->WaitToBecomeReady();
00275             m_scsiIO_p->IOCtl(rewind);
00276         }
00277         else {
00278             throw;
00279         }
00280     }
00281 }

Here is the call graph for this function:

void bea_TapeVolume::SeekBlock ( UInt32_t  a_block  )  [virtual]

Implements bea_Volume.

Definition at line 210 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), ie_SCSI_EOM, ie_SCSI_NOT_READY, bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_A_m, log_WriteEvent(), bea_Volume::m_medium_p, m_scsiIO_p, cdb_Locate::SetBlockNum(), and scsi_IO::WaitToBecomeReady().

00210                                                {
00211     log_FUNC_A_m(SeekBlock, " blk: " << a_block);
00212 
00213     if (DoMediumLogging()) {
00214         ostringstream sstr;
00215         sstr << "Vol " << GetVolumeNumber()
00216             << ": Seeking to "<< a_block << "...";
00217 
00218         log_WriteEvent(
00219             sstr.str(), "",
00220             GetJobID(),
00221             m_medium_p->GetBarcode());
00222     }
00223 
00224     InvalidateSizes();
00225     InvalidateEOD();
00226 
00227     cdb_Locate  pos;
00228 
00229     pos.SetBlockNum(a_block);
00230     try {
00231         m_scsiIO_p->IOCtl(pos);
00232     }
00233     catch (ivd_Error &ie) {
00234         if (ie.GetError() == ie_SCSI_NOT_READY) {
00235             m_scsiIO_p->WaitToBecomeReady();
00236             m_scsiIO_p->IOCtl(pos);
00237         }
00238         else if (ie.GetError() == ie_SCSI_EOM) {
00239             log_DBG_m(dbg_NORM,
00240                 "Ignored early EOM when seeking to position.");
00241         }
00242         else {
00243             throw;
00244         }
00245     }
00246 }

Here is the call graph for this function:

void bea_TapeVolume::SeekFileMark ( Int32_t  a_relativeFM  )  [virtual]

Implements bea_Volume.

Definition at line 285 of file bea_tapevolume.cpp.

References dbg_NORM, bea_Volume::DoMediumLogging(), bea_Medium::GetBarcode(), ivd_BaseException::GetError(), bea_Volume::GetJobID(), bea_Volume::GetVolumeNumber(), ie_SCSI_EOM, bea_Volume::InvalidateEOD(), bea_Volume::InvalidateSizes(), scsi_IO::IOCtl(), log_DBG_m, log_FUNC_A_m, log_WriteEvent(), bea_Volume::m_medium_p, m_scsiIO_p, and spaceFileMarks.

00285                                                       {
00286     log_FUNC_A_m(SeekFileMark, "relativeFM: " << a_relativeFM);
00287 
00288     if (DoMediumLogging()) {
00289         ostringstream sstr;
00290         if (a_relativeFM > 0) {
00291             sstr
00292                 << "Vol " << GetVolumeNumber()
00293                 << ": Seeking " << a_relativeFM << " filemark(s) forward...";
00294         }
00295         else {
00296             sstr
00297                 << "Vol " << GetVolumeNumber()
00298                 << ": Seeking " << -a_relativeFM << " filemark(s) back...";
00299         }
00300 
00301         log_WriteEvent(
00302             sstr.str(), "",
00303             GetJobID(),
00304             m_medium_p->GetBarcode());
00305     }
00306 
00307     InvalidateSizes();
00308     InvalidateEOD();
00309 
00310     cdb_Space fm(spaceFileMarks, a_relativeFM);
00311     try {
00312         m_scsiIO_p->IOCtl(fm);
00313     }
00314     catch(const ivd_Error& ie) {
00315         if (ie.GetError() == ie_SCSI_EOM) {
00316             log_DBG_m(dbg_NORM,
00317                       "Ignored early EOM when seeking to file mark.");
00318         }
00319         else {
00320             throw;
00321         }
00322     }
00323 }

Here is the call graph for this function:

void bea_TapeVolume::WriteRaw ( const UInt8_t a_buf,
UInt32_t  a_size 
) [protected, virtual]

Implements bea_Volume.

Definition at line 79 of file bea_tapevolume.cpp.

References scsi_IO::IOCtl(), m_scsiIO_p, and cdb_Write::SetBuffer().

00079                                                                    {
00080     cdb_Write   write;
00081     write.SetBuffer(a_buf, a_size);
00082     m_scsiIO_p->IOCtl(write);
00083 }

Here is the call graph for this function:

void bea_TapeVolume::ReadRaw ( UInt8_t a_buf,
UInt32_t  a_size 
) [protected, virtual]

Implements bea_Volume.

Definition at line 87 of file bea_tapevolume.cpp.

References scsi_IO::IOCtl(), m_scsiIO_p, and cdb_Read::SetBuffer().

00087                                                             {
00088     cdb_Read   read;
00089     read.SetBuffer(a_buf, a_size);
00090     m_scsiIO_p->IOCtl(read);
00091 }

Here is the call graph for this function:

void bea_TapeVolume::ReadEstimSizes (  )  [protected, virtual]

Reads estimated overall and remaining capacity of this medium volume.

It stores the values so that they can be retrieved by Get* methods. This method converts sizes to MB.

Implements bea_Volume.

Definition at line 333 of file bea_tapevolume.cpp.

References bmf_LTO, dbg_NORM, bea_Medium::GetCurVolNumber(), bea_Medium::GetMediumFamily(), data_Log::GetRemainingPartCap(), data_Log::GetTotalPartCap(), bea_Volume::GetVolumeNumber(), ie_INVALID_ARG, scsi_IO::IOCtl(), ivd_Error, log_DBG_m, log_FUNC_m, bea_Volume::m_atEOD, bea_Volume::m_medium_p, m_scsiIO_p, data_Log::pg_TAPECAP, SeekEOD(), and bea_Volume::SetEstimatedSizes().

00333                                     {
00334     log_FUNC_m(ReadEstimSizes);
00335 
00336     if (m_medium_p->GetCurVolNumber() != GetVolumeNumber()) {
00337         throw ivd_Error(
00338             ie_INVALID_ARG,
00339             "Estimated sizes can only be read for current volume.");
00340     };
00341 
00342     if (!m_atEOD) {
00343         SeekEOD();
00344     }
00345 
00346     data_Log        tapeCap(data_Log::pg_TAPECAP);
00347     cdb_LogSense    logSense(tapeCap);
00348 
00349     m_scsiIO_p->IOCtl(logSense);
00350 
00351     UInt32_t estimSize = tapeCap.GetTotalPartCap(UInt8_t(GetVolumeNumber())-1);
00352     UInt32_t estimFree = tapeCap.GetRemainingPartCap(UInt8_t(GetVolumeNumber())-1);
00353 
00354     if (m_medium_p->GetMediumFamily() != bmf_LTO) {
00355         // LTO reports capacity in MB, whereas other report in
00356         // kB. Conversion is necessary to convert the values to MB.
00357         estimSize /= 1024;
00358         estimFree /= 1024;
00359     };
00360 
00361     log_DBG_m(dbg_NORM,
00362         "Estimated capacity info [MB]:" << endl <<
00363         "total: " << estimSize << endl <<
00364         "free : " << estimFree << endl);
00365 
00366     SetEstimatedSizes(estimSize, estimFree);
00367 }

Here is the call graph for this function:


Member Data Documentation

Reimplemented from bea_Volume.

Definition at line 61 of file bea_tapevolume.h.


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

Generated on Mon Feb 27 19:01:13 2012 for OPENARCHIVE by  doxygen 1.5.6