LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 20 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 ci_.

8  : ci_()
9  , ft_()
10  , currentItem_(attempts)
11  , attemptsPerPhase_(attempts)
12  , waitBetweenAttempts_(waitBetweenAttempts)
13 {
14  ci_->configure(std::move(fileNames));
15 }
ServiceHandle< FileTransfer > ft_
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 55 of file FileServiceProxy.h.

References finish(), and obtainURI_().

56 {
57  finish();
58  return obtainURI_();
59 }
std::string art::detail::FileServiceProxy::obtainFileFromURI_ ( )
private

Definition at line 72 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_().

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 }
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 39 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().

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 }
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 50 of file FileServiceProxy.h.

Referenced by 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 35 of file FileServiceProxy.h.

Referenced by obtainFileFromURI_().

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

Definition at line 51 of file FileServiceProxy.h.

Referenced by obtainFileFromURI_(), and obtainURI_().


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