17 #ifndef LOGCOLLECTOR_HPP_
18 #define LOGCOLLECTOR_HPP_
25 #include <unordered_map>
40 class IExecutorContext;
41 class LoggingTransport;
44 typedef std::chrono::system_clock
clock_t;
49 TimeoutInfo(
const std::int32_t& transportAccessPointId,
const std::chrono::time_point<clock_t>& timeoutTime)
50 : transportAccessPointId_(transportAccessPointId), timeoutTime_(timeoutTime) {}
53 return transportAccessPointId_;
61 std::int32_t transportAccessPointId_;
62 std::chrono::time_point<clock_t> timeoutTime_;
78 logDeliverylistener_ = listener;
82 virtual void onLogUploadResponse(
const LogSyncResponse& response, std::size_t deliveryTime);
85 transport_ = transport;
89 typedef std::shared_ptr<std::promise<RecordInfo>> DeliveryFuture;
91 struct RecordDeliveryInfo {
92 RecordDeliveryInfo(
const DeliveryFuture& f,
const RecordInfo& info)
93 : deliveryFuture_(f), recordInfo_(info) {}
95 DeliveryFuture deliveryFuture_;
96 RecordInfo recordInfo_;
99 struct BucketWrapper {
100 BucketInfo bucketInfo_;
101 std::list<RecordDeliveryInfo> recordDeliveryInfoStorage_;
105 virtual void retryLogUpload();
106 virtual void retryLogUpload(std::size_t delay);
108 virtual void switchAccessPoint();
113 bool isDeliveryTimeout();
114 void addDeliveryTimeout(std::int32_t requestId);
115 bool removeDeliveryTimeout(std::int32_t requestId);
117 void startTimeoutTimer();
118 void startLogUploadCheckTimer();
120 void processTimeout();
122 void rescheduleTimers();
124 bool isUploadAllowed();
127 void updateBucketInfo(
const BucketInfo& bucketInfo,
const RecordDeliveryInfo& recordInfo);
128 BucketInfo getBucketInfo(std::int32_t);
129 void notifyDeliveryFuturesOnSuccess(std::int32_t bucketId, std::size_t deliveryTime);
130 void removeBucketInfo(std::int32_t);
135 LoggingTransport* transport_;
139 std::unordered_map<std::int32_t, TimeoutInfo> timeouts_;
140 std::int32_t timeoutAccessPointId_;
141 KAA_MUTEX_DECLARE(timeoutsGuard_);
143 KaaTimer<void ()> logUploadCheckTimer_;
144 KaaTimer<void ()> scheduledUploadTimer_;
145 KaaTimer<void ()> timeoutTimer_;
149 std::unordered_map<std::int32_t, BucketWrapper> bucketInfoStorage_;
150 KAA_MUTEX_DECLARE(bucketInfoStorageGuard_);
152 IKaaClientContext &context_;
virtual void setStorage(ILogStoragePtr storage)
Sets the new log storage.
std::shared_ptr< ILogDeliveryListener > ILogDeliveryListenerPtr
void setTransport(LoggingTransport *transport)
virtual void setUploadStrategy(ILogUploadStrategyPtr strategy)
Sets the new log upload strategy.
std::shared_ptr< ILogStorage > ILogStoragePtr
virtual std::shared_ptr< LogSyncRequest > getLogUploadRequest()
IKaaChannelManager * IKaaChannelManagerPtr
TimeoutInfo(const std::int32_t &transportAccessPointId, const std::chrono::time_point< clock_t > &timeoutTime)
The public interface to the Kaa log collecting subsystem.
virtual void onLogUploadResponse(const LogSyncResponse &response, std::size_t deliveryTime)
Describes unique log record delivery info.
NOTE: THIS FILE IS AUTO-GENERATED. DO NOT EDIT IT MANUALLY.
LogCollector(IKaaChannelManagerPtr manager, IKaaClientContext &context)
std::shared_ptr< ILogUploadStrategy > ILogUploadStrategyPtr
std::chrono::system_clock clock_t
virtual void setLogDeliveryListener(ILogDeliveryListenerPtr listener)
Set a listener which receives a delivery status of each log bucket.
LogUploadStrategyDecision
Log upload decisions.
std::chrono::time_point< clock_t > getTimeoutTime() const
virtual RecordFuture addLogRecord(const KaaUserLogRecord &record)
Adds a new log record to the log storage.
std::int32_t getTransportAccessPointId() const