client-cpp  0.7.0
kaa::DefaultLogUploadStrategy Class Reference

The default ILogUploadStrategy implementation. More...

#include <DefaultLogUploadStrategy.hpp>

+ Inheritance diagram for kaa::DefaultLogUploadStrategy:
+ Collaboration diagram for kaa::DefaultLogUploadStrategy:

Public Member Functions

 DefaultLogUploadStrategy (IKaaChannelManagerPtr manager)
 
virtual LogUploadStrategyDecision isUploadNeeded (ILogStorageStatus &status)
 Decides whether the log upload is needed. More...
 
virtual void onTimeout ()
 Callback is used when the log delivery timeout detected. More...
 
virtual void onFailure (LogDeliveryErrorCode code)
 Callback is used when the log delivery is failed. More...
 
virtual std::size_t getBatchSize ()
 Retrieves the maximum size of the report pack that will be delivered in the single request to the Operations server. More...
 
virtual std::size_t getTimeout ()
 Maximum time to wait the log delivery response. More...
 
void setBatchSize (std::size_t size)
 
void setUploadTimeout (std::size_t timeout)
 
void setRetryPeriod (std::size_t period)
 
void setVolumeThreshold (std::size_t maxVolume)
 
void setCountThreshold (std::size_t maxCount)
 
- Public Member Functions inherited from kaa::ILogUploadStrategy
virtual ~ILogUploadStrategy ()
 

Static Public Attributes

static const std::size_t DEFAULT_BATCH_SIZE = 8 * 1024
 
static const std::size_t DEFAULT_UPLOAD_TIMEOUT = 2 * 60
 
static const std::size_t DEFAULT_RETRY_PERIOD = 5 * 60
 
static const std::size_t DEFAULT_UPLOAD_VOLUME_THRESHOLD = 8 * 1024
 
static const std::size_t DEFAULT_UPLOAD_COUNT_THRESHOLD = 64
 

Detailed Description

The default ILogUploadStrategy implementation.

The decision algorithm depends on the log delivery status:

  1. The normal work flow (the Operations server successfully receives logs).

The LogUploadStrategyDecision::UPLOAD decision applies in two cases: 1) the consumed volume of the log storage is equal or greater than the corresponding value, specified in the strategy via setVolumeThreshold() (DEFAULT_UPLOAD_VOLUME_THRESHOLD is used by default); 2) the number of collected logs is equal or greater than the corresponding value, specified in the strategy via setCountThreshold() (DEFAULT_UPLOAD_COUNT_THRESHOLD is used by default);

  1. The delivery error.

If one of LogDeliveryErrorCode errors has occurred, the LogUploadStrategyDecision::NOOP will apply until the retry period, specified via setRetryPeriod (DEFAULT_RETRY_PERIOD is used by default) will have elapsed.

  1. The delivery timeout.

In this case the strategy tries to switch to the next transport channel supported the logging feature.

Definition at line 52 of file DefaultLogUploadStrategy.hpp.

Constructor & Destructor Documentation

kaa::DefaultLogUploadStrategy::DefaultLogUploadStrategy ( IKaaChannelManagerPtr  manager)

Member Function Documentation

virtual std::size_t kaa::DefaultLogUploadStrategy::getBatchSize ( )
inlinevirtual

Retrieves the maximum size of the report pack that will be delivered in the single request to the Operations server.

Returns
The size of the log batch in bytes.

Implements kaa::ILogUploadStrategy.

Definition at line 61 of file DefaultLogUploadStrategy.hpp.

virtual std::size_t kaa::DefaultLogUploadStrategy::getTimeout ( )
inlinevirtual

Maximum time to wait the log delivery response.

Returns
Time in seconds.

Implements kaa::ILogUploadStrategy.

Definition at line 62 of file DefaultLogUploadStrategy.hpp.

virtual LogUploadStrategyDecision kaa::DefaultLogUploadStrategy::isUploadNeeded ( ILogStorageStatus status)
virtual

Decides whether the log upload is needed.

The decision is made based on the current log storage status and, depending on the strategy implementation, on some additional information.

Parameters
[in]statusThe log storage status.
Returns
The log upload decision.
See also
ILogStorageStatus
LogUploadStrategyDecision

Implements kaa::ILogUploadStrategy.

virtual void kaa::DefaultLogUploadStrategy::onFailure ( LogDeliveryErrorCode  code)
virtual

Callback is used when the log delivery is failed.

Parameters
[in]codeThe reason code of the log delivery failure.
See also
LogDeliveryErrorCode

Implements kaa::ILogUploadStrategy.

virtual void kaa::DefaultLogUploadStrategy::onTimeout ( )
virtual

Callback is used when the log delivery timeout detected.

More information about the detection of the log delivery timeout read in the documentation for ILogCollector.

Implements kaa::ILogUploadStrategy.

void kaa::DefaultLogUploadStrategy::setBatchSize ( std::size_t  size)
inline

Definition at line 64 of file DefaultLogUploadStrategy.hpp.

void kaa::DefaultLogUploadStrategy::setCountThreshold ( std::size_t  maxCount)
inline

Definition at line 68 of file DefaultLogUploadStrategy.hpp.

void kaa::DefaultLogUploadStrategy::setRetryPeriod ( std::size_t  period)
inline

Definition at line 66 of file DefaultLogUploadStrategy.hpp.

void kaa::DefaultLogUploadStrategy::setUploadTimeout ( std::size_t  timeout)
inline

Definition at line 65 of file DefaultLogUploadStrategy.hpp.

void kaa::DefaultLogUploadStrategy::setVolumeThreshold ( std::size_t  maxVolume)
inline

Definition at line 67 of file DefaultLogUploadStrategy.hpp.

Member Data Documentation

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_BATCH_SIZE = 8 * 1024
static

The default value (in bytes) for the maximum size of the report pack that will be delivered in a single request to the Operaions server.

Definition at line 71 of file DefaultLogUploadStrategy.hpp.

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_RETRY_PERIOD = 5 * 60
static

The default value (in seconds) for time to postpone log upload.

Definition at line 78 of file DefaultLogUploadStrategy.hpp.

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_UPLOAD_COUNT_THRESHOLD = 64
static

The default value for the log count to initiate the log upload.

Definition at line 84 of file DefaultLogUploadStrategy.hpp.

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_UPLOAD_TIMEOUT = 2 * 60
static

The default value (in seconds) for time to wait the log delivery response.

Definition at line 75 of file DefaultLogUploadStrategy.hpp.

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_UPLOAD_VOLUME_THRESHOLD = 8 * 1024
static

The default value (in bytes) for log volume to initiate the log upload.

Definition at line 81 of file DefaultLogUploadStrategy.hpp.


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