#include <Utilities/StorageFactory/interface/StorageAccountProxy.h>
Public Member Functions | |
virtual void | close (void) |
virtual void | flush (void) |
virtual IOOffset | position (IOOffset offset, Relative whence=SET) |
virtual bool | prefetch (const IOPosBuffer *what, IOSize n) |
virtual IOSize | read (void *into, IOSize n, IOOffset pos) |
virtual IOSize | read (void *into, IOSize n) |
Read into into at most n number of bytes. | |
virtual IOSize | readv (IOPosBuffer *into, IOSize n) |
virtual IOSize | readv (IOBuffer *into, IOSize n) |
Read from the input stream into multiple scattered buffers. | |
virtual void | resize (IOOffset size) |
StorageAccountProxy (const std::string &storageClass, Storage *baseStorage) | |
virtual IOSize | write (const void *from, IOSize n, IOOffset pos) |
virtual IOSize | write (const void *from, IOSize n) |
Write n bytes of data starting at address from. | |
virtual IOSize | writev (const IOPosBuffer *from, IOSize n) |
virtual IOSize | writev (const IOBuffer *from, IOSize n) |
Write to the output stream from multiple buffers. | |
~StorageAccountProxy (void) | |
Protected Attributes | |
Storage * | m_baseStorage |
StorageAccount::Counter & | m_statsPosition |
StorageAccount::Counter & | m_statsPrefetch |
StorageAccount::Counter & | m_statsRead |
StorageAccount::Counter & | m_statsReadV |
StorageAccount::Counter & | m_statsWrite |
StorageAccount::Counter & | m_statsWriteV |
std::string | m_storageClass |
The returned Storage objects from StorageMaker are automatically wrapped with this class.
Future improvement would be to implement more methods so that the wrapper itself doesn't cause peroformance degradation if the base storage does actually implement "sophisticated" features.
Definition at line 16 of file StorageAccountProxy.h.
StorageAccountProxy::StorageAccountProxy | ( | const std::string & | storageClass, | |
Storage * | baseStorage | |||
) |
Definition at line 3 of file StorageAccountProxy.cc.
References StorageAccount::counter(), m_storageClass, and StorageAccount::Stamp::tick().
00005 : m_storageClass (storageClass), 00006 m_baseStorage (baseStorage), 00007 m_statsRead (StorageAccount::counter (m_storageClass, "read")), 00008 m_statsReadV (StorageAccount::counter (m_storageClass, "readv")), 00009 m_statsWrite (StorageAccount::counter (m_storageClass, "write")), 00010 m_statsWriteV (StorageAccount::counter (m_storageClass, "writev")), 00011 m_statsPosition (StorageAccount::counter (m_storageClass, "position")), 00012 m_statsPrefetch (StorageAccount::counter (m_storageClass, "prefetch")) 00013 { 00014 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "construct")); 00015 stats.tick (); 00016 }
StorageAccountProxy::~StorageAccountProxy | ( | void | ) |
Definition at line 18 of file StorageAccountProxy.cc.
References StorageAccount::counter(), m_baseStorage, m_storageClass, and StorageAccount::Stamp::tick().
00019 { 00020 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "destruct")); 00021 delete m_baseStorage; 00022 stats.tick (); 00023 }
Reimplemented from Storage.
Definition at line 123 of file StorageAccountProxy.cc.
References Storage::close(), StorageAccount::counter(), m_baseStorage, m_storageClass, and StorageAccount::Stamp::tick().
00124 { 00125 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "close")); 00126 m_baseStorage->close (); 00127 stats.tick (); 00128 }
Reimplemented from Storage.
Definition at line 115 of file StorageAccountProxy.cc.
References StorageAccount::counter(), Storage::flush(), m_baseStorage, m_storageClass, and StorageAccount::Stamp::tick().
00116 { 00117 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "flush")); 00118 m_baseStorage->flush (); 00119 stats.tick (); 00120 }
Implements Storage.
Definition at line 98 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsPosition, Storage::position(), HLT_VtxMuL3::result, and StorageAccount::Stamp::tick().
00099 { 00100 StorageAccount::Stamp stats (m_statsPosition); 00101 IOOffset result = m_baseStorage->position (offset, whence); 00102 stats.tick (); 00103 return result; 00104 }
bool StorageAccountProxy::prefetch | ( | const IOPosBuffer * | what, | |
IOSize | n | |||
) | [virtual] |
Reimplemented from Storage.
Definition at line 131 of file StorageAccountProxy.cc.
References i, m_baseStorage, m_statsPrefetch, Storage::prefetch(), Storage::size(), StorageAccount::Stamp::tick(), and value.
00132 { 00133 StorageAccount::Stamp stats (m_statsPrefetch); 00134 bool value = m_baseStorage->prefetch(what, n); 00135 if (value) 00136 { 00137 IOSize total = 0; 00138 for (IOSize i = 0; i < n; ++i) 00139 total += what[i].size(); 00140 stats.tick (total); 00141 } 00142 return value; 00143 }
Reimplemented from Storage.
Definition at line 35 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsRead, Storage::read(), HLT_VtxMuL3::result, and StorageAccount::Stamp::tick().
00036 { 00037 StorageAccount::Stamp stats (m_statsRead); 00038 IOSize result = m_baseStorage->read (into, n, pos); 00039 stats.tick (result); 00040 return result; 00041 }
Read into into at most n number of bytes.
If this is a blocking stream, the call will block until some data can be read, end of input is reached, or an exception is thrown. For a non-blocking stream the available input is returned. If none is available, an exception is thrown.
In | case of error, a IOError exception is thrown. This includes the situation where the input stream is in non-blocking mode and no input is currently available (FIXME: make this simpler; clarify which exception). |
Implements IOInput.
Definition at line 26 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsRead, Storage::read(), HLT_VtxMuL3::result, and StorageAccount::Stamp::tick().
00027 { 00028 StorageAccount::Stamp stats (m_statsRead); 00029 IOSize result = m_baseStorage->read (into, n); 00030 stats.tick (result); 00031 return result; 00032 }
IOSize StorageAccountProxy::readv | ( | IOPosBuffer * | into, | |
IOSize | n | |||
) | [virtual] |
Reimplemented from Storage.
Definition at line 53 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsReadV, Storage::readv(), HLT_VtxMuL3::result, and StorageAccount::Stamp::tick().
00054 { 00055 StorageAccount::Stamp stats (m_statsReadV); 00056 IOSize result = m_baseStorage->readv (into, n); 00057 stats.tick (result); 00058 return result; 00059 }
Read from the input stream into multiple scattered buffers.
There are buffers to fill in an array starting at into; the memory those buffers occupy does not need to be contiguous. The buffers are filled in the order given, eac buffer is filled fully before the subsequent buffers.
If this is a blocking stream, the call will block until some data can be read, end of input is reached, or an exception is thrown. For a non-blocking stream the available input is returned. If none is available, an exception is thrown.
The base class implementation uses read(void *, IOSize) method, but derived classes may implement a more efficient alternative.
In | case of error, a IOError exception is thrown. However if some data has already been read, the error is swallowed and the method returns the data read so far. It is assumed that persistent errors will occur anyway on the next read and sporadic errors like stream becoming unvailable can be ignored. Use xread() if a different policy is desirable. |
Reimplemented from IOInput.
Definition at line 44 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsReadV, Storage::readv(), HLT_VtxMuL3::result, and StorageAccount::Stamp::tick().
00045 { 00046 StorageAccount::Stamp stats (m_statsReadV); 00047 IOSize result = m_baseStorage->readv (into, n); 00048 stats.tick (result); 00049 return result; 00050 }
Implements Storage.
Definition at line 107 of file StorageAccountProxy.cc.
References StorageAccount::counter(), m_baseStorage, m_storageClass, Storage::resize(), and StorageAccount::Stamp::tick().
00108 { 00109 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "resize")); 00110 m_baseStorage->resize (size); 00111 stats.tick (); 00112 }
Reimplemented from Storage.
Definition at line 71 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsWrite, HLT_VtxMuL3::result, StorageAccount::Stamp::tick(), and Storage::write().
00072 { 00073 StorageAccount::Stamp stats (m_statsWrite); 00074 IOSize result = m_baseStorage->write (from, n, pos); 00075 stats.tick (result); 00076 return result; 00077 }
Write n bytes of data starting at address from.
In | case of error, an exception is thrown. However if the stream is in non-blocking mode and cannot accept output, it will not throw an exception -- the return value will be less than requested. |
Implements IOOutput.
Definition at line 62 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsWrite, HLT_VtxMuL3::result, StorageAccount::Stamp::tick(), and Storage::write().
00063 { 00064 StorageAccount::Stamp stats (m_statsWrite); 00065 IOSize result = m_baseStorage->write (from, n); 00066 stats.tick (result); 00067 return result; 00068 }
IOSize StorageAccountProxy::writev | ( | const IOPosBuffer * | from, | |
IOSize | n | |||
) | [virtual] |
Reimplemented from Storage.
Definition at line 89 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsWriteV, HLT_VtxMuL3::result, StorageAccount::Stamp::tick(), and Storage::writev().
00090 { 00091 StorageAccount::Stamp stats (m_statsWriteV); 00092 IOSize result = m_baseStorage->writev (from, n); 00093 stats.tick (result); 00094 return result; 00095 }
Write to the output stream from multiple buffers.
There are buffers to fill in an array starting at from. The buffers are filled in the order given, each buffer fully before the subsequent buffers. The method uses write(const void *, IOSize), but may be implemented more efficiently in derived classes.
Note that derived classes should not normally call this method, as it simply routes the call back to derived class through the other virtual functions. Use this method only at the "outside edge" when transferring calls from one object to another, not in up/down calls in the inheritance tree.
In | case of error, an exception is thrown. However if the stream is in non-blocking mode and cannot accept output, it will not throw an exception -- the return value will be less than requested. |
Reimplemented from IOOutput.
Definition at line 80 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsWriteV, HLT_VtxMuL3::result, StorageAccount::Stamp::tick(), and Storage::writev().
00081 { 00082 StorageAccount::Stamp stats (m_statsWriteV); 00083 IOSize result = m_baseStorage->writev (from, n); 00084 stats.tick (result); 00085 return result; 00086 }
Storage* StorageAccountProxy::m_baseStorage [protected] |
Definition at line 42 of file StorageAccountProxy.h.
Referenced by close(), flush(), position(), prefetch(), read(), readv(), resize(), write(), writev(), and ~StorageAccountProxy().
StorageAccount::Counter& StorageAccountProxy::m_statsRead [protected] |
StorageAccount::Counter& StorageAccountProxy::m_statsReadV [protected] |
StorageAccount::Counter& StorageAccountProxy::m_statsWrite [protected] |
std::string StorageAccountProxy::m_storageClass [protected] |
Definition at line 41 of file StorageAccountProxy.h.
Referenced by close(), flush(), resize(), StorageAccountProxy(), and ~StorageAccountProxy().