CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
StormLcgGtStorageMaker Class Reference
Inheritance diagram for StormLcgGtStorageMaker:
StorageMaker

Public Member Functions

bool check (const std::string &, const std::string &path, const AuxSettings &, IOOffset *size=0) const override
 
std::unique_ptr< Storageopen (const std::string &proto, const std::string &surl, int mode, const AuxSettings &) const override
 
- Public Member Functions inherited from StorageMaker
virtual void stagein (const std::string &proto, const std::string &path, const AuxSettings &aux) const
 
 StorageMaker ()=default
 
virtual ~StorageMaker ()=default
 

Private Member Functions

std::string getTURL (const std::string &surl) const
 

Detailed Description

Definition at line 12 of file StormLCGStorageMaker.cc.

Member Function Documentation

bool StormLcgGtStorageMaker::check ( const std::string &  ,
const std::string &  path,
const AuxSettings ,
IOOffset size = 0 
) const
inlineoverridevirtual

Reimplemented from StorageMaker.

Definition at line 70 of file StormLCGStorageMaker.cc.

References DEFINE_EDM_PLUGIN, getTURL(), findQualityFiles::size, and hgcalPlots::stat.

73  {
74  struct stat st;
75  if (stat(getTURL(path).c_str(), &st) != 0)
76  return false;
77 
78  if (size)
79  *size = st.st_size;
80 
81  return true;
82  }
size
Write out results.
std::string getTURL(const std::string &surl) const
std::string StormLcgGtStorageMaker::getTURL ( const std::string &  surl) const
inlineprivate

Definition at line 14 of file StormLCGStorageMaker.cc.

References Exception, LogDebug, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, command_line::start, AlCaHLTBitMon_QueryRunRegistry::string, and mps_check::timeout.

Referenced by check(), and open().

14  {
15  // PrepareToGet timeout
16  std::string timeout("300");
17  if (char *p = std::getenv("CMS_STORM_LCG_GT_TIMEOUT"))
18  timeout = p;
19 
20  /* Build the command line:
21  -b => no BDII contacted
22  -T srmv2 => necessary with -b
23  -t timeout */
24  std::string comm("lcg-gt -b -T srmv2 -t " + timeout + " srm:" + surl + " file 2>&1");
25  LogDebug("StormLCGStorageMaker") << "command: " << comm << std::endl;
26 
27  FILE *pipe = popen(comm.c_str(), "r");
28  if (!pipe)
29  throw cms::Exception("StormLCGStorageMaker") << "failed to execute lcg-gt command: " << comm;
30 
31  // Get output
32  int ch;
34  while ((ch = getc(pipe)) != EOF)
35  output.push_back(ch);
36  pclose(pipe);
37 
38  LogDebug("StormLCGStorageMaker") << "output: " << output << std::endl;
39 
40  // Extract TURL if possible.
41  size_t start = output.find("file:", 0);
42  if (start == std::string::npos)
43  throw cms::Exception("StormLCGStorageMaker") << "no turl found in command '" << comm << "' output:\n" << output;
44 
45  start += 5;
46  std::string turl(output, start, output.find_first_of("\n", start) - start);
47  LogDebug("StormLCGStorageMaker") << "file to open: " << turl << std::endl;
48  return turl;
49  }
#define LogDebug(id)
Definition: start.py:1
int timeout
Definition: mps_check.py:53
Definition: pipe.py:1
std::unique_ptr<Storage> StormLcgGtStorageMaker::open ( const std::string &  proto,
const std::string &  surl,
int  mode,
const AuxSettings  
) const
inlineoverridevirtual

Implements StorageMaker.

Definition at line 52 of file StormLCGStorageMaker.cc.

References StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), f, FrontierConditions_GlobalTag_cff::file, StorageFactory::get(), getTURL(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, eostools::move(), IOFlags::OpenUnbuffered, castor_dqm_sourceclient_file_cfg::path, StorageFactory::READ_HINT_UNBUFFERED, StorageFactory::readHint(), AlCaHLTBitMon_QueryRunRegistry::string, and StorageFactory::wrapNonLocalFile().

55  {
57  StorageFactory::ReadHint readHint = f->readHint();
58  StorageFactory::CacheHint cacheHint = f->cacheHint();
59 
62  else
64 
65  std::string path = getTURL(surl);
66  auto file = std::make_unique<File>(path, mode);
67  return f->wrapNonLocalFile(std::move(file), proto, path, mode);
68  }
CacheHint cacheHint(void) const
std::unique_ptr< Storage > wrapNonLocalFile(std::unique_ptr< Storage > s, const std::string &proto, const std::string &path, int mode) const
Definition: IOFlags.h:4
static const StorageFactory * get(void)
double f[11][100]
ReadHint readHint(void) const
def move(src, dest)
Definition: eostools.py:511
std::string getTURL(const std::string &surl) const