CernVM-FS  2.13.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog_downloader.cc
Go to the documentation of this file.
1 #include "catalog_downloader.h"
2 
4 
5 CatalogItem::CatalogItem(const shash::Any &hash) : hash_(hash) {}
6 
8  std::string const catalog_path;
9  shash::Any const catalog_hash;
10  // will PANIC if download failed
11  //catalog_mgr_->LoadCatalog(PathString("") /* not used */, *input->GetHash(), &catalog_path, &catalog_hash, NULL);
12  catalog::CatalogContext context(*input->GetHash(), PathString(catalog_path));
14  NotifyListeners(CatalogDownloadResult(catalog_path, input->GetHash()->ToString()));
15  tube_counter_->PopFront(); // pop after calling callback as callback could enqueue additional items
16 }
17 
19  catalog::SimpleCatalogManager *catalog_mgr)
20  : spawned_(false)
21  , catalog_mgr_(catalog_mgr)
22 {
23  const unsigned int nfork_base = 1;
24 
25  // spawn a bit more workers as this is just download task
26  for (unsigned i = 0; i < nfork_base * kCatalogDownloadMultiplier; ++i) {
27  TaskCatalogDownload *task =
31  }
32 }
33 
35  if (spawned_) {
37  }
38 }
39 
41  const CatalogDownloadResult &catalog_download_result)
42 {
43  NotifyListeners(catalog_download_result);
44 }
45 
47  const shash::Any &catalog_hash)
48 {
49  CatalogItem *catalog_item = new CatalogItem(catalog_hash);
50  tube_counter_.EnqueueBack(catalog_item);
51  tube_input_.EnqueueBack(catalog_item);
52 }
53 
56  spawned_ = true;
57 }
58 
61 }
CallbackPtr RegisterListener(typename BoundClosure< ParamT, DelegateT, ClosureDataT >::CallbackMethod method, DelegateT *delegate, ClosureDataT data)
void Wait()
Definition: tube.h:158
catalog::SimpleCatalogManager * catalog_mgr_
void TakeConsumer(TubeConsumer< ItemT > *consumer)
Definition: task.h:74
std::string ToString(const bool with_suffix=false) const
Definition: hash.h:241
virtual LoadReturn LoadCatalogByHash(CatalogContext *ctlg_context)
int kCatalogDownloadMultiplier
void NotifyListeners(const CatalogDownloadResult &parameter)
void Process(const shash::Any &catalog_hash)
virtual void Process(CatalogItem *input_hash)
Tube< CatalogItem > * tube_counter_
ItemT * PopFront()
Definition: tube.h:122
catalog::WritableCatalogManager * catalog_mgr_
Definition: repository.h:384
Tube< CatalogItem > tube_counter_
Tube< CatalogItem > tube_input_
CatalogItem(const shash::Any &hash)
void Spawn()
Definition: task.h:79
Link * EnqueueBack(ItemT *item)
Definition: tube.h:72
void OnFileProcessed(const CatalogDownloadResult &catalog_download_result)
CatalogDownloadPipeline(catalog::SimpleCatalogManager *catalog_mgr)
TubeConsumerGroup< CatalogItem > tasks_download_
ShortString< kDefaultMaxPath, 0 > PathString
Definition: shortstring.h:213
shash::Any * GetHash()
catalog::SimpleCatalogManager * catalog_mgr_
void Terminate()
Definition: task.h:94