CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
upload_spooler_definition.cc
Go to the documentation of this file.
1 
6 
7 #include <vector>
8 
9 #include "util/logging.h"
10 #include "util/string.h"
11 
12 namespace upload {
13 
14 const char *SpoolerDefinition::kDriverNames[] = {"S3", "local", "gw", "mock",
15  "unknown"};
16 
18  const std::string &definition_string,
19  const shash::Algorithms hash_algorithm,
20  const zlib::Algorithms compression_algorithm,
21  const bool generate_legacy_bulk_chunks,
22  const bool use_file_chunking,
23  const size_t min_file_chunk_size,
24  const size_t avg_file_chunk_size,
25  const size_t max_file_chunk_size,
26  const std::string &session_token_file,
27  const std::string &key_file)
28  : driver_type(Unknown)
29  , hash_algorithm(hash_algorithm)
30  , compression_alg(compression_algorithm)
31  , generate_legacy_bulk_chunks(generate_legacy_bulk_chunks)
32  , use_file_chunking(use_file_chunking)
33  , min_file_chunk_size(min_file_chunk_size)
34  , avg_file_chunk_size(avg_file_chunk_size)
35  , max_file_chunk_size(max_file_chunk_size)
36  , number_of_concurrent_uploads(kDefaultMaxConcurrentUploads)
37  , num_upload_tasks(kDefaultNumUploadTasks)
38  , session_token_file(session_token_file)
39  , key_file(key_file)
40  , valid_(false) {
41  // check if given file chunking values are sane
42  if (use_file_chunking
43  && (min_file_chunk_size >= avg_file_chunk_size
44  || avg_file_chunk_size >= max_file_chunk_size)) {
45  LogCvmfs(kLogSpooler, kLogStderr, "file chunk size values are not sane");
46  return;
47  }
48 
49  // split the spooler driver definition into name and config part
50  std::vector<std::string> upstream = SplitString(definition_string, ',');
51  if (upstream.size() != 3) {
52  LogCvmfs(kLogSpooler, kLogStderr, "Invalid spooler driver");
53  return;
54  }
55 
56  // recognize and configure the spooler driver
57  if (upstream[0] == "local") {
59  } else if (upstream[0] == "S3") {
60  driver_type = S3;
61  } else if (upstream[0] == "gw") {
63  } else if (upstream[0] == "mock") {
64  driver_type = Mock; // for unit testing purpose only!
65  } else {
67  LogCvmfs(kLogSpooler, kLogStderr, "unknown spooler driver: %s",
68  upstream[0].c_str());
69  return;
70  }
71 
72  // save data
73  temporary_path = upstream[1];
74  spooler_configuration = upstream[2];
75  valid_ = true;
76 }
77 
79  SpoolerDefinition result(*this);
81  return result;
82 }
83 
84 } // namespace upload
DriverType driver_type
the type of the spooler driver
SpoolerDefinition Dup2DefaultCompression() const
static const char * kDriverNames[]
corresponds to DriverType
Algorithms
Definition: hash.h:41
Algorithms
Definition: compression.h:44
SpoolerDefinition(const std::string &definition_string, const shash::Algorithms hash_algorithm, const zlib::Algorithms compression_algorithm=zlib::kZlibDefault, const bool generate_legacy_bulk_chunks=false, const bool use_file_chunking=false, const size_t min_file_chunk_size=0, const size_t avg_file_chunk_size=0, const size_t max_file_chunk_size=0, const std::string &session_token_file="", const std::string &key_file="")
vector< string > SplitString(const string &str, char delim)
Definition: string.cc:306
std::string temporary_path
scratch space for the IngestionPipeline
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)
Definition: logging.cc:545