#include <StorageAccountProxy.h>
Proxy class that wraps SEAL's Storage class with one that ticks StorageAccount counters for significant operations. 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().
: m_storageClass (storageClass), m_baseStorage (baseStorage), m_statsRead (StorageAccount::counter (m_storageClass, "read")), m_statsReadV (StorageAccount::counter (m_storageClass, "readv")), m_statsWrite (StorageAccount::counter (m_storageClass, "write")), m_statsWriteV (StorageAccount::counter (m_storageClass, "writev")), m_statsPosition (StorageAccount::counter (m_storageClass, "position")), m_statsPrefetch (StorageAccount::counter (m_storageClass, "prefetch")) { StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "construct")); stats.tick (); }
StorageAccountProxy::~StorageAccountProxy | ( | void | ) |
Definition at line 18 of file StorageAccountProxy.cc.
References StorageAccount::counter(), m_baseStorage, m_storageClass, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "destruct")); delete m_baseStorage; stats.tick (); }
void StorageAccountProxy::close | ( | void | ) | [virtual] |
Reimplemented from Storage.
Definition at line 123 of file StorageAccountProxy.cc.
References Storage::close(), StorageAccount::counter(), m_baseStorage, m_storageClass, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "close")); m_baseStorage->close (); stats.tick (); }
void StorageAccountProxy::flush | ( | void | ) | [virtual] |
Reimplemented from Storage.
Definition at line 115 of file StorageAccountProxy.cc.
References StorageAccount::counter(), Storage::flush(), m_baseStorage, m_storageClass, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "flush")); m_baseStorage->flush (); stats.tick (); }
Implements Storage.
Definition at line 98 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsPosition, Storage::position(), query::result, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (m_statsPosition); IOOffset result = m_baseStorage->position (offset, whence); stats.tick (); return result; }
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, n, Storage::prefetch(), Storage::size(), StorageAccount::Stamp::tick(), pileupDistInMC::total, and relativeConstraints::value.
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(), query::result, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (m_statsRead); IOSize result = m_baseStorage->read (into, n); stats.tick (result); return result; }
Reimplemented from Storage.
Definition at line 35 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsRead, Storage::read(), query::result, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (m_statsRead); IOSize result = m_baseStorage->read (into, n, pos); stats.tick (result); return result; }
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(), query::result, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (m_statsReadV); IOSize result = m_baseStorage->readv (into, n); stats.tick (result, n); return result; }
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(), query::result, and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (m_statsReadV); IOSize result = m_baseStorage->readv (into, n); stats.tick (result, n); return result; }
void StorageAccountProxy::resize | ( | IOOffset | size | ) | [virtual] |
Implements Storage.
Definition at line 107 of file StorageAccountProxy.cc.
References StorageAccount::counter(), m_baseStorage, m_storageClass, Storage::resize(), and StorageAccount::Stamp::tick().
{ StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "resize")); m_baseStorage->resize (size); stats.tick (); }
Reimplemented from Storage.
Definition at line 71 of file StorageAccountProxy.cc.
References m_baseStorage, m_statsWrite, query::result, StorageAccount::Stamp::tick(), and Storage::write().
{ StorageAccount::Stamp stats (m_statsWrite); IOSize result = m_baseStorage->write (from, n, pos); stats.tick (result); return result; }
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, query::result, StorageAccount::Stamp::tick(), and Storage::write().
{ StorageAccount::Stamp stats (m_statsWrite); IOSize result = m_baseStorage->write (from, n); stats.tick (result); return result; }
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, query::result, StorageAccount::Stamp::tick(), and Storage::writev().
{ StorageAccount::Stamp stats (m_statsWriteV); IOSize result = m_baseStorage->writev (from, n); stats.tick (result, n); return result; }
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, query::result, StorageAccount::Stamp::tick(), and Storage::writev().
{ StorageAccount::Stamp stats (m_statsWriteV); IOSize result = m_baseStorage->writev (from, n); stats.tick (result, n); return result; }
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().
Definition at line 48 of file StorageAccountProxy.h.
Referenced by position().
Definition at line 49 of file StorageAccountProxy.h.
Referenced by prefetch().
StorageAccount::Counter& StorageAccountProxy::m_statsRead [protected] |
Definition at line 44 of file StorageAccountProxy.h.
Referenced by read().
StorageAccount::Counter& StorageAccountProxy::m_statsReadV [protected] |
Definition at line 45 of file StorageAccountProxy.h.
Referenced by readv().
StorageAccount::Counter& StorageAccountProxy::m_statsWrite [protected] |
Definition at line 46 of file StorageAccountProxy.h.
Referenced by write().
Definition at line 47 of file StorageAccountProxy.h.
Referenced by writev().
std::string StorageAccountProxy::m_storageClass [protected] |
Definition at line 41 of file StorageAccountProxy.h.
Referenced by close(), flush(), resize(), StorageAccountProxy(), and ~StorageAccountProxy().