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
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);
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
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
136 IFCatalogInterface::doEventSelected(__attribute((unused)) std::string const & module_label,
137  __attribute((unused)) art::EventID const & event_id,
138  __attribute((unused)) art::HLTGlobalStatus const & acceptance_info) {
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);
virtual void doOutputModuleInitiated(std::string const &module_label, fhicl::ParameterSet const &pset)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
int status
Definition: fabricate.py:1613
IFDH interface (data handling)
FileDisposition
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)
const char * p
Definition: xmltok.h:285
virtual int doGetNextFileURI(std::string &uri, double &waitTime)
const XML_Char * s
Definition: expat.h:262
IFCatalogInterface(const fhicl::ParameterSet &, art::ActivityRegistry &)
virtual void doOutputFileClosed(std::string const &module_label, std::string const &fileFQname)
__attribute__((unused)) static std
virtual void doUpdateStatus(std::string const &uri, art::FileDisposition status)
virtual void doOutputFileOpened(std::string const &module_label)
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
std::vector< std::string > get_names() const
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)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const XML_Char const XML_Char * uri
Definition: expat.h:380
std::vector< std::string > _output_files