CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
payload_processor.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_RECEIVER_PAYLOAD_PROCESSOR_H_
6 #define CVMFS_RECEIVER_PAYLOAD_PROCESSOR_H_
7 
8 #include <stdint.h>
9 #include <map>
10 #include <string>
11 #include <vector>
12 
13 #include "pack.h"
14 #include "upload.h"
15 #include "util/raii_temp_dir.h"
16 
17 namespace receiver {
18 
19 struct FileInfo {
20  FileInfo();
21  explicit FileInfo(const ObjectPackBuild::Event& event);
22  FileInfo(const FileInfo& other);
23  FileInfo& operator=(const FileInfo& other);
24 
26  size_t total_size;
27  size_t current_size;
29  std::vector<unsigned char> hash_buffer;
30 };
31 
42  public:
44 
46  virtual ~PayloadProcessor();
47 
48  Result Process(int fdin, const std::string& header_digest,
49  const std::string& path, uint64_t header_size);
50 
51  virtual void ConsumerEventCallback(const ObjectPackBuild::Event& event);
52 
53  virtual void OnUploadJobComplete(const upload::UploaderResults &results,
54  void *buffer);
55 
56  int GetNumErrors() const { return num_errors_; }
57 
59 
60  protected:
61  // NOTE: These methods are made virtual such that they can be mocked for
62  // the purpose of unit testing
63  virtual Result Initialize();
64  virtual Result Finalize();
65 
66  private:
67  typedef std::map<shash::Any, FileInfo>::iterator FileIterator;
68  std::map<shash::Any, FileInfo> pending_files_;
69  std::string current_repo_;
74 };
75 
76 } // namespace receiver
77 
78 #endif // CVMFS_RECEIVER_PAYLOAD_PROCESSOR_H_
upload::UploadStreamHandle * handle
FileInfo & operator=(const FileInfo &other)
UniquePtr< upload::AbstractUploader > uploader_
UniquePtr< perf::StatisticsTemplate > statistics_
virtual void OnUploadJobComplete(const upload::UploaderResults &results, void *buffer)
virtual void ConsumerEventCallback(const ObjectPackBuild::Event &event)
std::vector< unsigned char > hash_buffer
shash::ContextPtr hash_context
std::map< shash::Any, FileInfo > pending_files_
UniquePtr< RaiiTempDir > temp_dir_
Result Process(int fdin, const std::string &header_digest, const std::string &path, uint64_t header_size)
std::map< shash::Any, FileInfo >::iterator FileIterator
void SetStatistics(perf::Statistics *st)