client-cpp  0.10.0
kaa::MemoryLogStorage Class Reference

The default ILogStorage implementation. More...

#include <MemoryLogStorage.hpp>

+ Inheritance diagram for kaa::MemoryLogStorage:
+ Collaboration diagram for kaa::MemoryLogStorage:

Public Member Functions

 MemoryLogStorage (IKaaClientContext &context, std::size_t bucketSize=LogStorageConstants::DEFAULT_MAX_BUCKET_SIZE, std::size_t bucketRecordCount=LogStorageConstants::DEFAULT_MAX_BUCKET_RECORD_COUNT)
 Creates the size-unlimited log storage. More...
 
 MemoryLogStorage (IKaaClientContext &context, std::size_t maxOccupiedSize, float percentToDelete, std::size_t bucketSize=LogStorageConstants::DEFAULT_MAX_BUCKET_SIZE, std::size_t bucketRecordCount=LogStorageConstants::DEFAULT_MAX_BUCKET_RECORD_COUNT)
 Creates the size-limited log storage. More...
 
virtual BucketInfo addLogRecord (LogRecord &&record)
 Persists a log record. More...
 
virtual ILogStorageStatusgetStatus ()
 Returns a log storage status. More...
 
virtual LogBucket getNextBucket ()
 Returns a new log bucket. More...
 
virtual void removeBucket (std::int32_t bucketId)
 Tells a log storage to remove a log bucket. More...
 
virtual void rollbackBucket (std::int32_t bucketId)
 Tells a log storage to consider a log bucket as unused, i.e. a log bucket will be accessible again via getNextBucket(). More...
 
virtual std::size_t getConsumedVolume ()
 Returns amount of bytes collected logs are consumed. More...
 
virtual std::size_t getRecordsCount ()
 Returns the number of collected logs. More...
 
- Public Member Functions inherited from kaa::ILogStorage
virtual ~ILogStorage ()
 
- Public Member Functions inherited from kaa::ILogStorageStatus
virtual ~ILogStorageStatus ()
 

Detailed Description

The default ILogStorage implementation.

NOTE: Collected logs are stored in a memory. So logs will be lost if the SDK has been restarted earlier than they are delivered to the Operations server.

Definition at line 38 of file MemoryLogStorage.hpp.

Constructor & Destructor Documentation

kaa::MemoryLogStorage::MemoryLogStorage ( IKaaClientContext context,
std::size_t  bucketSize = LogStorageConstants::DEFAULT_MAX_BUCKET_SIZE,
std::size_t  bucketRecordCount = LogStorageConstants::DEFAULT_MAX_BUCKET_RECORD_COUNT 
)

Creates the size-unlimited log storage.

Parameters
[in]bucketSizeThe bucket size in bytes.
[in]bucketRecordCountThe number of records in a bucket.
kaa::MemoryLogStorage::MemoryLogStorage ( IKaaClientContext context,
std::size_t  maxOccupiedSize,
float  percentToDelete,
std::size_t  bucketSize = LogStorageConstants::DEFAULT_MAX_BUCKET_SIZE,
std::size_t  bucketRecordCount = LogStorageConstants::DEFAULT_MAX_BUCKET_RECORD_COUNT 
)

Creates the size-limited log storage.

If the size of collected logs exceeds the specified maximum size of the log storage, elder logs will be forcibly deleted. The amount of logs (in bytes) to be deleted is computed by the formula:

SIZE = (MAX_SIZE * PERCENT_TO_DELETE) / 100, where PERCENT_TO_DELETE is in the (0.0, 100.0] range.

Parameters
[in]maxOccupiedSizeThe maximum size (in bytes) that collected logs can occupy.
[in]percentToDeleteThe percent of logs (in bytes) to be forcibly deleted.
[in]bucketSizeThe bucket size in bytes.
[in]bucketRecordCountThe number of records in a bucket.
Exceptions
KaaExceptionThe percentage is out of the range.

Member Function Documentation

virtual BucketInfo kaa::MemoryLogStorage::addLogRecord ( LogRecord &&  record)
virtual

Persists a log record.

Parameters
recordThe LogRecord object.
Returns
The BucketInfo object which contains information about a bucket the log record is added.
See Also
LogRecord
BucketInfo

Implements kaa::ILogStorage.

virtual std::size_t kaa::MemoryLogStorage::getConsumedVolume ( )
virtual

Returns amount of bytes collected logs are consumed.

Returns
Size (in bytes).

Implements kaa::ILogStorageStatus.

virtual LogBucket kaa::MemoryLogStorage::getNextBucket ( )
virtual

Returns a new log bucket.

Returns
The LogBucket object.
See Also
LogBucket

Implements kaa::ILogStorage.

virtual std::size_t kaa::MemoryLogStorage::getRecordsCount ( )
virtual

Returns the number of collected logs.

Returns
The number of collected logs.

Implements kaa::ILogStorageStatus.

virtual ILogStorageStatus& kaa::MemoryLogStorage::getStatus ( )
inlinevirtual

Returns a log storage status.

Returns
The LogStorageStatus object.
See Also
LogStorageStatus

Implements kaa::ILogStorage.

Definition at line 71 of file MemoryLogStorage.hpp.

virtual void kaa::MemoryLogStorage::removeBucket ( std::int32_t  bucketId)
virtual

Tells a log storage to remove a log bucket.

Parameters
bucketIdThe id of a log bucket.
See Also
LogBucket
BucketInfo

Implements kaa::ILogStorage.

virtual void kaa::MemoryLogStorage::rollbackBucket ( std::int32_t  bucketId)
virtual

Tells a log storage to consider a log bucket as unused, i.e. a log bucket will be accessible again via getNextBucket().

Parameters
bucketIdThe id of a log bucket.
See Also
LogBucket
BucketInfo

Implements kaa::ILogStorage.


The documentation for this class was generated from the following file: