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

virtual bool check (const std::string &, const std::string &path, const AuxSettings &, IOOffset *size=0) const override
 
virtual 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

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

Reimplemented from StorageMaker.

Definition at line 78 of file StormLCGStorageMaker.cc.

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

82  {
83  struct stat st;
84  if (stat (getTURL(path).c_str(), &st) != 0)
85  return false;
86 
87  if (size)
88  *size = st.st_size;
89 
90  return true;
91  }
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 15 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().

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

62  {
64  StorageFactory::ReadHint readHint = f->readHint();
65  StorageFactory::CacheHint cacheHint = f->cacheHint();
66 
68  || cacheHint == StorageFactory::CACHE_HINT_STORAGE)
70  else
72 
73  std::string path = getTURL(surl);
74  auto file = std::make_unique<File> (path, mode);
75  return f->wrapNonLocalFile (std::move(file), proto, path, mode);
76  }
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:510
std::string getTURL(const std::string &surl) const