CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
StorageAccountProxy Class Reference

#include <StorageAccountProxy.h>

Inheritance diagram for StorageAccountProxy:
Storage IOInput IOOutput

Public Member Functions

void close (void) override
 
void flush (void) override
 
IOOffset position (IOOffset offset, Relative whence=SET) override
 
bool prefetch (const IOPosBuffer *what, IOSize n) override
 
IOSize read (IOBuffer into)
 
IOSize read (IOBuffer into, IOOffset pos)
 
IOSize read (void *into, IOSize n) override
 
virtual IOSize read (void *into, IOSize n)=0
 
virtual IOSize read (void *into, IOSize n, IOOffset pos)
 
IOSize read (void *into, IOSize n, IOOffset pos) override
 
int read (void)
 
IOSize readv (IOBuffer *into, IOSize n) override
 
IOSize readv (IOPosBuffer *into, IOSize n) override
 
void resize (IOOffset size) override
 
 StorageAccountProxy (const std::string &storageClass, std::unique_ptr< Storage > baseStorage)
 
IOSize write (const void *from, IOSize n) override
 
virtual IOSize write (const void *from, IOSize n)=0
 
virtual IOSize write (const void *from, IOSize n, IOOffset pos)
 
IOSize write (const void *from, IOSize n, IOOffset pos) override
 
IOSize write (IOBuffer from)
 
IOSize write (IOBuffer from, IOOffset pos)
 
IOSize write (unsigned char byte)
 
IOSize writev (const IOBuffer *from, IOSize n) override
 
IOSize writev (const IOPosBuffer *from, IOSize n) override
 
 ~StorageAccountProxy (void) override
 
- Public Member Functions inherited from Storage
virtual bool eof (void) const
 
virtual IOOffset position (void) const
 
IOSize read (IOBuffer into)
 
IOSize read (IOBuffer into, IOOffset pos)
 
virtual IOSize read (void *into, IOSize n)=0
 
int read (void)
 
virtual IOSize readv (IOBuffer *into, IOSize buffers)
 
virtual void rewind (void)
 
virtual IOOffset size (void) const
 
 Storage (void)
 
virtual IOSize write (const void *from, IOSize n)=0
 
IOSize write (IOBuffer from)
 
IOSize write (IOBuffer from, IOOffset pos)
 
IOSize write (unsigned char byte)
 
virtual IOSize writev (const IOBuffer *from, IOSize buffers)
 
 ~Storage (void) override
 
- Public Member Functions inherited from IOInput
IOSize read (IOBuffer into)
 
int read (void)
 
IOSize xread (IOBuffer into)
 
IOSize xread (void *into, IOSize n)
 
IOSize xreadv (IOBuffer *into, IOSize buffers)
 
virtual ~IOInput (void)
 Destruct the stream. A no-op. More...
 
- Public Member Functions inherited from IOOutput
IOSize write (IOBuffer from)
 
IOSize write (unsigned char byte)
 
IOSize xwrite (const void *from, IOSize n)
 
IOSize xwrite (IOBuffer from)
 
IOSize xwritev (const IOBuffer *from, IOSize buffers)
 
virtual ~IOOutput (void)
 Destruct the stream. A no-op. More...
 

Protected Member Functions

void releaseStorage ()
 

Protected Attributes

edm::propagate_const< std::unique_ptr< Storage > > m_baseStorage
 
StorageAccount::Counterm_statsPosition
 
StorageAccount::Counterm_statsPrefetch
 
StorageAccount::Counterm_statsRead
 
StorageAccount::Counterm_statsReadV
 
StorageAccount::Counterm_statsWrite
 
StorageAccount::Counterm_statsWriteV
 
StorageAccount::StorageClassToken m_token
 

Additional Inherited Members

- Public Types inherited from Storage
enum  Relative { SET, CURRENT, END }
 

Detailed Description

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 18 of file StorageAccountProxy.h.

Constructor & Destructor Documentation

◆ StorageAccountProxy()

StorageAccountProxy::StorageAccountProxy ( const std::string &  storageClass,
std::unique_ptr< Storage baseStorage 
)

◆ ~StorageAccountProxy()

StorageAccountProxy::~StorageAccountProxy ( void  )
override

Member Function Documentation

◆ close()

void StorageAccountProxy::close ( void  )
overridevirtual

◆ flush()

void StorageAccountProxy::flush ( void  )
overridevirtual

◆ position()

IOOffset StorageAccountProxy::position ( IOOffset  offset,
Relative  whence = SET 
)
overridevirtual

Implements Storage.

Definition at line 78 of file StorageAccountProxy.cc.

78  {
80  IOOffset result = m_baseStorage->position(offset, whence);
81  stats.tick();
82  return result;
83 }

References m_baseStorage, m_statsPosition, hltrates_dqm_sourceclient-live_cfg::offset, mps_fire::result, and dqmMemoryStats::stats.

◆ prefetch()

bool StorageAccountProxy::prefetch ( const IOPosBuffer what,
IOSize  n 
)
overridevirtual

Reimplemented from Storage.

Definition at line 103 of file StorageAccountProxy.cc.

103  {
105  bool value = m_baseStorage->prefetch(what, n);
106  if (value) {
107  IOSize total = 0;
108  for (IOSize i = 0; i < n; ++i)
109  total += what[i].size();
110  stats.tick(total);
111  }
112  return value;
113 }

References mps_fire::i, m_baseStorage, m_statsPrefetch, dqmiodumpmetadata::n, Storage::size(), dqmMemoryStats::stats, dqmMemoryStats::total, and relativeConstraints::value.

◆ read() [1/7]

IOSize IOInput::read

Read from the input stream into the buffer starting at into and of size n.

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 simply forwards the call to read(void *, IOSize) method.

Returns
The number of bytes actually read. This is less or equal to the size of the buffer. Zero indicates that the end of the input has been reached: end of file, or remote end closing for a connected channel like a pipe or a socket. Otherwise the value can be less than requested if limited amount of input is currently available for platform or implementation reasons.
Exceptions
Incase 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).

Definition at line 80 of file IOInput.cc.

80 { return read(into.data(), into.size()); }

◆ read() [2/7]

IOSize Storage::read

Definition at line 10 of file Storage.cc.

10 { return read(into.data(), into.size(), pos); }

◆ read() [3/7]

IOSize StorageAccountProxy::read ( void *  into,
IOSize  n 
)
overridevirtual

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.

Returns
The number of bytes actually read. This is less or equal to the size of the buffer. Zero indicates that the end of the input has been reached: end of file, or remote end closing for a connected channel like a pipe or a socket. Otherwise the value can be less than requested if limited amount of input is currently available for platform or implementation reasons.
Exceptions
Incase 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 22 of file StorageAccountProxy.cc.

22  {
24  IOSize result = m_baseStorage->read(into, n);
25  stats.tick(result);
26  return result;
27 }

References m_baseStorage, m_statsRead, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

◆ read() [4/7]

IOSize IOInput::read

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.

Returns
The number of bytes actually read. This is less or equal to the size of the buffer. Zero indicates that the end of the input has been reached: end of file, or remote end closing for a connected channel like a pipe or a socket. Otherwise the value can be less than requested if limited amount of input is currently available for platform or implementation reasons.
Exceptions
Incase 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).

◆ read() [5/7]

IOSize Storage::read

Definition at line 12 of file Storage.cc.

12  {
13  // FIXME: this is not thread safe! split into separate interface
14  // that a particular storage can choose to support or not? make
15  // sure that throw semantics are correct here!
16  // FIXME: use saveposition object in case exceptions are thrown?
17  IOOffset here = position();
18  position(pos);
19  n = read(into, n);
20  position(here);
21  return n;
22 }

◆ read() [6/7]

IOSize StorageAccountProxy::read ( void *  into,
IOSize  n,
IOOffset  pos 
)
overridevirtual

Reimplemented from Storage.

Definition at line 29 of file StorageAccountProxy.cc.

29  {
31  IOSize result = m_baseStorage->read(into, n, pos);
32  stats.tick(result);
33  return result;
34 }

References m_baseStorage, m_statsRead, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

◆ read() [7/7]

int IOInput::read

Read the next single byte from the input stream and return it as an unsigned char cast to an int, -1 to indicate end of intput data.

If this is a blocking stream, the call will block until the byte can be read, end of data is reached, or an exception is thrown. For a non-blocking input a character is returned if one is available, otherwise an exception is thrown.

The base class implementation simply forwards the call to read(void *, IOSize) method.

Returns
The byte cast from a unsigned char to an int (in range 0...255, inclusive) if one could be read, or -1 to indicate end of input data.
Exceptions
Incase 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).

Definition at line 52 of file IOInput.cc.

52  {
53  unsigned char byte;
54  IOSize n = read(&byte, 1);
55  return n == 0 ? -1 : byte;
56 }

◆ readv() [1/2]

IOSize StorageAccountProxy::readv ( IOBuffer into,
IOSize  buffers 
)
overridevirtual

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.

Returns
The number of bytes actually read. This is less or equal to the size of the buffer. Zero indicates that the end of the input has been reached: end of file, or remote end closing for a connected channel like a pipe or a socket. Otherwise the value can be less than requested if limited amount of input is currently available for platform or implementation reasons. Note that the return value indicates the number of bytes read, not the number of buffers; it is the sum total of bytes filled into all the buffers.
Exceptions
Incase 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 36 of file StorageAccountProxy.cc.

36  {
38  IOSize result = m_baseStorage->readv(into, n);
39  stats.tick(result, n);
40  return result;
41 }

References m_baseStorage, m_statsReadV, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

◆ readv() [2/2]

IOSize StorageAccountProxy::readv ( IOPosBuffer into,
IOSize  n 
)
overridevirtual

Reimplemented from Storage.

Definition at line 43 of file StorageAccountProxy.cc.

43  {
45  IOSize result = m_baseStorage->readv(into, n);
46  stats.tick(result, n);
47  return result;
48 }

References m_baseStorage, m_statsReadV, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

◆ releaseStorage()

void StorageAccountProxy::releaseStorage ( )
inlineprotected

Definition at line 42 of file StorageAccountProxy.h.

42 { get_underlying_safe(m_baseStorage).release(); }

References edm::get_underlying_safe(), and m_baseStorage.

Referenced by ~StorageAccountProxy().

◆ resize()

void StorageAccountProxy::resize ( IOOffset  size)
overridevirtual

◆ write() [1/7]

IOSize StorageAccountProxy::write ( const void *  from,
IOSize  n 
)
overridevirtual

Write n bytes of data starting at address from.

Returns
The number of bytes written. Normally this will be n, but can be less, even zero, for example if the stream is non-blocking mode and cannot accept input at this time.
Exceptions
Incase 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 50 of file StorageAccountProxy.cc.

50  {
52  IOSize result = m_baseStorage->write(from, n);
53  stats.tick(result);
54  return result;
55 }

References m_baseStorage, m_statsWrite, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

◆ write() [2/7]

IOSize IOOutput::write

Write n bytes of data starting at address from.

Returns
The number of bytes written. Normally this will be n, but can be less, even zero, for example if the stream is non-blocking mode and cannot accept input at this time.
Exceptions
Incase 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.

◆ write() [3/7]

IOSize Storage::write

Definition at line 44 of file Storage.cc.

44  {
45  // FIXME: this is not thread safe! split into separate interface
46  // that a particular storage can choose to support or not? make
47  // sure that throw semantics are correct here!
48 
49  // FIXME: use saveposition object in case exceptions are thrown?
50  IOOffset here = position();
51  position(pos);
52  n = write(from, n);
53  position(here);
54  return n;
55 }

◆ write() [4/7]

IOSize StorageAccountProxy::write ( const void *  from,
IOSize  n,
IOOffset  pos 
)
overridevirtual

Reimplemented from Storage.

Definition at line 57 of file StorageAccountProxy.cc.

57  {
59  IOSize result = m_baseStorage->write(from, n, pos);
60  stats.tick(result);
61  return result;
62 }

References m_baseStorage, m_statsWrite, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

◆ write() [5/7]

IOSize IOOutput::write

Write to the output stream the buffer from. This method is simply redirected to write(const void *, IOSize).

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.

Returns
The number of bytes actually written. This is less or equal to the size of the buffer. The value can be less than requested if the stream is unable to accept all the output for platform or implementation reasons.
Exceptions
Incase 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.

Definition at line 59 of file IOOutput.cc.

59 { return write(from.data(), from.size()); }

◆ write() [6/7]

IOSize Storage::write

Definition at line 42 of file Storage.cc.

42 { return write(from.data(), from.size(), pos); }

◆ write() [7/7]

IOSize IOOutput::write

Write a single byte to the output stream. This method is simply redirected to write(const void *, IOSize).

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.

Returns
The number of bytes written. Normally this will be one, but can be zero if the stream is in non-blocking mode and cannot accept output at this time.
Exceptions
Incase 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 – zero will be returned.

Definition at line 39 of file IOOutput.cc.

39 { return write(&byte, 1); }

◆ writev() [1/2]

IOSize StorageAccountProxy::writev ( const IOBuffer from,
IOSize  buffers 
)
overridevirtual

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.

Returns
The number of bytes actually written. This is less or equal to the size of the buffers. The value can be less than requested if the stream is unable to accept all the output for platform or implementation reasons. Note that the return value indicates the number of bytes written, not the number of buffers; it is the sum total of bytes written from all the buffers.
Exceptions
Incase 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 64 of file StorageAccountProxy.cc.

64  {
66  IOSize result = m_baseStorage->writev(from, n);
67  stats.tick(result, n);
68  return result;
69 }

References m_baseStorage, m_statsWriteV, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

◆ writev() [2/2]

IOSize StorageAccountProxy::writev ( const IOPosBuffer from,
IOSize  n 
)
overridevirtual

Reimplemented from Storage.

Definition at line 71 of file StorageAccountProxy.cc.

71  {
73  IOSize result = m_baseStorage->writev(from, n);
74  stats.tick(result, n);
75  return result;
76 }

References m_baseStorage, m_statsWriteV, dqmiodumpmetadata::n, mps_fire::result, and dqmMemoryStats::stats.

Member Data Documentation

◆ m_baseStorage

edm::propagate_const<std::unique_ptr<Storage> > StorageAccountProxy::m_baseStorage
protected

◆ m_statsPosition

StorageAccount::Counter& StorageAccountProxy::m_statsPosition
protected

Definition at line 51 of file StorageAccountProxy.h.

Referenced by position().

◆ m_statsPrefetch

StorageAccount::Counter& StorageAccountProxy::m_statsPrefetch
protected

Definition at line 52 of file StorageAccountProxy.h.

Referenced by prefetch().

◆ m_statsRead

StorageAccount::Counter& StorageAccountProxy::m_statsRead
protected

Definition at line 47 of file StorageAccountProxy.h.

Referenced by read().

◆ m_statsReadV

StorageAccount::Counter& StorageAccountProxy::m_statsReadV
protected

Definition at line 48 of file StorageAccountProxy.h.

Referenced by readv().

◆ m_statsWrite

StorageAccount::Counter& StorageAccountProxy::m_statsWrite
protected

Definition at line 49 of file StorageAccountProxy.h.

Referenced by write().

◆ m_statsWriteV

StorageAccount::Counter& StorageAccountProxy::m_statsWriteV
protected

Definition at line 50 of file StorageAccountProxy.h.

Referenced by writev().

◆ m_token

StorageAccount::StorageClassToken StorageAccountProxy::m_token
protected

Definition at line 46 of file StorageAccountProxy.h.

Referenced by close(), flush(), resize(), StorageAccountProxy(), and ~StorageAccountProxy().

StorageAccount::Operation::flush
Storage::size
virtual IOOffset size(void) const
Definition: Storage.cc:77
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pos
Definition: PixelAliasList.h:18
StorageAccount::Operation::prefetch
StorageAccountProxy::m_statsPrefetch
StorageAccount::Counter & m_statsPrefetch
Definition: StorageAccountProxy.h:52
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
StorageAccount::Operation::position
StorageAccountProxy::m_statsWrite
StorageAccount::Counter & m_statsWrite
Definition: StorageAccountProxy.h:49
StorageAccountProxy::m_statsReadV
StorageAccount::Counter & m_statsReadV
Definition: StorageAccountProxy.h:48
StorageAccount::Operation::readv
StorageAccountProxy::m_statsPosition
StorageAccount::Counter & m_statsPosition
Definition: StorageAccountProxy.h:51
StorageAccount::Operation::close
StorageAccountProxy::m_baseStorage
edm::propagate_const< std::unique_ptr< Storage > > m_baseStorage
Definition: StorageAccountProxy.h:44
StorageAccount::Operation::resize
StorageAccount::Stamp
Definition: StorageAccount.h:93
IOOffset
int64_t IOOffset
Definition: IOTypes.h:19
StorageAccountProxy::m_statsRead
StorageAccount::Counter & m_statsRead
Definition: StorageAccountProxy.h:47
value
Definition: value.py:1
StorageAccount::tokenForStorageClassName
static StorageClassToken tokenForStorageClassName(std::string const &iName)
Definition: StorageAccount.cc:38
StorageAccountProxy::write
IOSize write(const void *from, IOSize n) override
Definition: StorageAccountProxy.cc:50
dqmMemoryStats.stats
stats
Definition: dqmMemoryStats.py:134
StorageAccount::Operation::write
StorageAccount::Operation::read
eostools.move
def move(src, dest)
Definition: eostools.py:511
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Storage::position
virtual IOOffset position(void) const
Definition: Storage.cc:72
IOInput::read
int read(void)
Definition: IOInput.cc:52
StorageAccount::counter
static Counter & counter(StorageClassToken token, Operation operation)
Definition: StorageAccount.cc:97
StorageAccount::Operation::destruct
dqmMemoryStats.total
total
Definition: dqmMemoryStats.py:152
StorageAccountProxy::releaseStorage
void releaseStorage()
Definition: StorageAccountProxy.h:42
StorageAccountProxy::m_statsWriteV
StorageAccount::Counter & m_statsWriteV
Definition: StorageAccountProxy.h:50
mps_fire.result
result
Definition: mps_fire.py:311
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
IOSize
size_t IOSize
Definition: IOTypes.h:14
StorageAccount::Operation::writev
StorageAccountProxy::m_token
StorageAccount::StorageClassToken m_token
Definition: StorageAccountProxy.h:46
StorageAccount::Operation::construct