LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
FileServiceProxy.cc
Go to the documentation of this file.
2 #include "cetlib/compiler_macros.h"
3 
5  std::vector<std::string>&& fileNames,
6  size_t attempts,
7  double waitBetweenAttempts)
8  : ci_()
9  , ft_()
10  , currentItem_(attempts)
11  , attemptsPerPhase_(attempts)
12  , waitBetweenAttempts_(waitBetweenAttempts)
13 {
14  ci_->configure(std::move(fileNames));
15 }
16 
18 {
19  if (!currentItem_.uri.empty()) {
22  } else {
24  }
25  }
26 }
27 
28 void
30 {
32  // File is complete.
34  }
36 }
37 
38 std::string
40 {
41  double wait = 0.0;
42  switch (currentItem_.uriStatus) {
44  FALLTHROUGH;
46  wait = waitBetweenAttempts_;
47  FALLTHROUGH;
51  << "Unable to obtain URI from CatalogInterface service after "
52  << attemptsPerPhase_ << " attempts.\n";
53  }
55  ci_->getNextFileURI(currentItem_.uri, wait));
56  return obtainURI_();
59  return obtainFileFromURI_();
60  break;
62  return std::string(); // Done.
63  default:
65  << "CatalogInterface service returned failure code "
67  << static_cast<int>(currentItem_.uriStatus) << ").\n";
68  }
69 }
70 
71 std::string
73 {
75  switch (currentItem_.ftStatus) {
77  sleep(waitBetweenAttempts_);
78  FALLTHROUGH;
82  << "Unable to obtain URI " << currentItem_.uri
83  << " from FileTransfer service after " << attemptsPerPhase_
84  << " attempts.\n";
85  }
87  ft_->translateToLocalFilename(currentItem_.uri, currentItem_.pfn));
88  return obtainFileFromURI_();
91  return currentItem_.pfn; // Done.
92  default:
94  << "FileTransfer service returned failure code "
96  << static_cast<int>(currentItem_.ftStatus) << ") for URI "
97  << currentItem_.uri << ".\n";
98  }
99 }
FileServiceProxy(std::vector< std::string > &&fileNames, size_t attempts=5, double waitBetweenAttempts=5.0)
ServiceHandle< FileTransfer > ft_
std::string translateFileTransferStatus(FileTransferStatus stat)
std::string translateFileDeliveryStatus(FileDeliveryStatus stat)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
struct art::detail::FileServiceProxy::FileEntity currentItem_
ServiceHandle< CatalogInterface > ci_