client-cpp  0.10.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 (IKaaClientContext &context)
 
virtual LogUploadStrategyDecision isUploadNeeded (ILogStorageStatus &status)
 Decides whether the log upload is needed. More...
 
virtual void onTimeout (ILogFailoverCommand &controller)
 Callback is used when the log delivery timeout detected. More...
 
virtual void onFailure (ILogFailoverCommand &controller, LogDeliveryErrorCode code)
 Callback is used when the log delivery is failed. More...
 
virtual std::size_t getTimeout ()
 Maximum time to wait the log delivery response. More...
 
void setUploadTimeout (std::size_t timeout)
 
virtual std::size_t getTimeoutCheckPeriod ()
 
void setTimeoutCheckPeriod (std::size_t period)
 
virtual std::size_t getLogUploadCheckPeriod ()
 
void setLogUploadCheckPeriod (std::size_t period)
 
virtual std::size_t getMaxParallelUploads ()
 Max amount of log batches allowed to be uploaded parallel. More...
 
void setMaxParallelUploads (std::size_t count)
 
std::size_t getRetryPeriod ()
 
void setRetryPeriod (std::size_t period)
 
std::size_t getVolumeThreshold () const
 
void setVolumeThreshold (std::size_t maxVolume)
 
std::size_t getCountThreshold () const
 
void setCountThreshold (std::size_t maxCount)
 
- Public Member Functions inherited from kaa::ILogUploadStrategy
virtual ~ILogUploadStrategy ()
 

Static Public Attributes

static const std::size_t DEFAULT_UPLOAD_TIMEOUT = 2 * 60
 
static const std::size_t DEFAULT_TIMEOUT_CHECK_PERIOD = 10
 
static const std::size_t DEFAULT_LOG_UPLOAD_CHECK_PERIOD = 30
 
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
 
static const std::size_t DEFAULT_MAX_PARALLEL_UPLOADS = INT32_MAX
 

Protected Attributes

std::size_t uploadTimeout_ = DEFAULT_UPLOAD_TIMEOUT
 
std::size_t retryReriod_ = DEFAULT_RETRY_PERIOD
 
std::size_t timeoutCheckPeriod_ = DEFAULT_TIMEOUT_CHECK_PERIOD
 
std::size_t logUploadCheckReriod_ = DEFAULT_LOG_UPLOAD_CHECK_PERIOD
 
std::size_t uploadVolumeThreshold_ = DEFAULT_UPLOAD_VOLUME_THRESHOLD
 
std::size_t uploadCountThreshold_ = DEFAULT_UPLOAD_COUNT_THRESHOLD
 
std::size_t maxParallelUploads_ = DEFAULT_MAX_PARALLEL_UPLOADS
 
IKaaClientContextcontext_
 

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 53 of file DefaultLogUploadStrategy.hpp.

Constructor & Destructor Documentation

kaa::DefaultLogUploadStrategy::DefaultLogUploadStrategy ( IKaaClientContext context)
inline

Definition at line 55 of file DefaultLogUploadStrategy.hpp.

Member Function Documentation

std::size_t kaa::DefaultLogUploadStrategy::getCountThreshold ( ) const
inline

Definition at line 80 of file DefaultLogUploadStrategy.hpp.

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

Implements kaa::ILogUploadStrategy.

Definition at line 68 of file DefaultLogUploadStrategy.hpp.

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

Max amount of log batches allowed to be uploaded parallel.

Returns
Amount of batches.

Implements kaa::ILogUploadStrategy.

Definition at line 71 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::getRetryPeriod ( )
inline

Definition at line 74 of file DefaultLogUploadStrategy.hpp.

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

Maximum time to wait the log delivery response.

Parameters
[in]controller
Returns
Time in seconds.

Implements kaa::ILogUploadStrategy.

Definition at line 62 of file DefaultLogUploadStrategy.hpp.

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

Implements kaa::ILogUploadStrategy.

Definition at line 65 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::getVolumeThreshold ( ) const
inline

Definition at line 77 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.

Reimplemented in kaa::RecordCountWithTimeLimitLogUploadStrategy, kaa::StorageSizeWithTimeLimitLogUploadStrategy, kaa::PeriodicLogUploadStrategy, kaa::RecordCountLogUploadStrategy, and kaa::StorageSizeLogUploadStrategy.

virtual void kaa::DefaultLogUploadStrategy::onFailure ( ILogFailoverCommand controller,
LogDeliveryErrorCode  code 
)
virtual

Callback is used when the log delivery is failed.

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

Implements kaa::ILogUploadStrategy.

virtual void kaa::DefaultLogUploadStrategy::onTimeout ( ILogFailoverCommand controller)
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::setCountThreshold ( std::size_t  maxCount)
inline

Definition at line 81 of file DefaultLogUploadStrategy.hpp.

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

Definition at line 69 of file DefaultLogUploadStrategy.hpp.

void kaa::DefaultLogUploadStrategy::setMaxParallelUploads ( std::size_t  count)
inline

Definition at line 72 of file DefaultLogUploadStrategy.hpp.

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

Definition at line 75 of file DefaultLogUploadStrategy.hpp.

void kaa::DefaultLogUploadStrategy::setTimeoutCheckPeriod ( 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 63 of file DefaultLogUploadStrategy.hpp.

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

Definition at line 78 of file DefaultLogUploadStrategy.hpp.

Member Data Documentation

IKaaClientContext& kaa::DefaultLogUploadStrategy::context_
protected

Definition at line 116 of file DefaultLogUploadStrategy.hpp.

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_LOG_UPLOAD_CHECK_PERIOD = 30
static

Definition at line 89 of file DefaultLogUploadStrategy.hpp.

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_MAX_PARALLEL_UPLOADS = INT32_MAX
static

The default value for Max amount of log batches allowed to be uploaded parallel.

Definition at line 100 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 91 of file DefaultLogUploadStrategy.hpp.

const std::size_t kaa::DefaultLogUploadStrategy::DEFAULT_TIMEOUT_CHECK_PERIOD = 10
static

Definition at line 87 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 97 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 84 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 94 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::logUploadCheckReriod_ = DEFAULT_LOG_UPLOAD_CHECK_PERIOD
protected

Definition at line 109 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::maxParallelUploads_ = DEFAULT_MAX_PARALLEL_UPLOADS
protected

Definition at line 114 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::retryReriod_ = DEFAULT_RETRY_PERIOD
protected

Definition at line 105 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::timeoutCheckPeriod_ = DEFAULT_TIMEOUT_CHECK_PERIOD
protected

Definition at line 107 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::uploadCountThreshold_ = DEFAULT_UPLOAD_COUNT_THRESHOLD
protected

Definition at line 112 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::uploadTimeout_ = DEFAULT_UPLOAD_TIMEOUT
protected

Definition at line 104 of file DefaultLogUploadStrategy.hpp.

std::size_t kaa::DefaultLogUploadStrategy::uploadVolumeThreshold_ = DEFAULT_UPLOAD_VOLUME_THRESHOLD
protected

Definition at line 111 of file DefaultLogUploadStrategy.hpp.


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