Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
art::detail::FileServiceProxy Class Reference

#include <FileServiceProxy.h>

Classes

struct  FileEntity
 

Public Member Functions

 FileServiceProxy (std::vector< std::string > &&fileNames, size_t attempts=5, double waitBetweenAttempts=5.0)
 
 ~FileServiceProxy ()
 
std::string next ()
 
void finish ()
 

Private Member Functions

std::string obtainURI_ ()
 
std::string obtainFileFromURI_ ()
 

Private Attributes

ServiceHandle< CatalogInterfaceci_ {}
 
ServiceHandle< FileTransferft_ {}
 
struct art::detail::FileServiceProxy::FileEntity currentItem_
 
size_t const attemptsPerPhase_
 
double const waitBetweenAttempts_
 

Detailed Description

Definition at line 17 of file FileServiceProxy.h.

Constructor & Destructor Documentation

art::detail::FileServiceProxy::FileServiceProxy ( std::vector< std::string > &&  fileNames,
size_t  attempts = 5,
double  waitBetweenAttempts = 5.0 
)
explicit

Definition at line 4 of file FileServiceProxy.cc.

8  : currentItem_{attempts}
9  , attemptsPerPhase_{attempts}
10  , waitBetweenAttempts_{waitBetweenAttempts}
11 {
12  ci_->configure(std::move(fileNames));
13 }
def move(depos, offset)
Definition: depos.py:107
struct art::detail::FileServiceProxy::FileEntity currentItem_
ServiceHandle< CatalogInterface > ci_
art::detail::FileServiceProxy::~FileServiceProxy ( )

Definition at line 15 of file FileServiceProxy.cc.

Member Function Documentation

void art::detail::FileServiceProxy::finish ( )

Definition at line 27 of file FileServiceProxy.cc.

28 {
30  // File is complete.
32  }
33  currentItem_ = FileEntity(attemptsPerPhase_);
34 }
struct art::detail::FileServiceProxy::FileEntity currentItem_
ServiceHandle< CatalogInterface > ci_
std::string art::detail::FileServiceProxy::next ( )
inline

Definition at line 48 of file FileServiceProxy.h.

49 {
50  finish();
51  return obtainURI_();
52 }
std::string art::detail::FileServiceProxy::obtainFileFromURI_ ( )
private

Definition at line 70 of file FileServiceProxy.cc.

71 {
73  switch (currentItem_.ftStatus) {
75  sleep(waitBetweenAttempts_);
76  [[fallthrough]];
80  << "Unable to obtain URI " << currentItem_.uri
81  << " from FileTransfer service after " << attemptsPerPhase_
82  << " attempts.\n";
83  }
85  ft_->translateToLocalFilename(currentItem_.uri, currentItem_.pfn));
86  return obtainFileFromURI_();
89  return currentItem_.pfn; // Done.
90  default:
92  << "FileTransfer service returned failure code "
94  << static_cast<int>(currentItem_.ftStatus) << ") for URI "
95  << currentItem_.uri << ".\n";
96  }
97 }
ServiceHandle< FileTransfer > ft_
std::string translateFileTransferStatus(FileTransferStatus stat)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
struct art::detail::FileServiceProxy::FileEntity currentItem_
ServiceHandle< CatalogInterface > ci_
std::string art::detail::FileServiceProxy::obtainURI_ ( )
private

Definition at line 37 of file FileServiceProxy.cc.

38 {
39  double wait = 0.0;
40  switch (currentItem_.uriStatus) {
42  [[fallthrough]];
44  wait = waitBetweenAttempts_;
45  [[fallthrough]];
49  << "Unable to obtain URI from CatalogInterface service after "
50  << attemptsPerPhase_ << " attempts.\n";
51  }
53  ci_->getNextFileURI(currentItem_.uri, wait));
54  return obtainURI_();
57  return obtainFileFromURI_();
58  break;
60  return std::string(); // Done.
61  default:
63  << "CatalogInterface service returned failure code "
65  << static_cast<int>(currentItem_.uriStatus) << ").\n";
66  }
67 }
void wait(std::chrono::milliseconds dur)
std::string string
Definition: nybbler.cc:12
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_

Member Data Documentation

size_t const art::detail::FileServiceProxy::attemptsPerPhase_
private

Definition at line 43 of file FileServiceProxy.h.

ServiceHandle<CatalogInterface> art::detail::FileServiceProxy::ci_ {}
private

Definition at line 31 of file FileServiceProxy.h.

struct art::detail::FileServiceProxy::FileEntity art::detail::FileServiceProxy::currentItem_
private
ServiceHandle<FileTransfer> art::detail::FileServiceProxy::ft_ {}
private

Definition at line 32 of file FileServiceProxy.h.

double const art::detail::FileServiceProxy::waitBetweenAttempts_
private

Definition at line 44 of file FileServiceProxy.h.


The documentation for this class was generated from the following files: