CernVM-FS
2.12.0
|
#include <upload_facility.h>
Classes | |
struct | JobStatus |
struct | UploadBuffer |
struct | UploadJob |
Public Member Functions | |
virtual | ~AbstractUploader () |
virtual std::string | name () const =0 |
virtual bool | Create ()=0 |
virtual unsigned | GetNumTasks () const |
virtual bool | Initialize () |
virtual bool | FinalizeSession (bool commit, const std::string &old_root_hash, const std::string &new_root_hash, const RepositoryTag &tag) |
void | TearDown () |
void | UploadFile (const std::string &local_path, const std::string &remote_path, const CallbackTN *callback=NULL) |
void | UploadIngestionSource (const std::string &remote_path, IngestionSource *source, const CallbackTN *callback=NULL) |
virtual UploadStreamHandle * | InitStreamedUpload (const CallbackTN *callback)=0 |
void | ScheduleUpload (UploadStreamHandle *handle, UploadBuffer buffer, const CallbackTN *callback=NULL) |
void | ScheduleCommit (UploadStreamHandle *handle, const shash::Any &content_hash) |
void | RemoveAsync (const std::string &file_to_delete) |
void | RemoveAsync (const shash::Any &hash_to_delete) |
int64_t | GetObjectSize (const shash::Any &hash) |
virtual bool | Peek (const std::string &path)=0 |
virtual bool | Mkdir (const std::string &path)=0 |
virtual bool | PlaceBootstrappingShortcut (const shash::Any &object)=0 |
virtual void | WaitForUpload () const |
virtual unsigned int | GetNumberOfErrors () const =0 |
void | InitCounters (perf::StatisticsTemplate *statistics) |
Public Member Functions inherited from PolymorphicConstructionImpl< AbstractUploader, SpoolerDefinition, void > | |
virtual | ~PolymorphicConstructionImpl () |
Static Public Member Functions | |
static void | RegisterPlugins () |
Static Public Member Functions inherited from PolymorphicConstruction< AbstractUploader, SpoolerDefinition > | |
static IntrospectionData | Introspect () |
Static Public Member Functions inherited from PolymorphicConstructionImpl< AbstractUploader, SpoolerDefinition, void > | |
static AbstractUploader * | Construct (const SpoolerDefinition ¶m) |
Static Public Member Functions inherited from Callbackable< UploaderResults > | |
static CallbackTN * | MakeClosure (typename BoundClosure< UploaderResults, DelegateT, ClosureDataT >::CallbackMethod method, DelegateT *delegate, const ClosureDataT &closure_data) |
static CallbackTN * | MakeCallback (typename BoundCallback< UploaderResults, DelegateT >::CallbackMethod method, DelegateT *delegate) |
static CallbackTN * | MakeCallback (typename Callback< UploaderResults >::CallbackFunction function) |
Protected Types | |
typedef Callbackable < UploaderResults > ::CallbackTN * | CallbackPtr |
Protected Types inherited from PolymorphicConstructionImpl< AbstractUploader, SpoolerDefinition, void > | |
typedef AbstractFactory < AbstractUploader, SpoolerDefinition, void > | Factory |
typedef std::vector< Factory * > | RegisteredPlugins |
Protected Member Functions | |
AbstractUploader (const SpoolerDefinition &spooler_definition) | |
virtual void | DoUpload (const std::string &remote_path, IngestionSource *source, const CallbackTN *callback)=0 |
virtual void | StreamedUpload (UploadStreamHandle *handle, UploadBuffer buffer, const CallbackTN *callback)=0 |
virtual void | FinalizeStreamedUpload (UploadStreamHandle *handle, const shash::Any &content_hash)=0 |
virtual void | DoRemoveAsync (const std::string &file_to_delete)=0 |
virtual int64_t | DoGetObjectSize (const std::string &file_name)=0 |
void | Respond (const CallbackTN *callback, const UploaderResults &result) const |
int | CreateAndOpenTemporaryChunkFile (std::string *path) const |
const SpoolerDefinition & | spooler_definition () const |
void | CountUploadedChunks () const |
void | DecUploadedChunks () const |
void | CountUploadedBytes (int64_t bytes_written) const |
void | CountDuplicates () const |
void | CountUploadedCatalogs () const |
void | CountUploadedCatalogBytes (int64_t bytes_written) const |
void | IncJobsInFlight () |
Protected Member Functions inherited from SingleCopy | |
SingleCopy () | |
Private Attributes | |
const SpoolerDefinition | spooler_definition_ |
unsigned | num_upload_tasks_ |
SynchronizingCounter< int32_t > | jobs_in_flight_ |
TubeGroup< UploadJob > | tubes_upload_ |
TubeConsumerGroup< UploadJob > | tasks_upload_ |
UniquePtr< UploadCounters > | counters_ |
Friends | |
class | TaskUpload |
Additional Inherited Members | |
Public Types inherited from PolymorphicConstruction< AbstractUploader, SpoolerDefinition > | |
typedef std::vector< void > | IntrospectionData |
Public Types inherited from Callbackable< UploaderResults > | |
typedef CallbackBase < UploaderResults > | CallbackTN |
Static Protected Member Functions inherited from PolymorphicConstructionImpl< AbstractUploader, SpoolerDefinition, void > | |
static void | LazilyRegisterPlugins () |
static void | RegisterPlugin () |
Static Protected Attributes inherited from PolymorphicConstructionImpl< AbstractUploader, SpoolerDefinition, void > | |
static RegisteredPlugins | registered_plugins_ |
Abstract base class for all backend upload facilities This class defines an interface and constructs the concrete Uploaders, furthermore it handles callbacks to the outside world to notify users of done upload jobs.
Note: Users could be both the Spooler (when calling Spooler::Upload()) and the IngestionPipeline (when calling Spooler::Process()). We therefore cannot use the Observable template here, since this would forward finished upload jobs to ALL listeners instead of only the owner of the specific job.
Definition at line 83 of file upload_facility.h.
|
protected |
Definition at line 334 of file upload_facility.h.
|
inlinevirtual |
|
explicitprotected |
Definition at line 46 of file upload_facility.cc.
|
protected |
Definition at line 125 of file upload_facility.cc.
Referenced by upload::LocalUploader::FinalizeStreamedUpload(), and upload::S3Uploader::MainCollectResults().
|
protected |
Definition at line 119 of file upload_facility.cc.
Referenced by upload::LocalUploader::FinalizeStreamedUpload(), upload::S3Uploader::FinalizeStreamedUpload(), upload::GatewayUploader::FinalizeStreamedUpload(), and upload::S3Uploader::MainCollectResults().
|
protected |
Definition at line 137 of file upload_facility.cc.
Referenced by upload::LocalUploader::FinalizeStreamedUpload(), upload::S3Uploader::FinalizeStreamedUpload(), and upload::GatewayUploader::FinalizeStreamedUpload().
|
protected |
Definition at line 131 of file upload_facility.cc.
Referenced by upload::LocalUploader::FinalizeStreamedUpload(), upload::S3Uploader::FinalizeStreamedUpload(), and upload::GatewayUploader::FinalizeStreamedUpload().
|
protected |
Definition at line 107 of file upload_facility.cc.
Referenced by upload::LocalUploader::FinalizeStreamedUpload(), upload::S3Uploader::FinalizeStreamedUpload(), and upload::GatewayUploader::FinalizeStreamedUpload().
|
pure virtual |
Initializes a new repository storage area, e.g. create directory layout for local backend or create bucket for S3 backend.
Implemented in upload::GatewayUploader, upload::S3Uploader, and upload::LocalUploader.
|
protected |
Creates a temporary file in the backend storage's temporary location For the LocalUploader this usually is the 'txn' directory of the backend storage. Otherwise it is some scratch area.
path | pointer to a string that will contain the created file path |
Definition at line 72 of file upload_facility.cc.
Referenced by upload::LocalUploader::InitStreamedUpload().
|
protected |
Definition at line 113 of file upload_facility.cc.
Referenced by upload::S3Uploader::MainCollectResults().
|
protectedpure virtual |
Implemented in upload::GatewayUploader, upload::LocalUploader, and upload::S3Uploader.
Referenced by GetObjectSize().
|
protectedpure virtual |
Implemented in upload::GatewayUploader, upload::S3Uploader, and upload::LocalUploader.
Referenced by RemoveAsync().
|
protectedpure virtual |
Implementation of plain file upload Public interface: AbstractUploader::Upload()
local_path | file to be uploaded |
remote_path | destination to be written in the backend |
callback | callback to be called on completion |
Implemented in upload::GatewayUploader, upload::S3Uploader, and upload::LocalUploader.
Referenced by UploadFile(), and UploadIngestionSource().
|
virtual |
Called during Spooler::WaitForUpload(), to ensure that the upload has finished. If commit == true, then a Commit request is also sent, to apply all the the changes accumulated during the session. "catalog_path" represents the path of the root catalog with the changes. By default it is a noop and returns true;
Reimplemented in upload::GatewayUploader.
Definition at line 64 of file upload_facility.cc.
|
protectedpure virtual |
Implementation of streamed upload commit Public interface: AbstractUploader::ScheduleUpload()
handle | descendant of UploadStreamHandle specifying the stream |
content_hash | the computed content hash of the streamed object |
Implemented in upload::GatewayUploader, upload::S3Uploader, and upload::LocalUploader.
Referenced by upload::TaskUpload::Process().
|
pure virtual |
Implemented in upload::LocalUploader, upload::S3Uploader, and upload::GatewayUploader.
Referenced by StatisticsDatabase::UploadStatistics().
|
inlinevirtual |
Concrete uploaders might want to use a customized setting for multi-stream writing, for instance one per disk. Note that the S3 backend uses one task but this one task uses internally multiple HTTP streams through curl async I/O.
Definition at line 157 of file upload_facility.h.
Referenced by Initialize().
|
inline |
Get object size based on its content hash
hash | the content hash of a file |
Definition at line 289 of file upload_facility.h.
|
inlineprotected |
Used by concrete implementations when they use callbacks where it's not already foreseen, e.g. S3Uploader::Peek().
Definition at line 423 of file upload_facility.h.
Referenced by upload::S3Uploader::Create(), and upload::S3Uploader::Peek().
void upload::AbstractUploader::InitCounters | ( | perf::StatisticsTemplate * | statistics | ) |
Definition at line 103 of file upload_facility.cc.
|
virtual |
This is called right after the constructor of AbstractUploader or/and its derived class has been executed. You can override that to do additional initialization that cannot be done in the constructor itself.
Reimplemented from PolymorphicConstructionImpl< AbstractUploader, SpoolerDefinition, void >.
Reimplemented in upload::GatewayUploader.
Definition at line 53 of file upload_facility.cc.
Referenced by upload::GatewayUploader::Initialize().
|
pure virtual |
This method is called before the first data block of a streamed upload is scheduled (see above implementation of UploadStreamHandle for details).
callback | (optional) this callback will be invoked once this parti- cular streamed upload is committed. |
Implemented in upload::GatewayUploader, upload::S3Uploader, and upload::LocalUploader.
Referenced by TaskWrite::Process().
|
pure virtual |
Make directory in upstream storage. Noop if directory already present.
path | relative directory path in the upstream storage |
Implemented in upload::S3Uploader, upload::LocalUploader, and upload::GatewayUploader.
|
pure virtual |
A string identifying the uploader type
Implemented in upload::GatewayUploader, upload::S3Uploader, and upload::LocalUploader.
|
pure virtual |
Checks if a file is already present in the backend storage. This might be a synchronous operation.
path | the path of the file to be checked |
Implemented in upload::S3Uploader, upload::LocalUploader, and upload::GatewayUploader.
|
pure virtual |
Creates a top-level shortcut to the given data object. This is particularly useful for bootstrapping repositories whose data-directory is secured by a VOMS certificate.
object | content hash of the object to be exposed on the top-level |
Implemented in upload::LocalUploader, upload::S3Uploader, and upload::GatewayUploader.
|
static |
Definition at line 40 of file upload_facility.cc.
|
inline |
Removes a file from the backend storage.
Note: If the file doesn't exist before calling this won't be an error.
file_to_delete | path to the file to be removed |
Definition at line 270 of file upload_facility.h.
Referenced by RemoveAsync(), and StatisticsDatabase::UploadStatistics().
|
inline |
Overloaded method used to remove a object based on its content hash.
hash_to_delete | the content hash of a file to be deleted |
Definition at line 280 of file upload_facility.h.
|
inlineprotected |
This notifies the callback that is associated to a finishing job. Please do not call the handed callback yourself in concrete Uploaders!
Note: Since the job is finished after we respond to it, the callback object gets automatically destroyed by this call! Therefore you must not call Respond() twice or use the callback later by any means!
Definition at line 386 of file upload_facility.h.
Referenced by upload::LocalUploader::DoRemoveAsync(), upload::GatewayUploader::DoRemoveAsync(), upload::LocalUploader::DoUpload(), upload::S3Uploader::DoUpload(), upload::GatewayUploader::DoUpload(), upload::LocalUploader::FinalizeStreamedUpload(), upload::GatewayUploader::FinalizeStreamedUpload(), upload::S3Uploader::MainCollectResults(), upload::LocalUploader::StreamedUpload(), upload::S3Uploader::StreamedUpload(), and upload::GatewayUploader::StreamedUpload().
|
inline |
This method schedules a commit job as soon as all data blocks of a streamed upload are (successfully) uploaded. Derived classes must override AbstractUploader::FinalizeStreamedUpload() for this to happen.
handle | Pointer to a previously acquired UploadStreamHandle |
content_hash | the content hash of the full uploaded data Chunk |
Definition at line 255 of file upload_facility.h.
Referenced by TaskWrite::Process().
|
inline |
This method schedules a buffer to be uploaded in the context of the given UploadStreamHandle. The actual upload will happen asynchronously by a concrete implementation of AbstractUploader (see AbstractUploader::StreamedUpload()). As soon has the scheduled upload job is complete (either successful or not) the optionally passed callback is supposed to be invoked using AbstractUploader::Respond().
handle | Pointer to a previously acquired UploadStreamHandle |
buffer | contains the data block to be uploaded |
callback | (optional) callback object to be invoked once the given upload is finished (see AbstractUploader::Respond()) |
Definition at line 238 of file upload_facility.h.
Referenced by TaskWrite::Process().
|
inlineprotected |
Definition at line 407 of file upload_facility.h.
Referenced by upload::S3Uploader::DoUpload(), upload::GatewayUploader::DoUpload(), and upload::S3Uploader::InitStreamedUpload().
|
protectedpure virtual |
Implementation of a streamed upload step. See public interface for details. Public interface: AbstractUploader::ScheduleUpload()
handle | descendant of UploadStreamHandle specifying the stream |
buffer | the CharBuffer to be uploaded to the stream |
callback | callback to be called on completion |
Implemented in upload::GatewayUploader, upload::S3Uploader, and upload::LocalUploader.
Referenced by upload::TaskUpload::Process().
void upload::AbstractUploader::TearDown | ( | ) |
This must be called right before the destruction of the AbstractUploader! You are not supposed to overwrite this method in your concrete Uploader.
Definition at line 97 of file upload_facility.cc.
|
inline |
Uploads the file at the path local_path into the backend storage under the path remote_path. When the upload has finished it calls callback. Note: This method might be implemented in a synchronous way.
local_path | path to the file to be uploaded |
remote_path | desired path for the file in the backend storage |
callback | (optional) gets notified when the upload was finished |
Definition at line 194 of file upload_facility.h.
Referenced by StatisticsDatabase::UploadStatistics().
|
inline |
|
virtual |
Waits until the current upload queue is empty.
Note: This does NOT necessarily mean, that all files are actually uploaded. If new jobs are concurrently scheduled the behavior of this method is not defined (it returns also on intermediately empty queues)
Reimplemented in upload::GatewayUploader.
Definition at line 101 of file upload_facility.cc.
Referenced by StatisticsDatabase::UploadStatistics().
|
friend |
Definition at line 87 of file upload_facility.h.
Referenced by Initialize().
|
mutableprivate |
Definition at line 438 of file upload_facility.h.
Referenced by CountDuplicates(), CountUploadedBytes(), CountUploadedCatalogBytes(), CountUploadedCatalogs(), CountUploadedChunks(), DecUploadedChunks(), and InitCounters().
|
mutableprivate |
Definition at line 435 of file upload_facility.h.
Referenced by IncJobsInFlight(), RemoveAsync(), Respond(), ScheduleCommit(), ScheduleUpload(), UploadFile(), UploadIngestionSource(), and WaitForUpload().
|
private |
Number of threads used for I/O write calls. Effectively this parameter sets the I/O depth. Defaults to 1.
Definition at line 434 of file upload_facility.h.
Referenced by GetNumTasks().
|
private |
Definition at line 428 of file upload_facility.h.
Referenced by CreateAndOpenTemporaryChunkFile(), and spooler_definition().
|
private |
Definition at line 437 of file upload_facility.h.
Referenced by Initialize(), TearDown(), and ~AbstractUploader().
Definition at line 436 of file upload_facility.h.
Referenced by Initialize(), ScheduleCommit(), and ScheduleUpload().