Utilities
StorageFactory
plugins
StormStorageMaker.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
StormStorageMaker
:
public
StorageMaker
{
13
/* getTURL: Executes a prepare to get script and extracts the physical file path */
14
std::string
getTURL
(
const
std::string
&surl)
const
{
15
std::string
client
;
16
if
(
char
*
p
= std::getenv(
"CMS_STORM_PTG_CLIENT"
))
17
client
=
p
;
18
else
19
throw
cms::Exception
(
"StormStorageMaker"
) <<
"$CMS_STORM_PTG_CLIENT has no value"
;
20
21
// Command
22
std::string
comm(
client
+
" srm:"
+ surl +
" 2>&1"
);
23
LogDebug
(
"StormStorageMaker"
) <<
"command: "
<< comm << std::endl;
24
25
FILE *
pipe
= popen(comm.c_str(),
"r"
);
26
if
(!
pipe
)
27
throw
cms::Exception
(
"StormStorageMaker"
) <<
"failed to execute PtG command: "
<< comm;
28
29
// Get output
30
int
ch;
31
std::string
output
;
32
while
((ch = getc(
pipe
)) != EOF)
33
output
.push_back(ch);
34
pclose(
pipe
);
35
36
LogDebug
(
"StormStorageMaker"
) <<
"output: "
<<
output
<< std::endl;
37
38
// Extract TURL if possible.
39
size_t
start
=
output
.find(
"FilePath:"
, 0);
40
if
(
start
== std::string::npos)
41
throw
cms::Exception
(
"StormStorageMaker"
) <<
"no turl found in command '"
<< comm <<
"' output:\n"
<<
output
;
42
43
start
+= 9;
44
std::string
turl(
output
,
start
,
output
.find_first_of(
"\n"
,
start
) -
start
);
45
LogDebug
(
"StormStorageMaker"
) <<
"file to open: "
<< turl << std::endl;
46
return
turl;
47
}
48
49
public
:
50
std::unique_ptr<Storage>
open
(
const
std::string
&proto,
51
const
std::string
&surl,
52
int
mode
,
53
const
AuxSettings
&)
const override
{
54
const
StorageFactory
*
f
=
StorageFactory::get
();
55
StorageFactory::ReadHint
readHint =
f
->readHint();
56
StorageFactory::CacheHint
cacheHint =
f
->cacheHint();
57
58
if
(readHint !=
StorageFactory::READ_HINT_UNBUFFERED
|| cacheHint ==
StorageFactory::CACHE_HINT_STORAGE
)
59
mode
&= ~
IOFlags
::OpenUnbuffered
;
60
else
61
mode
|=
IOFlags::OpenUnbuffered
;
62
63
std::string
path
=
getTURL
(surl);
64
auto
file
= std::make_unique<File>(
path
,
mode
);
65
return
f
->wrapNonLocalFile(
std::move
(
file
), proto,
path
,
mode
);
66
}
67
68
bool
check
(
const
std::string
&
/*proto*/
,
69
const
std::string
&
path
,
70
const
AuxSettings
&,
71
IOOffset
*
size
=
nullptr
)
const override
{
72
struct
stat
st;
73
if
(
stat
(
getTURL
(
path
).c_str(), &st) != 0)
74
return
false
;
75
76
if
(
size
)
77
*
size
= st.st_size;
78
79
return
true
;
80
}
81
};
82
83
DEFINE_EDM_PLUGIN
(
StorageMakerFactory
,
StormStorageMaker
,
"storm"
);
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
EDMException.h
hgcalPlots.stat
stat
Definition:
hgcalPlots.py:1111
HLTObjectMonitor_Client_cff.client
client
Definition:
HLTObjectMonitor_Client_cff.py:6
StorageFactory::get
static const StorageFactory * get(void)
Definition:
StorageFactory.cc:26
StorageMaker.h
StormStorageMaker::check
bool check(const std::string &, const std::string &path, const AuxSettings &, IOOffset *size=nullptr) const override
Definition:
StormStorageMaker.cc:68
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
StormStorageMaker::getTURL
std::string getTURL(const std::string &surl) const
Definition:
StormStorageMaker.cc:14
IOFlags
Definition:
IOFlags.h:4
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:670
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
StorageFactory
Definition:
StorageFactory.h:13
StorageMakerFactory.h
StormStorageMaker::open
std::unique_ptr< Storage > open(const std::string &proto, const std::string &surl, int mode, const AuxSettings &) const override
Definition:
StormStorageMaker.cc:50
eostools.move
def move(src, dest)
Definition:
eostools.py:511
Exception
Definition:
hltDiff.cc:246
StormStorageMaker
Definition:
StormStorageMaker.cc:12
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
Generated for CMSSW Reference Manual by
1.8.16