LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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.

References attemptsPerPhase_, ci_, and waitBetweenAttempts_.

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

Member Function Documentation

void art::detail::FileServiceProxy::finish ( )
std::string art::detail::FileServiceProxy::next ( )
inline

Definition at line 48 of file FileServiceProxy.h.

References finish(), and obtainURI_().

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

Definition at line 70 of file FileServiceProxy.cc.

References attemptsPerPhase_, art::detail::FileServiceProxy::FileEntity::attemptsRemaining, art::errors::CatalogServiceError, ci_, currentItem_, ft_, art::detail::FileServiceProxy::FileEntity::ftStatus, art::PENDING, art::detail::FileServiceProxy::FileEntity::pfn, art::SUCCESS, art::TRANSFERRED, art::translateFileTransferStatus(), art::detail::FDS::UNAVAILABLE, art::detail::FileServiceProxy::FileEntity::uri, art::detail::FileServiceProxy::FileEntity::uriStatus, and waitBetweenAttempts_.

Referenced by obtainURI_().

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.

References attemptsPerPhase_, art::detail::FileServiceProxy::FileEntity::attemptsRemaining, art::errors::CatalogServiceError, ci_, currentItem_, art::NO_MORE_FILES, obtainFileFromURI_(), art::PENDING, art::SUCCESS, art::translateFileDeliveryStatus(), art::detail::FDS::TRY_AGAIN_LATER, art::detail::FDS::UNAVAILABLE, art::detail::FileServiceProxy::FileEntity::uri, art::detail::FileServiceProxy::FileEntity::uriStatus, and waitBetweenAttempts_.

Referenced by next().

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 }
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.

Referenced by FileServiceProxy(), finish(), obtainFileFromURI_(), and obtainURI_().

ServiceHandle<CatalogInterface> art::detail::FileServiceProxy::ci_ {}
private
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.

Referenced by obtainFileFromURI_().

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

Definition at line 44 of file FileServiceProxy.h.

Referenced by FileServiceProxy(), obtainFileFromURI_(), and obtainURI_().


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