IFCatalogInterface_service.cc
Go to the documentation of this file.
7 
9 
10 namespace ifdh_ns {
11 
12 
14  _process_id(""),
15  _proj_uri(""),
16  _project_name(""),
17  _sam_station(""),
18  _last_file_uri("")
19 {
20  std::vector<std::string> cfgkeys = cfg.get_names();
21  std::string s;
22 
23  mf::LogVerbatim("test") << "IFCatalogInterface constructor, got keys:";
24  for (std::vector<std::string>::iterator p = cfgkeys.begin(); p != cfgkeys.end(
25  ); p++ ) {
26  mf::LogVerbatim("test")<< *p << ", ";
27  }
28 
29  if ( cfg.get_if_present("webURI", s) ) {
30  mf::LogVerbatim("test") << "IFCatalogInterface: setting _proj_uri to:" << s << "\n";
31  _proj_uri = s;
32  }
33 }
34 
36  std::string process_status("completed");
37  mf::LogVerbatim("test") << "IFCatalogInterface destructor:";
38  if( _last_file_uri.length() ) {
39  mf::LogVerbatim("test") << "IFCatalogInterface: updating file status in destructor";
41  process_status = "bad";
42  }
43  if( _proj_uri.length() && _process_id.length() ) {
44  _ifdh_handle->setStatus(_proj_uri, _process_id, process_status);
45  }
46 }
47 
48 void
49 IFCatalogInterface::doConfigure(std::vector<std::string> const & item) {
50  if (item.size() ) {
51  _process_id = item[0];
52  mf::LogVerbatim("test") << "IFCatalogInterface doConfigure, got id:" << item[0];
53  }
54 }
55 
56 
57 int
58 IFCatalogInterface::doGetNextFileURI(std::string & uri, double & waitTime [[maybe_unused]]) {
59  mf::LogVerbatim("test") << "IFCatalogInterface entering doGetNextFile\n";
60  if ( _last_file_uri.length() ) {
61  mf::LogVerbatim("test") << "Updating status in doGetNextFile\n";
62  // XXX should this be art::FileDisposition::SKIPPED ???
63  // shouldn't we have updated the status already?
65  }
66  if ( _proj_uri.length()) {
67  uri = _ifdh_handle->getNextFile(_proj_uri,_process_id);
68  _last_file_uri = uri;
69  if (uri.length()) {
70  mf::LogVerbatim("test") << "doGetNextFile success\n";
72  } else {
73  mf::LogVerbatim("test") << "doGetNextFile no_more_files\n";
75  }
76  }
78 }
79 
80 void
82  static const char *statusmap[] = {
83  "transferred",
84  "consumed",
85  "skipped",
86  "consumed", /* INCOMPLETE */
87  };
88 
89  mf::LogVerbatim("test") << "IFCatalogInterface doUpdateStatus " << uri << " status: " << int(status) << "\n";
90 
91  if( _proj_uri.length()) {
92  _ifdh_handle->updateFileStatus(_proj_uri,_process_id,uri,statusmap[int(status)]);
93  if (status != art::FileDisposition::TRANSFERRED) {
94  int res = unlink(_ifdh_handle->localPath(_last_file_uri).c_str());
95  mf::LogVerbatim("test") << "unlink of file returns:" << res << "\n";
96  _last_file_uri = "";
97  }
98  }
99 }
100 
101 void
103  return;
104 }
105 
106 void
107 IFCatalogInterface::doOutputModuleInitiated(std::string const & module_label [[maybe_unused]],
108  fhicl::ParameterSet const & pset) {
109  std::string s;
110  bool ignore = false;
111  std::vector<std::string> cfgkeys = pset.get_names();
112  mf::LogVerbatim("test") << "IFCatalogInterface doOutputModuleInitiated, got keys:";
113  for (std::vector<std::string>::iterator p = cfgkeys.begin(); p != cfgkeys.end(
114  ); p++ ) {
115  mf::LogVerbatim("test")<< *p << ", ";
116  }
117 
118  if ( pset.get_if_present("fileName", s) ) {
119  _output_files.push_back(s);
120  }
121  if ( pset.get_if_present("sam_ignore", ignore) ) {
122  ;
123  }
124  _output_ignore.push_back(ignore);
125 }
126 
127 
128 void
130  std::string const & fileFQname) {
131  mf::LogVerbatim("test") << "IFCatalogInteface doOutputFileClosed: " << module_label << ", " << fileFQname << "\n";
132  return;
133 }
134 
135 void
137  art::EventID const &,
138  art::HLTGlobalStatus const &) {
139  ;
140 }
141 
142 bool
144  return 0;
145 }
146 
147 void
149  // throw NotImplemented;
150  ;
151 }
152 
153 }
154 
155 //DEFINE_ART_SERVICE(ifdh_ns::IFCatalogInterface);
intermediate_table::iterator iterator
virtual void doOutputModuleInitiated(std::string const &module_label, fhicl::ParameterSet const &pset)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
FileDisposition
std::string string
Definition: nybbler.cc:12
virtual int doGetNextFileURI(std::string &uri, double &waitTime)
IFCatalogInterface(const fhicl::ParameterSet &, art::ActivityRegistry &)
virtual void doOutputFileClosed(std::string const &module_label, std::string const &fileFQname)
virtual void doUpdateStatus(std::string const &uri, art::FileDisposition status)
virtual void doOutputFileOpened(std::string const &module_label)
p
Definition: test.py:223
virtual void doConfigure(std::vector< std::string > const &item)
art::ServiceHandle< IFDH > _ifdh_handle
virtual void doEventSelected(std::string const &module_label, art::EventID const &event_id, art::HLTGlobalStatus const &acceptance_info)
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:224
std::vector< std::string > get_names() const
static QCString * s
Definition: config.cpp:1042
std::vector< std::string > _output_files
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)