CMS 3D CMS Logo

StormLCGStorageMaker.cc
Go to the documentation of this file.
1 #define ML_DEBUG 1
8 #include <cstdlib>
9 #include <cstdio>
10 #include <sys/stat.h>
11 
13  /* getTURL: Executes lcg-gt and extracts the physical file path */
14  std::string getTURL(const std::string &surl) const {
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  }
50 
51 public:
52  std::unique_ptr<Storage> open(const std::string &proto,
53  const std::string &surl,
54  int mode,
55  const AuxSettings &) const override {
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  }
69 
70  bool check(const std::string & /*proto*/,
71  const std::string &path,
72  const AuxSettings &,
73  IOOffset *size = nullptr) const override {
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  }
83 };
84 
start
Definition: start.py:1
MessageLogger.h
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
StorageFactory::CacheHint
CacheHint
Definition: StorageFactory.h:15
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
StorageFactory::READ_HINT_UNBUFFERED
Definition: StorageFactory.h:17
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
StorageMaker
Definition: StorageMaker.h:9
StormLcgGtStorageMaker::getTURL
std::string getTURL(const std::string &surl) const
Definition: StormLCGStorageMaker.cc:14
EDMException.h
StormLcgGtStorageMaker::open
std::unique_ptr< Storage > open(const std::string &proto, const std::string &surl, int mode, const AuxSettings &) const override
Definition: StormLCGStorageMaker.cc:52
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1111
StorageFactory::get
static const StorageFactory * get(void)
Definition: StorageFactory.cc:26
StorageMaker.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
pipe
Definition: pipe.py:1
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IOFlags
Definition: IOFlags.h:4
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
mps_check.timeout
int timeout
Definition: mps_check.py:53
edmplugin::PluginFactory
Definition: PluginFactory.h:34
IOOffset
int64_t IOOffset
Definition: IOTypes.h:19
StorageFactory.h
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
timeout
Definition: timeout.py:1
StorageFactory
Definition: StorageFactory.h:13
StormLcgGtStorageMaker
Definition: StormLCGStorageMaker.cc:12
StorageMakerFactory.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
StormLcgGtStorageMaker::check
bool check(const std::string &, const std::string &path, const AuxSettings &, IOOffset *size=nullptr) const override
Definition: StormLCGStorageMaker.cc:70
Exception
Definition: hltDiff.cc:246
IOFlags::OpenUnbuffered
Definition: IOFlags.h:20
StorageFactory::CACHE_HINT_STORAGE
Definition: StorageFactory.h:15
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
StorageFactory::ReadHint
ReadHint
Definition: StorageFactory.h:17
command_line.start
start
Definition: command_line.py:167
StorageMaker::AuxSettings
Definition: StorageMaker.h:11
File.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443