GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/receiver/payload_processor.h
Date: 2024-04-21 02:33:16
Exec Total Coverage
Lines: 0 1 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
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
25 upload::UploadStreamHandle *handle;
26 size_t total_size;
27 size_t current_size;
28 shash::ContextPtr hash_context;
29 std::vector<unsigned char> hash_buffer;
30 };
31
32 /**
33 * This class is used in the `cvmfs_receiver` tool, on repository gateway
34 * machines. The receiver::Reactor class, implementing the event loop of the
35 * `cvmfs_receiver` tool, dispatches the handling of the kSubmitPayload events
36 * to this class.
37 *
38 * Its responsibility is reading the payload - containing a serialized
39 * ObjectPack - from a file descriptor, and unpacking it into the repository.
40 */
41 class PayloadProcessor {
42 public:
43 enum Result { kSuccess, kPathViolation, kUploaderError, kOtherError };
44
45 PayloadProcessor();
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
58 void SetStatistics(perf::Statistics *st);
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_;
70 UniquePtr<upload::AbstractUploader> uploader_;
71 UniquePtr<RaiiTempDir> temp_dir_;
72 int num_errors_;
73 UniquePtr<perf::StatisticsTemplate> statistics_;
74 };
75
76 } // namespace receiver
77
78 #endif // CVMFS_RECEIVER_PAYLOAD_PROCESSOR_H_
79