Utilities
StorageFactory
plugins
StormLCGStorageMaker.cc
Go to the documentation of this file.
1
#define ML_DEBUG 1
2
#include "
Utilities/StorageFactory/interface/StorageMaker.h
"
3
#include "
Utilities/StorageFactory/interface/StorageMakerFactory.h
"
4
#include "
Utilities/StorageFactory/interface/StorageFactory.h
"
5
#include "
Utilities/StorageFactory/interface/File.h
"
6
#include "
FWCore/Utilities/interface/EDMException.h
"
7
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
8
#include <cstdlib>
9
#include <cstdio>
10
#include <sys/stat.h>
11
12
class
StormLcgGtStorageMaker
:
public
StorageMaker
{
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;
33
std::string
output
;
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
{
56
const
StorageFactory
*
f
=
StorageFactory::get
();
57
StorageFactory::ReadHint
readHint =
f
->readHint();
58
StorageFactory::CacheHint
cacheHint =
f
->cacheHint();
59
60
if
(readHint !=
StorageFactory::READ_HINT_UNBUFFERED
|| cacheHint ==
StorageFactory::CACHE_HINT_STORAGE
)
61
mode
&= ~
IOFlags
::OpenUnbuffered
;
62
else
63
mode
|=
IOFlags::OpenUnbuffered
;
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
85
DEFINE_EDM_PLUGIN
(
StorageMakerFactory
,
StormLcgGtStorageMaker
,
"storm-lcg"
);
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:72
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
StorageFactory::get
static const StorageFactory * get(void)
Definition:
StorageFactory.cc:28
StorageMaker.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition:
PluginFactory.h:124
pipe
Definition:
pipe.py:1
geometryDiff.file
file
Definition:
geometryDiff.py:13
IOFlags
Definition:
IOFlags.h:4
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:233
AlCaHLTBitMon_ParallelJobs.p
def p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
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
timeout
Definition:
timeout.py:1
StorageFactory
Definition:
StorageFactory.h:13
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
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:245
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
edm_modernize_messagelogger.stat
stat
Definition:
edm_modernize_messagelogger.py:27
StorageMaker::AuxSettings
Definition:
StorageMaker.h:11
File.h
findQualityFiles.size
size
Write out results.
Definition:
findQualityFiles.py:443
Generated for CMSSW Reference Manual by
1.8.16