File indexing completed on 2024-04-06 12:31:52
0001 #include "Utilities/StorageFactory/interface/StorageAccountProxy.h"
0002 using namespace edm::storage;
0003
0004 StorageAccountProxy::StorageAccountProxy(const std::string &storageClass, std::unique_ptr<Storage> baseStorage)
0005 : m_baseStorage(std::move(baseStorage)),
0006 m_token(StorageAccount::tokenForStorageClassName(storageClass)),
0007 m_statsRead(StorageAccount::counter(m_token, StorageAccount::Operation::read)),
0008 m_statsReadV(StorageAccount::counter(m_token, StorageAccount::Operation::readv)),
0009 m_statsWrite(StorageAccount::counter(m_token, StorageAccount::Operation::write)),
0010 m_statsWriteV(StorageAccount::counter(m_token, StorageAccount::Operation::writev)),
0011 m_statsPosition(StorageAccount::counter(m_token, StorageAccount::Operation::position)),
0012 m_statsPrefetch(StorageAccount::counter(m_token, StorageAccount::Operation::prefetch)) {
0013 StorageAccount::Stamp stats(StorageAccount::counter(m_token, StorageAccount::Operation::construct));
0014 stats.tick();
0015 }
0016
0017 StorageAccountProxy::~StorageAccountProxy() {
0018 StorageAccount::Stamp stats(StorageAccount::counter(m_token, StorageAccount::Operation::destruct));
0019 releaseStorage();
0020 stats.tick();
0021 }
0022
0023 IOSize StorageAccountProxy::read(void *into, IOSize n) {
0024 StorageAccount::Stamp stats(m_statsRead);
0025 IOSize result = m_baseStorage->read(into, n);
0026 stats.tick(result);
0027 return result;
0028 }
0029
0030 IOSize StorageAccountProxy::read(void *into, IOSize n, IOOffset pos) {
0031 StorageAccount::Stamp stats(m_statsRead);
0032 IOSize result = m_baseStorage->read(into, n, pos);
0033 stats.tick(result);
0034 return result;
0035 }
0036
0037 IOSize StorageAccountProxy::readv(IOBuffer *into, IOSize n) {
0038 StorageAccount::Stamp stats(m_statsReadV);
0039 IOSize result = m_baseStorage->readv(into, n);
0040 stats.tick(result, n);
0041 return result;
0042 }
0043
0044 IOSize StorageAccountProxy::readv(IOPosBuffer *into, IOSize n) {
0045 StorageAccount::Stamp stats(m_statsReadV);
0046 IOSize result = m_baseStorage->readv(into, n);
0047 stats.tick(result, n);
0048 return result;
0049 }
0050
0051 IOSize StorageAccountProxy::write(const void *from, IOSize n) {
0052 StorageAccount::Stamp stats(m_statsWrite);
0053 IOSize result = m_baseStorage->write(from, n);
0054 stats.tick(result);
0055 return result;
0056 }
0057
0058 IOSize StorageAccountProxy::write(const void *from, IOSize n, IOOffset pos) {
0059 StorageAccount::Stamp stats(m_statsWrite);
0060 IOSize result = m_baseStorage->write(from, n, pos);
0061 stats.tick(result);
0062 return result;
0063 }
0064
0065 IOSize StorageAccountProxy::writev(const IOBuffer *from, IOSize n) {
0066 StorageAccount::Stamp stats(m_statsWriteV);
0067 IOSize result = m_baseStorage->writev(from, n);
0068 stats.tick(result, n);
0069 return result;
0070 }
0071
0072 IOSize StorageAccountProxy::writev(const IOPosBuffer *from, IOSize n) {
0073 StorageAccount::Stamp stats(m_statsWriteV);
0074 IOSize result = m_baseStorage->writev(from, n);
0075 stats.tick(result, n);
0076 return result;
0077 }
0078
0079 IOOffset StorageAccountProxy::position(IOOffset offset, Relative whence) {
0080 StorageAccount::Stamp stats(m_statsPosition);
0081 IOOffset result = m_baseStorage->position(offset, whence);
0082 stats.tick();
0083 return result;
0084 }
0085
0086 void StorageAccountProxy::resize(IOOffset size) {
0087 StorageAccount::Stamp stats(StorageAccount::counter(m_token, StorageAccount::Operation::resize));
0088 m_baseStorage->resize(size);
0089 stats.tick();
0090 }
0091
0092 void StorageAccountProxy::flush() {
0093 StorageAccount::Stamp stats(StorageAccount::counter(m_token, StorageAccount::Operation::flush));
0094 m_baseStorage->flush();
0095 stats.tick();
0096 }
0097
0098 void StorageAccountProxy::close() {
0099 StorageAccount::Stamp stats(StorageAccount::counter(m_token, StorageAccount::Operation::close));
0100 m_baseStorage->close();
0101 stats.tick();
0102 }
0103
0104 bool StorageAccountProxy::prefetch(const IOPosBuffer *what, IOSize n) {
0105 StorageAccount::Stamp stats(m_statsPrefetch);
0106 bool value = m_baseStorage->prefetch(what, n);
0107 if (value) {
0108 IOSize total = 0;
0109 for (IOSize i = 0; i < n; ++i)
0110 total += what[i].size();
0111 stats.tick(total);
0112 }
0113 return value;
0114 }