client-cpp  0.7.0
LogCollector.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LOGCOLLECTOR_HPP_
18 #define LOGCOLLECTOR_HPP_
19 
20 
21 #include <chrono>
22 #include <memory>
23 #include <unordered_map>
24 
25 #include "kaa/KaaThread.hpp"
26 #include "kaa/log/ILogStorage.hpp"
31 
32 namespace kaa {
33 
34 class LoggingTransport;
35 
39 class LogCollector : public ILogCollector, public ILogProcessor {
40 public:
42 
43  virtual void addLogRecord(const KaaUserLogRecord& record);
44 
45  virtual void setStorage(ILogStoragePtr storage);
46  virtual void setUploadStrategy(ILogUploadStrategyPtr strategy);
47 
48  std::shared_ptr<LogSyncRequest> getLogUploadRequest();
49  virtual void onLogUploadResponse(const LogSyncResponse& response);
50 
51  void setTransport(LoggingTransport* transport);
52 
53 private:
54  void doSync();
55  void processLogUploadDecision(LogUploadStrategyDecision decision);
56 
57  bool isDeliveryTimeout();
58 
59 private:
60  ILogStoragePtr storage_;
61  ILogUploadStrategyPtr uploadStrategy_;
62 
63  KAA_MUTEX_DECLARE(storageGuard_);
64 
65  RequestId requestId_;
66  LoggingTransport* transport_;
67 
68  typedef std::chrono::system_clock clock_t;
69  std::unordered_map<std::int32_t, std::chrono::time_point<clock_t>> timeoutsMap_;
70 };
71 
72 } // namespace kaa
73 
74 #endif /* LOGCOLLECTOR_HPP_ */
virtual void setStorage(ILogStoragePtr storage)
Sets the new log storage.
LogCollector(IKaaChannelManagerPtr manager)
void setTransport(LoggingTransport *transport)
virtual void setUploadStrategy(ILogUploadStrategyPtr strategy)
Sets the new log upload strategy.
std::shared_ptr< ILogStorage > ILogStoragePtr
virtual void addLogRecord(const KaaUserLogRecord &record)
Adds a new log record to the log storage.
std::int32_t RequestId
Definition: KaaThread.hpp:82
The public interface to the Kaa log collecting subsystem.
virtual void onLogUploadResponse(const LogSyncResponse &response)
NOTE: THIS FILE IS AUTO-GENERATED. DO NOT EDIT IT MANUALLY.
std::shared_ptr< LogSyncRequest > getLogUploadRequest()
std::shared_ptr< ILogUploadStrategy > ILogUploadStrategyPtr
LogUploadStrategyDecision
Log upload decisions.