CernVM-FS  2.12.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[] =
15  {"S3", "local", "gw", "mock", "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 && (min_file_chunk_size >= avg_file_chunk_size ||
43  avg_file_chunk_size >= max_file_chunk_size)) {
44  LogCvmfs(kLogSpooler, kLogStderr, "file chunk size values are not sane");
45  return;
46  }
47 
48  // split the spooler driver definition into name and config part
49  std::vector<std::string> upstream = SplitString(definition_string, ',');
50  if (upstream.size() != 3) {
51  LogCvmfs(kLogSpooler, kLogStderr, "Invalid spooler driver");
52  return;
53  }
54 
55  // recognize and configure the spooler driver
56  if (upstream[0] == "local") {
58  } else if (upstream[0] == "S3") {
59  driver_type = S3;
60  } else if (upstream[0] == "gw") {
62  } else if (upstream[0] == "mock") {
63  driver_type = Mock; // for unit testing purpose only!
64  } else {
66  LogCvmfs(kLogSpooler, kLogStderr, "unknown spooler driver: %s",
67  upstream[0].c_str());
68  return;
69  }
70 
71  // save data
72  temporary_path = upstream[1];
73  spooler_configuration = upstream[2];
74  valid_ = true;
75 }
76 
78  SpoolerDefinition result(*this);
80  return result;
81 }
82 
83 } // 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:290
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:528