#include <Utilities/StorageFactory/interface/StorageFactory.h>
Public Types | |
enum | CacheHint { CACHE_HINT_APPLICATION, CACHE_HINT_STORAGE, CACHE_HINT_LAZY_DOWNLOAD, CACHE_HINT_AUTO_DETECT } |
enum | ReadHint { READ_HINT_UNBUFFERED, READ_HINT_READAHEAD, READ_HINT_AUTO } |
Public Member Functions | |
bool | accounting (void) const |
CacheHint | cacheHint (void) const |
bool | check (const std::string &url, IOOffset *size=0) |
bool | enableAccounting (bool enabled) |
Storage * | open (const std::string &url, int mode=IOFlags::OpenRead, const std::string &tmpdir="") |
ReadHint | readHint (void) const |
void | setCacheHint (CacheHint value) |
void | setReadHint (ReadHint value) |
void | setTempDir (const std::string &s) |
void | stagein (const std::string &url) |
std::string | tempDir (void) const |
~StorageFactory (void) | |
Static Public Member Functions | |
static StorageFactory * | get (void) |
Protected Types | |
typedef std::map< std::string, StorageMaker * > | MakerTable |
Protected Member Functions | |
StorageMaker * | getMaker (const std::string &url, std::string &protocol, std::string &rest) |
StorageMaker * | getMaker (const std::string &proto) |
StorageFactory (void) | |
Protected Attributes | |
bool | m_accounting |
CacheHint | m_cacheHint |
MakerTable | m_makers |
ReadHint | m_readHint |
std::string | m_tempdir |
Static Protected Attributes | |
static StorageFactory | s_instance |
Definition at line 11 of file StorageFactory.h.
typedef std::map<std::string, StorageMaker *> StorageFactory::MakerTable [protected] |
Definition at line 55 of file StorageFactory.h.
CACHE_HINT_APPLICATION | |
CACHE_HINT_STORAGE | |
CACHE_HINT_LAZY_DOWNLOAD | |
CACHE_HINT_AUTO_DETECT |
Definition at line 14 of file StorageFactory.h.
00015 { 00016 CACHE_HINT_APPLICATION, 00017 CACHE_HINT_STORAGE, 00018 CACHE_HINT_LAZY_DOWNLOAD, 00019 CACHE_HINT_AUTO_DETECT 00020 };
Definition at line 22 of file StorageFactory.h.
00023 { 00024 READ_HINT_UNBUFFERED, 00025 READ_HINT_READAHEAD, 00026 READ_HINT_AUTO 00027 };
StorageFactory::~StorageFactory | ( | void | ) |
StorageFactory::StorageFactory | ( | void | ) | [protected] |
Definition at line 14 of file StorageFactory.cc.
00015 : m_cacheHint(CACHE_HINT_AUTO_DETECT), 00016 m_readHint(READ_HINT_AUTO), 00017 m_accounting (false), 00018 m_tempdir(".") 00019 {}
Definition at line 40 of file StorageFactory.cc.
References m_accounting.
Referenced by RFIOStorageMaker::open(), and DCacheStorageMaker::open().
00041 { return m_accounting; }
StorageFactory::CacheHint StorageFactory::cacheHint | ( | void | ) | const |
Definition at line 48 of file StorageFactory.cc.
References m_cacheHint.
Referenced by RFIOStorageMaker::open(), StormLcgGtStorageMaker::open(), StormStorageMaker::open(), DCacheStorageMaker::open(), LocalStorageMaker::open(), and TStorageFactoryFile::ReadBufferAsync().
00049 { return m_cacheHint; }
Definition at line 163 of file StorageFactory.cc.
References StorageAccount::counter(), err, cms::Exception::explainSelf(), getMaker(), and m_accounting.
Referenced by TStorageFactorySystem::AccessPathName(), and mcdbGetInputFile().
00164 { 00165 std::string protocol; 00166 std::string rest; 00167 00168 bool ret = false; 00169 boost::shared_ptr<StorageAccount::Stamp> stats; 00170 if (StorageMaker *maker = getMaker (url, protocol, rest)) 00171 { 00172 if (m_accounting) 00173 stats.reset(new StorageAccount::Stamp(StorageAccount::counter (protocol, "check"))); 00174 try 00175 { 00176 ret = maker->check (protocol, rest, size); 00177 if (stats) stats->tick(); 00178 } 00179 catch (cms::Exception &err) 00180 { 00181 edm::LogWarning("StorageFactory::check()") 00182 << "Existence or size check for the file '" << url << "' failed because:\n" 00183 << err.explainSelf(); 00184 } 00185 } 00186 00187 return ret; 00188 }
Definition at line 32 of file StorageFactory.cc.
References m_accounting, and old.
Referenced by mcdbGetInputFile(), PixelSLinkDataInputSource::PixelSLinkDataInputSource(), and TFileAdaptor::TFileAdaptor().
00033 { 00034 bool old = m_accounting; 00035 m_accounting = enabled; 00036 return old; 00037 }
StorageFactory * StorageFactory::get | ( | void | ) | [static] |
Definition at line 28 of file StorageFactory.cc.
References s_instance.
Referenced by TStorageFactorySystem::AccessPathName(), lhef::LHEReader::FileSource::FileSource(), TStorageFactorySystem::GetPathInfo(), mcdbGetInputFile(), RFIOStorageMaker::open(), StormLcgGtStorageMaker::open(), StormStorageMaker::open(), LocalStorageMaker::open(), DCacheStorageMaker::open(), StreamerInputFile::openStreamerFile(), PixelSLinkDataInputSource::PixelSLinkDataInputSource(), TStorageFactoryFile::ReadBufferAsync(), edm::RootInputFileSequence::RootInputFileSequence(), TStorageFactoryFile::SysOpen(), TFileAdaptor::TFileAdaptor(), and TStorageFactoryFile::TStorageFactoryFile().
00029 { return &s_instance; }
StorageMaker * StorageFactory::getMaker | ( | const std::string & | url, | |
std::string & | protocol, | |||
std::string & | rest | |||
) | [protected] |
Definition at line 79 of file StorageFactory.cc.
References getMaker(), and p.
00082 { 00083 size_t p = url.find(':'); 00084 if (p != std::string::npos) 00085 { 00086 protocol = url.substr(0,p); 00087 rest = url.substr(p+1); 00088 } 00089 else 00090 { 00091 protocol = "file"; 00092 rest = url; 00093 } 00094 00095 return getMaker (protocol); 00096 }
StorageMaker * StorageFactory::getMaker | ( | const std::string & | proto | ) | [protected] |
Definition at line 68 of file StorageFactory.cc.
References edmplugin::standard::config(), edmplugin::PluginManager::configure(), DBSPlugin::get(), edmplugin::PluginManager::isAvailable(), and m_makers.
Referenced by check(), getMaker(), open(), and stagein().
00069 { 00070 StorageMaker *&instance = m_makers [proto]; 00071 if (! edmplugin::PluginManager::isAvailable()) 00072 edmplugin::PluginManager::configure(edmplugin::standard::config()); 00073 if (! instance) 00074 instance = StorageMakerFactory::get()->tryToCreate(proto); 00075 return instance; 00076 }
Storage * StorageFactory::open | ( | const std::string & | url, | |
int | mode = IOFlags::OpenRead , |
|||
const std::string & | tmpdir = "" | |||
) |
Definition at line 99 of file StorageFactory.cc.
References StorageAccount::counter(), err, Exception, getMaker(), m_accounting, m_tempdir, and tmp.
Referenced by lhef::LHEReader::FileSource::FileSource(), and mcdbGetInputFile().
00100 { 00101 std::string protocol; 00102 std::string rest; 00103 const std::string &tmp = (tmpdir.empty() ? m_tempdir : tmpdir); 00104 00105 Storage *ret = 0; 00106 boost::shared_ptr<StorageAccount::Stamp> stats; 00107 if (StorageMaker *maker = getMaker (url, protocol, rest)) 00108 { 00109 if (m_accounting) 00110 stats.reset(new StorageAccount::Stamp(StorageAccount::counter (protocol, "open"))); 00111 try 00112 { 00113 if (Storage *storage = maker->open (protocol, rest, mode, tmp)) 00114 { 00115 if (dynamic_cast<LocalCacheFile *>(storage)) 00116 protocol = "local-cache"; 00117 00118 if (m_accounting) 00119 ret = new StorageAccountProxy(protocol, storage); 00120 else 00121 ret = storage; 00122 00123 if (stats) 00124 stats->tick(); 00125 } 00126 } 00127 catch (cms::Exception &err) 00128 { 00129 throw cms::Exception("StorageFactory::open()") 00130 << "Failed to open the file '" << url << "' because:\n" 00131 << err; 00132 } 00133 } 00134 return ret; 00135 }
StorageFactory::ReadHint StorageFactory::readHint | ( | void | ) | const |
Definition at line 56 of file StorageFactory.cc.
References m_readHint.
Referenced by RFIOStorageMaker::open(), StormLcgGtStorageMaker::open(), StormStorageMaker::open(), DCacheStorageMaker::open(), and LocalStorageMaker::open().
00057 { return m_readHint; }
Definition at line 44 of file StorageFactory.cc.
References m_cacheHint.
Referenced by TFileAdaptor::TFileAdaptor().
00045 { m_cacheHint = value; }
Definition at line 52 of file StorageFactory.cc.
References m_readHint.
Referenced by TFileAdaptor::TFileAdaptor().
00053 { m_readHint = value; }
void StorageFactory::setTempDir | ( | const std::string & | s | ) |
Definition at line 60 of file StorageFactory.cc.
References m_tempdir.
Referenced by TFileAdaptor::TFileAdaptor().
void StorageFactory::stagein | ( | const std::string & | url | ) |
Definition at line 138 of file StorageFactory.cc.
References StorageAccount::counter(), err, cms::Exception::explainSelf(), getMaker(), and m_accounting.
Referenced by edm::RootInputFileSequence::RootInputFileSequence().
00139 { 00140 std::string protocol; 00141 std::string rest; 00142 00143 boost::shared_ptr<StorageAccount::Stamp> stats; 00144 if (StorageMaker *maker = getMaker (url, protocol, rest)) 00145 { 00146 if (m_accounting) 00147 stats.reset(new StorageAccount::Stamp(StorageAccount::counter (protocol, "stagein"))); 00148 try 00149 { 00150 maker->stagein (protocol, rest); 00151 if (stats) stats->tick(); 00152 } 00153 catch (cms::Exception &err) 00154 { 00155 edm::LogWarning("StorageFactory::stagein()") 00156 << "Failed to stage in file '" << url << "' because:\n" 00157 << err.explainSelf(); 00158 } 00159 } 00160 }
std::string StorageFactory::tempDir | ( | void | ) | const |
Definition at line 64 of file StorageFactory.cc.
References m_tempdir.
Referenced by RFIOStorageMaker::open(), and DCacheStorageMaker::open().
00065 { return m_tempdir; }
bool StorageFactory::m_accounting [protected] |
Definition at line 66 of file StorageFactory.h.
Referenced by accounting(), check(), enableAccounting(), open(), and stagein().
CacheHint StorageFactory::m_cacheHint [protected] |
MakerTable StorageFactory::m_makers [protected] |
ReadHint StorageFactory::m_readHint [protected] |
std::string StorageFactory::m_tempdir [protected] |
StorageFactory StorageFactory::s_instance [static, protected] |