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 StormStorageMaker.cc.
std::string StormStorageMaker::getTURL | ( | const std::string & | surl | ) | [inline, private] |
Definition at line 14 of file StormStorageMaker.cc.
References lat::endl(), Exception, LogDebug, output(), and p.
Referenced by check(), and open().
00015 { 00016 std::string client; 00017 if (char *p = getenv("CMS_STORM_PTG_CLIENT")) 00018 client = p; 00019 else 00020 throw cms::Exception("StormStorageMaker") 00021 << "$CMS_STORM_PTG_CLIENT has no value"; 00022 00023 // Command 00024 std::string comm(client + " srm:" + surl + " 2>&1"); 00025 LogDebug("StormStorageMaker") << "command: " << comm << std::endl; 00026 00027 FILE *pipe = popen(comm.c_str(), "r"); 00028 if(! pipe) 00029 throw cms::Exception("StormStorageMaker") 00030 << "failed to execute PtG command: " 00031 << comm; 00032 00033 // Get output 00034 int ch; 00035 std::string output; 00036 while ((ch = getc(pipe)) != EOF) 00037 output.push_back(ch); 00038 pclose(pipe); 00039 00040 LogDebug("StormStorageMaker") << "output: " << output << std::endl; 00041 00042 // Extract TURL if possible. 00043 size_t start = output.find("FilePath:", 0); 00044 if (start == std::string::npos) 00045 throw cms::Exception("StormStorageMaker") 00046 << "no turl found in command '" << comm << "' output:\n" << output; 00047 00048 start += 9; 00049 std::string turl(output, start, output.find_first_of("\n", start) - start); 00050 LogDebug("StormStorageMaker") << "file to open: " << turl << std::endl; 00051 return turl; 00052 }
virtual Storage* StormStorageMaker::open | ( | const std::string & | proto, | |
const std::string & | surl, | |||
int | mode, | |||
const std::string & | tmpdir | |||
) | [inline, virtual] |
Implements StorageMaker.
Definition at line 56 of file StormStorageMaker.cc.
References StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), f, StorageFactory::get(), getTURL(), IOFlags::OpenUnbuffered, StorageFactory::READ_HINT_UNBUFFERED, and StorageFactory::readHint().
00060 { 00061 StorageFactory *f = StorageFactory::get(); 00062 StorageFactory::ReadHint readHint = f->readHint(); 00063 StorageFactory::CacheHint cacheHint = f->cacheHint(); 00064 00065 if (readHint != StorageFactory::READ_HINT_UNBUFFERED 00066 || cacheHint == StorageFactory::CACHE_HINT_STORAGE) 00067 mode &= ~IOFlags::OpenUnbuffered; 00068 else 00069 mode |= IOFlags::OpenUnbuffered; 00070 00071 return new File (getTURL(surl), mode); 00072 }