| 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 |
|
104 |
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(const CallbackTN *callback); |
| 75 |
|
|
|
| 76 |
|
|
virtual void StreamedUpload(UploadStreamHandle *handle, UploadBuffer buffer, |
| 77 |
|
|
const CallbackTN *callback); |
| 78 |
|
|
|
| 79 |
|
|
virtual void FinalizeStreamedUpload(UploadStreamHandle *handle, |
| 80 |
|
|
const shash::Any &content_hash); |
| 81 |
|
|
|
| 82 |
|
|
virtual void DoRemoveAsync(const std::string &file_to_delete); |
| 83 |
|
|
|
| 84 |
|
|
protected: |
| 85 |
|
|
virtual void ReadSessionTokenFile(const std::string &token_file_name, |
| 86 |
|
|
std::string *token); |
| 87 |
|
|
|
| 88 |
|
|
virtual bool ReadKey(const std::string &key_file, std::string *key_id, |
| 89 |
|
|
std::string *secret); |
| 90 |
|
|
|
| 91 |
|
|
virtual int64_t DoGetObjectSize(const std::string &file_name); |
| 92 |
|
|
|
| 93 |
|
|
private: |
| 94 |
|
|
void BumpErrors() const; |
| 95 |
|
|
|
| 96 |
|
|
Config config_; |
| 97 |
|
|
SessionContext *session_context_; |
| 98 |
|
|
mutable atomic_int32 num_errors_; |
| 99 |
|
|
}; |
| 100 |
|
|
|
| 101 |
|
|
} // namespace upload |
| 102 |
|
|
|
| 103 |
|
|
#endif // CVMFS_UPLOAD_GATEWAY_H_ |
| 104 |
|
|
|