5 #include <odbc++/connection.h>
6 #include <odbc++/drivermanager.h>
7 #include <odbc++/resultset.h>
8 #include <odbc++/statement.h>
9 #include <odbc++/types.h>
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 std::string gsearchpath(getenv(
"GSEARCHPATH"));
44 std::cout <<
"FROG: GSEARCHPATH: " << gsearchpath << std::endl;
46 boost::char_separator<char> sep(
":");
47 boost::tokenizer<boost::char_separator<char> > tok(gsearchpath, sep);
48 for (
auto &iter : tok)
54 std::cout <<
"Searching FileCatalog for disk resident file "
55 << logical_name << std::endl;
61 std::cout <<
"Found " << logical_name <<
" in FileCatalog, returning "
67 else if (iter ==
"DCACHE")
71 std::cout <<
"Searching FileCatalog for dCache file "
72 << logical_name << std::endl;
78 std::cout <<
"Found " << logical_name <<
" in dCache, returning "
84 else if (iter ==
"XROOTD")
88 std::cout <<
"Searching FileCatalog for XRootD file "
89 << logical_name << std::endl;
95 std::cout <<
"Found " << logical_name <<
" in XRootD, returning "
101 else if (iter ==
"LUSTRE")
105 std::cout <<
"Searching FileCatalog for Lustre file "
106 << logical_name << std::endl;
112 std::cout <<
"Found " << logical_name <<
" in Lustre, returning "
118 else if (iter ==
"MINIO")
122 std::cout <<
"Searching FileCatalog for Lustre file via MinIO"
123 << logical_name << std::endl;
129 std::cout <<
"Found " << logical_name <<
" in Lustre, returning MinIO URL "
139 std::cout <<
"Trying path " << iter << std::endl;
141 std::string fullfile = iter +
"/" + logical_name;
153 std::cout <<
"FROG: GSEARCHPATH not set " << std::endl;
162 if (std::ifstream(logical_name))
181 m_OdbcConnection = odbc::DriverManager::getConnection(
"FileCatalog",
"argouser",
"Brass_Ring");
184 catch (odbc::SQLException &
e)
187 <<
" Exception caught during DriverManager::getConnection" << std::endl;
188 std::cout <<
"Message: " << e.getMessage() << std::endl;
191 std::this_thread::sleep_for(std::chrono::seconds(30));
192 }
while (icount < 5);
209 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'";
212 odbc::ResultSet *rs = stmt->executeQuery(sqlquery);
216 pfn = rs->getString(1);
231 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'dcache'";
234 odbc::ResultSet *rs = stmt->executeQuery(sqlquery);
238 std::string dcachefile = rs->getString(1);
239 if (std::ifstream(dcachefile))
241 pfn =
"dcache:" + dcachefile;
257 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'dcache'";
260 odbc::ResultSet *rs = stmt->executeQuery(sqlquery);
264 std::string xrootdfile = rs->getString(1);
265 if (std::ifstream(xrootdfile))
267 pfn =
"root://dcsphdoor02.rcf.bnl.gov:1095" + xrootdfile;
283 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'lustre'";
286 odbc::ResultSet *rs = stmt->executeQuery(sqlquery);
290 pfn = rs->getString(1);
305 std::string sqlquery =
"SELECT full_file_path from files where lfn='" + lname +
"' and full_host_name = 'lustre'";
308 odbc::ResultSet *rs = stmt->executeQuery(sqlquery);
312 pfn = rs->getString(1);
313 std::string toreplace(
"/sphenix/lustre01/sphnxpro");
314 size_t strpos =
pfn.find(toreplace);
315 if (strpos == std::string::npos)
317 std::cout <<
" could not locate " << toreplace
318 <<
" in full file path " <<
pfn << std::endl;
323 std::cout <<
"full file path " <<
pfn
324 <<
"does not start with " << toreplace << std::endl;
328 pfn.replace(
pfn.begin(),
pfn.begin()+toreplace.size(),
"s3://dcsphst004.rcf.bnl.gov:9000");