11 #include <boost/tokenizer.hpp>
24 if (logical_name.empty() || logical_name.find(
'/') != std::string::npos)
28 if (logical_name.empty())
30 std::cout <<
"FROG: empty string as filename" << std::endl;
32 else if (logical_name.find(
'/') != std::string::npos)
34 std::cout <<
"FROG: found / in filename, assuming it contains a full path" << std::endl;
41 char *gsearchpath_env = getenv(
"GSEARCHPATH");
42 if (gsearchpath_env ==
nullptr)
49 std::cout <<
"FROG: GSEARCHPATH: " << gsearchpath << std::endl;
51 boost::char_separator<char> sep(
":");
52 boost::tokenizer<boost::char_separator<char> > tok(gsearchpath, sep);
53 for (
auto &iter : tok)
59 std::cout <<
"Searching FileCatalog for disk resident file "
60 << logical_name << std::endl;
66 std::cout <<
"Found " << logical_name <<
" in FileCatalog, returning "
72 else if (iter ==
"DCACHE")
76 std::cout <<
"Searching FileCatalog for dCache file "
77 << logical_name << std::endl;
83 std::cout <<
"Found " << logical_name <<
" in dCache, returning "
89 else if (iter ==
"XROOTD")
93 std::cout <<
"Searching FileCatalog for XRootD file "
94 << logical_name << std::endl;
100 std::cout <<
"Found " << logical_name <<
" in XRootD, returning "
106 else if (iter ==
"LUSTRE")
110 std::cout <<
"Searching FileCatalog for Lustre file "
111 << logical_name << std::endl;
117 std::cout <<
"Found " << logical_name <<
" in Lustre, returning "
123 else if (iter ==
"MINIO")
127 std::cout <<
"Searching FileCatalog for Lustre file via MinIO "
128 << logical_name << std::endl;
134 std::cout <<
"Found " << logical_name <<
" in Lustre, returning MinIO URL "
144 std::cout <<
"Trying path " << iter << std::endl;
158 std::cout <<
"FROG: GSEARCHPATH not set " << std::endl;
167 if (std::ifstream(logical_name))
192 <<
" Exception caught during DriverManager::getConnection" << std::endl;
193 std::cout <<
"Message: " << e.
getMessage() << std::endl;
196 std::this_thread::sleep_for(std::chrono::seconds(30));
197 }
while (icount < 5);
214 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name <> 'hpss' and full_host_name <> 'dcache' and full_host_name <> 'lustre'";
218 std::cout <<
"sql query:" << std::endl
219 << sqlquery << std::endl;
241 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'dcache'";
245 std::cout <<
"sql query:" << std::endl
246 << sqlquery << std::endl;
254 if (std::ifstream(dcachefile))
256 pfn =
"dcache:" + dcachefile;
272 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'lustre'";
275 std::cout <<
"sql query:" << std::endl
276 << sqlquery << std::endl;
284 pfn =
"root://xrdsphenix.rcf.bnl.gov/" + xrootdfile;
299 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'lustre'";
321 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'lustre'";
325 std::cout <<
"sql query:" << std::endl
326 << sqlquery << std::endl;
334 std::string toreplace(
"/sphenix/lustre01/sphnxpro");
335 size_t strpos =
pfn.find(toreplace);
336 if (strpos == std::string::npos)
338 std::cout <<
" could not locate " << toreplace
339 <<
" in full file path " <<
pfn << std::endl;
344 std::cout <<
"full file path " <<
pfn
345 <<
"does not start with " << toreplace << std::endl;
349 pfn.replace(
pfn.begin(),
pfn.begin()+toreplace.size(),
"s3://sphenixs3.rcf.bnl.gov:9000");