Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#ifndef CVMFS_UPLOAD_GATEWAY_H_ |
6 |
|
|
#define CVMFS_UPLOAD_GATEWAY_H_ |
7 |
|
|
|
8 |
|
|
#include <string> |
9 |
|
|
|
10 |
|
|
#include "pack.h" |
11 |
|
|
#include "repository_tag.h" |
12 |
|
|
#include "session_context.h" |
13 |
|
|
#include "upload_facility.h" |
14 |
|
|
#include "util/atomic.h" |
15 |
|
|
|
16 |
|
|
namespace upload { |
17 |
|
|
|
18 |
|
|
struct GatewayStreamHandle : public UploadStreamHandle { |
19 |
|
|
GatewayStreamHandle(const CallbackTN* commit_callback, |
20 |
|
|
ObjectPack::BucketHandle bkt); |
21 |
|
|
|
22 |
|
|
ObjectPack::BucketHandle bucket; |
23 |
|
|
}; |
24 |
|
|
|
25 |
|
|
class GatewayUploader : public AbstractUploader { |
26 |
|
|
public: |
27 |
|
|
struct Config { |
28 |
|
4 |
Config() : session_token_file(), key_file(), api_url() {} |
29 |
|
|
Config(const std::string& session_token_file, const std::string& key_file, |
30 |
|
|
const std::string& api_url) |
31 |
|
|
: session_token_file(session_token_file), |
32 |
|
|
key_file(key_file), |
33 |
|
|
api_url(api_url) {} |
34 |
|
|
std::string session_token_file; |
35 |
|
|
std::string key_file; |
36 |
|
|
std::string api_url; |
37 |
|
|
}; |
38 |
|
|
|
39 |
|
|
static bool WillHandle(const SpoolerDefinition& spooler_definition); |
40 |
|
|
|
41 |
|
|
static bool ParseSpoolerDefinition( |
42 |
|
|
const SpoolerDefinition& spooler_definition, Config* config); |
43 |
|
|
|
44 |
|
|
explicit GatewayUploader(const SpoolerDefinition& spooler_definition); |
45 |
|
|
|
46 |
|
|
virtual ~GatewayUploader(); |
47 |
|
|
|
48 |
|
|
virtual bool Initialize(); |
49 |
|
|
|
50 |
|
|
// Can't "create" a repository storage area with the gateway backend |
51 |
|
|
virtual bool Create(); |
52 |
|
|
|
53 |
|
|
virtual bool FinalizeSession(bool commit, const std::string& old_root_hash, |
54 |
|
|
const std::string& new_root_hash, |
55 |
|
|
const RepositoryTag& tag); |
56 |
|
|
|
57 |
|
|
virtual void WaitForUpload() const; |
58 |
|
|
|
59 |
|
|
virtual std::string name() const; |
60 |
|
|
|
61 |
|
|
virtual bool Peek(const std::string& path); |
62 |
|
|
|
63 |
|
|
virtual bool Mkdir(const std::string &path); |
64 |
|
|
|
65 |
|
|
virtual bool PlaceBootstrappingShortcut(const shash::Any& object); |
66 |
|
|
|
67 |
|
|
virtual unsigned int GetNumberOfErrors() const; |
68 |
|
|
|
69 |
|
|
protected: |
70 |
|
|
virtual void DoUpload(const std::string& remote_path, |
71 |
|
|
IngestionSource *source, |
72 |
|
|
const CallbackTN* callback); |
73 |
|
|
|
74 |
|
|
virtual UploadStreamHandle* InitStreamedUpload( |
75 |
|
|
const CallbackTN* callback); |
76 |
|
|
|
77 |
|
|
virtual void StreamedUpload(UploadStreamHandle* handle, UploadBuffer buffer, |
78 |
|
|
const CallbackTN* callback); |
79 |
|
|
|
80 |
|
|
virtual void FinalizeStreamedUpload(UploadStreamHandle* handle, |
81 |
|
|
const shash::Any& content_hash); |
82 |
|
|
|
83 |
|
|
virtual void DoRemoveAsync(const std::string& file_to_delete); |
84 |
|
|
|
85 |
|
|
protected: |
86 |
|
|
virtual void ReadSessionTokenFile(const std::string& token_file_name, |
87 |
|
|
std::string* token); |
88 |
|
|
|
89 |
|
|
virtual bool ReadKey(const std::string& key_file, std::string* key_id, |
90 |
|
|
std::string* secret); |
91 |
|
|
|
92 |
|
|
virtual int64_t DoGetObjectSize(const std::string &file_name); |
93 |
|
|
|
94 |
|
|
private: |
95 |
|
|
void BumpErrors() const; |
96 |
|
|
|
97 |
|
|
Config config_; |
98 |
|
|
SessionContext* session_context_; |
99 |
|
|
mutable atomic_int32 num_errors_; |
100 |
|
|
}; |
101 |
|
|
|
102 |
|
|
} // namespace upload |
103 |
|
|
|
104 |
|
|
#endif // CVMFS_UPLOAD_GATEWAY_H_ |
105 |
|
|
|