00001 #include "Utilities/StorageFactory/interface/StorageAccountProxy.h" 00002 00003 StorageAccountProxy::StorageAccountProxy (const std::string &storageClass, 00004 Storage *baseStorage) 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 } 00017 00018 StorageAccountProxy::~StorageAccountProxy (void) 00019 { 00020 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "destruct")); 00021 delete m_baseStorage; 00022 stats.tick (); 00023 } 00024 00025 IOSize 00026 StorageAccountProxy::read (void *into, IOSize n) 00027 { 00028 StorageAccount::Stamp stats (m_statsRead); 00029 IOSize result = m_baseStorage->read (into, n); 00030 stats.tick (result); 00031 return result; 00032 } 00033 00034 IOSize 00035 StorageAccountProxy::read (void *into, IOSize n, IOOffset pos) 00036 { 00037 StorageAccount::Stamp stats (m_statsRead); 00038 IOSize result = m_baseStorage->read (into, n, pos); 00039 stats.tick (result); 00040 return result; 00041 } 00042 00043 IOSize 00044 StorageAccountProxy::readv (IOBuffer *into, IOSize n) 00045 { 00046 StorageAccount::Stamp stats (m_statsReadV); 00047 IOSize result = m_baseStorage->readv (into, n); 00048 stats.tick (result); 00049 return result; 00050 } 00051 00052 IOSize 00053 StorageAccountProxy::readv (IOPosBuffer *into, IOSize n) 00054 { 00055 StorageAccount::Stamp stats (m_statsReadV); 00056 IOSize result = m_baseStorage->readv (into, n); 00057 stats.tick (result); 00058 return result; 00059 } 00060 00061 IOSize 00062 StorageAccountProxy::write (const void *from, IOSize n) 00063 { 00064 StorageAccount::Stamp stats (m_statsWrite); 00065 IOSize result = m_baseStorage->write (from, n); 00066 stats.tick (result); 00067 return result; 00068 } 00069 00070 IOSize 00071 StorageAccountProxy::write (const void *from, IOSize n, IOOffset pos) 00072 { 00073 StorageAccount::Stamp stats (m_statsWrite); 00074 IOSize result = m_baseStorage->write (from, n, pos); 00075 stats.tick (result); 00076 return result; 00077 } 00078 00079 IOSize 00080 StorageAccountProxy::writev (const IOBuffer *from, IOSize n) 00081 { 00082 StorageAccount::Stamp stats (m_statsWriteV); 00083 IOSize result = m_baseStorage->writev (from, n); 00084 stats.tick (result); 00085 return result; 00086 } 00087 00088 IOSize 00089 StorageAccountProxy::writev (const IOPosBuffer *from, IOSize n) 00090 { 00091 StorageAccount::Stamp stats (m_statsWriteV); 00092 IOSize result = m_baseStorage->writev (from, n); 00093 stats.tick (result); 00094 return result; 00095 } 00096 00097 IOOffset 00098 StorageAccountProxy::position (IOOffset offset, Relative whence) 00099 { 00100 StorageAccount::Stamp stats (m_statsPosition); 00101 IOOffset result = m_baseStorage->position (offset, whence); 00102 stats.tick (); 00103 return result; 00104 } 00105 00106 void 00107 StorageAccountProxy::resize (IOOffset size) 00108 { 00109 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "resize")); 00110 m_baseStorage->resize (size); 00111 stats.tick (); 00112 } 00113 00114 void 00115 StorageAccountProxy::flush (void) 00116 { 00117 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "flush")); 00118 m_baseStorage->flush (); 00119 stats.tick (); 00120 } 00121 00122 void 00123 StorageAccountProxy::close (void) 00124 { 00125 StorageAccount::Stamp stats (StorageAccount::counter (m_storageClass, "close")); 00126 m_baseStorage->close (); 00127 stats.tick (); 00128 } 00129 00130 bool 00131 StorageAccountProxy::prefetch (const IOPosBuffer *what, IOSize n) 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 }