![]() |
XRootD
|
Random utilities. More...
#include <XrdClUtils.hh>
Public Types | |
enum | AddressType { IPAuto = 0 , IPAll = 1 , IPv6 = 2 , IPv4 = 3 , IPv4Mapped6 = 4 } |
Address type. More... | |
Static Public Member Functions | |
static std::string | BytesToString (uint64_t bytes) |
Convert bytes to a human readable string. More... | |
static std::string | Char2Hex (uint8_t *array, uint16_t size) |
Print a char array as hex. More... | |
static bool | CheckEC (const Message *req, const URL &url) |
Check if this client can support given EC redirect. More... | |
static XRootDStatus | CheckTPC (const std::string &server, uint16_t timeout=0) |
Check if peer supports tpc. More... | |
static XRootDStatus | CheckTPCLite (const std::string &server, uint16_t timeout=0) |
static std::string | FQDNToCC (const std::string &fqdn) |
Convert the fully qualified host name to country code. More... | |
static Status | GetDirectoryEntries (std::vector< std::string > &entries, const std::string &path) |
Get directory entries. More... | |
static uint64_t | GetElapsedMicroSecs (timeval start, timeval end) |
Get the elapsed microseconds between two timevals. More... | |
static Status | GetHostAddresses (std::vector< XrdNetAddr > &addresses, const URL &url, AddressType type) |
Resolve IP addresses. More... | |
static int | GetIntParameter (const URL &url, const std::string &name, int defaultVal) |
Get a parameter either from the environment or URL. More... | |
static XRootDStatus | GetLocalCheckSum (std::string &checkSum, const std::string &checkSumType, const std::string &path) |
Get a checksum from local file. More... | |
static XrdCl::XRootDStatus | GetProtocolVersion (const XrdCl::URL url, int &protver) |
static XRootDStatus | GetRemoteCheckSum (std::string &checkSum, const std::string &checkSumType, const URL &url) |
Get a checksum from a remote xrootd server. More... | |
static std::string | GetStringParameter (const URL &url, const std::string &name, const std::string &defaultVal) |
Get a parameter either from the environment or URL. More... | |
static std::vector< std::string > | GetSupportedCheckSums (const XrdCl::URL &url) |
Get supported checksum types for given URL. More... | |
static bool | HasPgRW (const XrdCl::URL &url) |
static bool | HasXAttr (const XrdCl::URL &url) |
static std::string | InferChecksumType (const XrdCl::URL &source, const XrdCl::URL &destination, bool zip=false) |
Automatically infer the right checksum type. More... | |
static void | LogHostAddresses (Log *log, uint64_t type, const std::string &hostId, std::vector< XrdNetAddr > &addresses) |
Log all the addresses on the list. More... | |
static void | LogPropertyList (Log *log, uint64_t topic, const char *format, const PropertyList &list) |
Log property list. More... | |
static std::string | NormalizeChecksum (const std::string &name, const std::string &checksum) |
Normalize checksum. More... | |
static Status | ProcessConfig (std::map< std::string, std::string > &config, const std::string &file) |
Process a config file and return key-value pairs. More... | |
static Status | ProcessConfigDir (std::map< std::string, std::string > &config, const std::string &dir) |
Process a config directory and return key-value pairs. More... | |
static void | SplitChunks (std::vector< ChunkList > &listsvec, const ChunkList &chunks, const uint32_t maxcs, const size_t maxc) |
Split chunks in a ChunkList into one or more ChunkLists. More... | |
template<class Container > | |
static void | splitString (Container &result, const std::string &input, const std::string &delimiter) |
Split a string. More... | |
static AddressType | String2AddressType (const std::string &addressType) |
Interpret a string as address type, default to IPAll. More... | |
static std::string | TimeToString (time_t timestamp) |
Convert timestamp to a string. More... | |
static void | Trim (std::string &str) |
Trim a string. More... | |
Random utilities.
Definition at line 49 of file XrdClUtils.hh.
Address type.
Enumerator | |
---|---|
IPAuto | |
IPAll | |
IPv6 | |
IPv4 | |
IPv4Mapped6 |
Definition at line 86 of file XrdClUtils.hh.
|
static |
Convert bytes to a human readable string.
Definition at line 367 of file XrdClUtils.cc.
Referenced by ProgressDisplay::GetProgressBar(), ProgressDisplay::GetSummaryBar(), and ProgressDisplay::JobProgress().
|
static |
Check if this client can support given EC redirect.
Definition at line 703 of file XrdClUtils.cc.
References XrdCl::Buffer::GetBuffer(), XrdCl::URL::GetParams(), kXR_new, kXR_open_updt, kXR_open_wrto, ClientRequest::open, ClientOpenRequest::options, and splitString().
Referenced by XrdCl::XRootDMsgHandler::Process().
|
static |
Check if peer supports tpc.
Definition at line 382 of file XrdClUtils.cc.
References XrdCl::QueryCode::Config, XrdCl::Log::Debug(), XrdCl::errNotSupported, XrdCl::Log::Error(), XrdCl::Buffer::FromString(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), XrdCl::FileSystem::Query(), XrdCl::Status::status, XrdCl::stError, XrdCl::stFatal, XrdCl::XRootDStatus::ToStr(), XrdCl::Buffer::ToString(), and XrdCl::UtilityMsg.
|
static |
Check if peer supports tpc / tpc lite
Definition at line 426 of file XrdClUtils.cc.
References XrdCl::QueryCode::Config, XrdCl::Log::Debug(), XrdCl::errNotSupported, XrdCl::Log::Error(), XrdCl::Buffer::FromString(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), XrdCl::FileSystem::Query(), splitString(), XrdCl::Status::status, XrdCl::stError, XrdCl::stFatal, XrdCl::stOK, XrdCl::suPartial, XrdCl::XRootDStatus::ToStr(), XrdCl::Buffer::ToString(), and XrdCl::UtilityMsg.
|
static |
Convert the fully qualified host name to country code.
Definition at line 490 of file XrdClUtils.cc.
References splitString().
|
static |
Get directory entries.
Definition at line 506 of file XrdClUtils.cc.
References closedir(), XrdCl::errOSError, opendir(), readdir(), and XrdCl::stError.
Referenced by ProcessConfigDir().
|
static |
Get the elapsed microseconds between two timevals.
Definition at line 269 of file XrdClUtils.cc.
Referenced by XrdCl::ClassicCopyJob::Run(), and XrdCl::ThirdPartyCopyJob::Run().
|
static |
Resolve IP addresses.
Definition at line 140 of file XrdClUtils.cc.
References XrdNetUtils::allIPMap, XrdNetUtils::allV4Map, XrdCl::DefaultIPNoShuffle, XrdCl::DefaultPreferIPv4, XrdCl::errInvalidAddr, XrdCl::Log::Error(), XrdNetUtils::GetAddrs(), XrdCl::DefaultEnv::GetEnv(), XrdCl::URL::GetHostName(), XrdCl::Env::GetInt(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetPort(), IPAll, IPv4, IPv4Mapped6, IPv6, XrdNetUtils::onlyIPv4, XrdNetUtils::onlyIPv6, opts, XrdNetUtils::order46, XrdNetUtils::order64, XrdNetUtils::prefAuto, XrdCl::stError, and XrdCl::UtilityMsg.
Referenced by XrdCl::Stream::CanCollapse(), XrdCl::Socket::Connect(), and XrdCl::Stream::EnableLink().
|
static |
Get a parameter either from the environment or URL.
Definition at line 81 of file XrdClUtils.cc.
References XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), and XrdCl::URL::GetParams().
Referenced by XrdCl::Stream::Stream().
|
static |
Get a checksum from local file.
Definition at line 330 of file XrdClUtils.cc.
References XrdCl::CheckSumManager::Calculate(), XrdCl::Log::Dump(), XrdCl::errCheckSumError, XrdCl::errInternal, XrdCl::Log::Error(), XrdCksData::Get(), XrdCl::DefaultEnv::GetCheckSumManager(), XrdCl::DefaultEnv::GetLog(), NormalizeChecksum(), XrdCksData::Set(), XrdCl::stError, and XrdCl::UtilityMsg.
|
inlinestatic |
Get protocol version of the given server
url | : URL pointing to the server |
protver | : protocol version (output parameter) |
Definition at line 235 of file XrdClUtils.hh.
References XrdCl::AnyObject::Get(), XrdCl::DefaultEnv::GetPostMaster(), XrdCl::Status::IsOK(), and XrdCl::XRootDQuery::ProtocolVersion.
Referenced by HasPgRW(), HasXAttr(), and XrdCl::FileStateHandler::PgRead().
|
static |
Get a checksum from a remote xrootd server.
Definition at line 279 of file XrdClUtils.cc.
References XrdCl::QueryCode::Checksum, XrdCl::Log::Dump(), XrdCl::errCheckSumError, XrdCl::errInternal, XrdCl::errInvalidResponse, XrdCl::Buffer::FromString(), XrdCl::XRootDStatus::GetErrorMessage(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetPath(), XrdCl::Status::IsOK(), NormalizeChecksum(), XrdCl::FileSystem::Query(), XrdCl::XRootDStatus::SetErrorMessage(), splitString(), XrdCl::stError, XrdCl::Buffer::ToString(), and XrdCl::UtilityMsg.
Referenced by XrdCl::ThirdPartyCopyJob::Run().
|
static |
Get a parameter either from the environment or URL.
Definition at line 104 of file XrdClUtils.cc.
References XrdCl::DefaultEnv::GetEnv(), XrdCl::URL::GetParams(), and XrdCl::Env::GetString().
Referenced by XrdCl::Stream::Stream().
|
static |
Get supported checksum types for given URL.
Definition at line 665 of file XrdClUtils.cc.
References XrdCl::QueryCode::Config, XrdCl::Buffer::FromString(), XrdCl::Status::IsOK(), XrdCl::FileSystem::Query(), splitString(), and XrdCl::Buffer::ToString().
Referenced by InferChecksumType().
|
inlinestatic |
Check if given server supports pgread/pgwrite
url | : URL pointing to the server |
Definition at line 267 of file XrdClUtils.hh.
References GetProtocolVersion(), XrdCl::URL::IsLocalFile(), and kXR_PROTPGRWVERSION.
|
inlinestatic |
Check if given server supports extended file attributes
url | : URL pointing to the server |
Definition at line 253 of file XrdClUtils.hh.
References GetProtocolVersion(), XrdCl::URL::IsLocalFile(), and kXR_PROTXATTVERSION.
Referenced by XrdCl::ClassicCopyJob::Run().
|
static |
Automatically infer the right checksum type.
Automatically infer the right checksum type
source | : source URL |
destination | : destination URL |
zip | : true if the source file is being extracted from a ZIP archive, false otherwise |
Definition at line 771 of file XrdClUtils.cc.
References XrdCl::DefaultZipMtlnCksum, XrdCl::RedirectorRegistry::Get(), XrdCl::DefaultEnv::GetEnv(), XrdCl::Env::GetInt(), XrdCl::URL::GetProtocol(), XrdCl::VirtualRedirector::GetSupportedCheckSums(), GetSupportedCheckSums(), XrdCl::RedirectorRegistry::Instance(), XrdCl::URL::IsLocalFile(), and XrdCl::URL::IsMetalink().
Referenced by XrdCl::ClassicCopyJob::Run().
|
static |
Log all the addresses on the list.
Definition at line 234 of file XrdClUtils.cc.
References XrdCl::Log::Debug(), and XrdNetAddrInfo::fmtAdv6.
Referenced by XrdCl::Socket::Connect(), and XrdCl::Stream::EnableLink().
|
static |
Log property list.
Definition at line 617 of file XrdClUtils.cc.
References XrdCl::PropertyList::begin(), XrdCl::Log::Dump(), XrdCl::Log::DumpMsg, XrdCl::PropertyList::end(), XrdCl::Log::GetLevel(), obfuscateAuth(), and unlikely.
Referenced by XrdCl::CopyProcess::AddJob().
|
static |
Normalize checksum.
Definition at line 648 of file XrdClUtils.cc.
Referenced by XrdCl::CheckSumHelper::GetCheckSum(), GetLocalCheckSum(), GetRemoteCheckSum(), XrdCl::ClassicCopyJob::Run(), and XrdCl::ThirdPartyCopyJob::Run().
|
static |
Process a config file and return key-value pairs.
Definition at line 534 of file XrdClUtils.cc.
References XrdCl::errConfig, XrdCl::errOSError, getline(), splitString(), XrdCl::stError, and Trim().
Referenced by ProcessConfigDir().
|
static |
Process a config directory and return key-value pairs.
Definition at line 566 of file XrdClUtils.cc.
References XrdCl::Log::Debug(), GetDirectoryEntries(), XrdCl::DefaultEnv::GetLog(), XrdCl::Status::IsOK(), ProcessConfig(), XrdCl::Status::ToString(), and XrdCl::UtilityMsg.
|
static |
Split chunks in a ChunkList into one or more ChunkLists.
Split chunks in a ChunkList into one or more ChunkLists
listsvec | : output vector of ChunkLists |
chunks | : input ChunkLisits |
maxcs | : maximum size of a ChunkInfo in output |
maxc | : maximum number of ChunkInfo in each ChunkList |
Definition at line 875 of file XrdClUtils.cc.
References XrdCl::ChunkInfo::buffer, XrdCl::ChunkInfo::length, and XrdCl::ChunkInfo::offset.
Referenced by XrdCl::ZipArchive::CloseArchive().
|
inlinestatic |
Split a string.
Definition at line 56 of file XrdClUtils.hh.
References XrdOucTUtils::splitString().
Referenced by BuildPath(), CheckEC(), CheckTPCLite(), XrdCl::PollerFactory::CreatePoller(), FQDNToCC(), XrdCl::GetEcHandler(), GetRemoteCheckSum(), GetSupportedCheckSums(), main(), XrdCl::ParseInput(), XrdCl::StatInfoImpl::ParseServerResponse(), XrdCl::LocationInfo::ParseServerResponse(), XrdCl::StatInfoVFS::ParseServerResponse(), XrdCl::DirectoryList::ParseServerResponse(), XrdCl::XRootDMsgHandler::Process(), ProcessConfig(), ProcessStatQuery(), and XrdCl::URL::SetParams().
|
static |
Interpret a string as address type, default to IPAll.
Definition at line 123 of file XrdClUtils.cc.
References IPAll, IPAuto, IPv4, IPv4Mapped6, and IPv6.
Referenced by XrdCl::Stream::Stream().
|
static |
Convert timestamp to a string.
Definition at line 256 of file XrdClUtils.cc.
Referenced by XrdCl::XRootDTransport::IsStreamBroken(), XrdCl::TaskManager::RegisterTask(), and XrdCl::TaskManager::RunTasks().
|
static |
Trim a string.
Definition at line 606 of file XrdClUtils.cc.
Referenced by ProcessConfig().