Public Member Functions | |
virtual bool | check (const std::string &proto, const std::string &path, IOOffset *size=0) |
virtual Storage * | open (const std::string &proto, const std::string &surl, int mode, const std::string &tmpdir) |
Private Member Functions | |
std::string | getTURL (const std::string &surl) |
Definition at line 11 of file StormLCGStorageMaker.cc.
virtual bool StormLcgGtStorageMaker::check | ( | const std::string & | proto, | |
const std::string & | path, | |||
IOOffset * | size = 0 | |||
) | [inline, virtual] |
Reimplemented from StorageMaker.
Definition at line 75 of file StormLCGStorageMaker.cc.
References getTURL(), and size.
00078 { 00079 struct stat st; 00080 if (stat (getTURL(path).c_str(), &st) != 0) 00081 return false; 00082 00083 if (size) 00084 *size = st.st_size; 00085 00086 return true; 00087 }
std::string StormLcgGtStorageMaker::getTURL | ( | const std::string & | surl | ) | [inline, private] |
Definition at line 14 of file StormLCGStorageMaker.cc.
References lat::endl(), Exception, LogDebug, output(), p, and lhef::timeout().
Referenced by check(), and open().
00015 { 00016 // PrepareToGet timeout 00017 std::string timeout("300"); 00018 if(char *p = getenv("CMS_STORM_LCG_GT_TIMEOUT")) 00019 timeout = p; 00020 00021 /* Build the command line: 00022 -b => no BDII contacted 00023 -T srmv2 => necessary with -b 00024 -t timeout */ 00025 std::string comm("lcg-gt -b -T srmv2 -t " + timeout + " srm:" + surl + " file 2>&1"); 00026 LogDebug("StormLCGStorageMaker") << "command: " << comm << std::endl; 00027 00028 FILE *pipe = popen(comm.c_str(), "r"); 00029 if(! pipe) 00030 throw cms::Exception("StormLCGStorageMaker") 00031 << "failed to execute lcg-gt command: " 00032 << comm; 00033 00034 // Get output 00035 int ch; 00036 std::string output; 00037 while ((ch = getc(pipe)) != EOF) 00038 output.push_back(ch); 00039 pclose(pipe); 00040 00041 LogDebug("StormLCGStorageMaker") << "output: " << output << std::endl; 00042 00043 // Extract TURL if possible. 00044 size_t start = output.find("file:", 0); 00045 if (start == std::string::npos) 00046 throw cms::Exception("StormLCGStorageMaker") 00047 << "no turl found in command '" << comm << "' output:\n" << output; 00048 00049 start += 5; 00050 std::string turl(output, start, output.find_first_of("\n", start) - start); 00051 LogDebug("StormLCGStorageMaker") << "file to open: " << turl << std::endl; 00052 return turl; 00053 }
virtual Storage* StormLcgGtStorageMaker::open | ( | const std::string & | proto, | |
const std::string & | surl, | |||
int | mode, | |||
const std::string & | tmpdir | |||
) | [inline, virtual] |
Implements StorageMaker.
Definition at line 57 of file StormLCGStorageMaker.cc.
References StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), f, StorageFactory::get(), getTURL(), IOFlags::OpenUnbuffered, StorageFactory::READ_HINT_UNBUFFERED, and StorageFactory::readHint().
00061 { 00062 StorageFactory *f = StorageFactory::get(); 00063 StorageFactory::ReadHint readHint = f->readHint(); 00064 StorageFactory::CacheHint cacheHint = f->cacheHint(); 00065 00066 if (readHint != StorageFactory::READ_HINT_UNBUFFERED 00067 || cacheHint == StorageFactory::CACHE_HINT_STORAGE) 00068 mode &= ~IOFlags::OpenUnbuffered; 00069 else 00070 mode |= IOFlags::OpenUnbuffered; 00071 00072 return new File (getTURL(surl), mode); 00073 }