#include <XrdClXCpSrc.hh>
Public Member Functions | |
XCpSrc (uint32_t chunkSize, uint8_t parallel, int64_t fileSize, XCpCtx *ctx) | |
void | Start () |
void | Stop () |
void | Delete () |
XCpSrc * | Self () |
bool | IsRunning () |
bool | HasData () |
uint64_t | TransferRate () |
Static Public Member Functions | |
static void | DeleteChunk (ChunkInfo *&chunk) |
Private Member Functions | |
virtual | ~XCpSrc () |
void | StartDownloading () |
XRootDStatus | Initialize () |
XRootDStatus | Recover () |
XRootDStatus | ReadChunks () |
void | Steal (XCpSrc *src) |
XRootDStatus | GetWork () |
void | ReportResponse (XRootDStatus *status, ChunkInfo *chunk, File *handle) |
Static Private Member Functions | |
static void * | Run (void *arg) |
template<typename T > | |
static void | DeletePtr (T *&obj) |
static bool | FilesEqual (File *f1, File *f2) |
Private Attributes | |
uint32_t | pChunkSize |
uint8_t | pParallel |
int64_t | pFileSize |
pthread_t | pThread |
XCpCtx * | pCtx |
std::string | pUrl |
File * | pFile |
std::map< File *, uint8_t > | pFailed |
uint64_t | pCurrentOffset |
uint64_t | pBlkEnd |
uint64_t | pDataTransfered |
std::map< uint64_t, uint64_t > | pOngoing |
std::map< uint64_t, uint64_t > | pRecovered |
SyncQueue< XRootDStatus * > | pReports |
XrdSysRecMutex | pMtx |
size_t | pRefCount |
bool | pRunning |
time_t | pStartTime |
time_t | pTransferTime |
Friends | |
class | ChunkHandler |
XrdCl::XCpSrc::XCpSrc | ( | uint32_t | chunkSize, | |
uint8_t | parallel, | |||
int64_t | fileSize, | |||
XCpCtx * | ctx | |||
) |
Constructor.
chunkSize | : default chunk size | |
parallel | : number of parallel chunks | |
fileSize | : file size if available (e.g. in metalink file), should be set to -1 if not available, in this case a stat will be performed during initialization | |
ctx | : Extreme Copy context |
virtual XrdCl::XCpSrc::~XCpSrc | ( | ) | [private, virtual] |
Destructor (private).
Use Delelte() method to destroy the object.
void XrdCl::XCpSrc::Delete | ( | ) | [inline] |
Deletes the instance if the reference counter reached 0.
References pMtx, pRefCount, and XrdSysMutexHelper::UnLock().
static void XrdCl::XCpSrc::DeleteChunk | ( | ChunkInfo *& | chunk | ) | [inline, static] |
Delete ChunkInfo object, and set the pointer to null.
chunk | : the chunk to be deleted |
References XrdCl::ChunkInfo::buffer.
static void XrdCl::XCpSrc::DeletePtr | ( | T *& | obj | ) | [inline, static, private] |
Delets a pointer and sets it to null.
Check if two file object point to the same URL.
References XrdCl::File::GetProperty().
XRootDStatus XrdCl::XCpSrc::GetWork | ( | ) | [private] |
Get more work. First try to get a new block. If there are no blocks remaining, try stealing from others.
bool XrdCl::XCpSrc::HasData | ( | ) | [inline] |
References pBlkEnd, pCurrentOffset, pMtx, pOngoing, and pRecovered.
XRootDStatus XrdCl::XCpSrc::Initialize | ( | ) | [private] |
Initializes the object:
bool XrdCl::XCpSrc::IsRunning | ( | ) | [inline] |
References pRunning.
XRootDStatus XrdCl::XCpSrc::ReadChunks | ( | ) | [private] |
Asynchronously reads consecutive chunks.
XRootDStatus XrdCl::XCpSrc::Recover | ( | ) | [private] |
Tries to open the file at the next available URL. Moves all ongoing chunk to recovered.
void XrdCl::XCpSrc::ReportResponse | ( | XRootDStatus * | status, | |
ChunkInfo * | chunk, | |||
File * | handle | |||
) | [private] |
This method is used by ChunkHandler to report the result of a write, to the source object.
stats | : operation status | |
chunk | : the read chunk (if operation failed, should be null) | |
handle | : the file object used to read the chunk |
static void* XrdCl::XCpSrc::Run | ( | void * | arg | ) | [static, private] |
The start routine.
XCpSrc* XrdCl::XCpSrc::Self | ( | ) | [inline] |
void XrdCl::XCpSrc::Start | ( | ) |
Creates new thread with XCpSrc::Run as the start routine.
void XrdCl::XCpSrc::StartDownloading | ( | ) | [private] |
Initializes the object first. Afterwards, starts the download.
void XrdCl::XCpSrc::Steal | ( | XCpSrc * | src | ) | [private] |
Steal work from given source.
src | : the source from whom we are stealing |
void XrdCl::XCpSrc::Stop | ( | ) | [inline] |
Stops the thread.
References pRunning.
uint64_t XrdCl::XCpSrc::TransferRate | ( | ) |
Get the transfer rate for current source
friend class ChunkHandler [friend] |
uint64_t XrdCl::XCpSrc::pBlkEnd [private] |
End of the our block.
Referenced by HasData().
uint32_t XrdCl::XCpSrc::pChunkSize [private] |
Default chunk size
XCpCtx* XrdCl::XCpSrc::pCtx [private] |
Extreme Copy context
uint64_t XrdCl::XCpSrc::pCurrentOffset [private] |
The offset of the next chunk to be transfered.
Referenced by HasData().
uint64_t XrdCl::XCpSrc::pDataTransfered [private] |
Total number of data transfered from this source.
std::map<File*, uint8_t> XrdCl::XCpSrc::pFailed [private] |
File* XrdCl::XCpSrc::pFile [private] |
Handle to the file.
int64_t XrdCl::XCpSrc::pFileSize [private] |
The file size
XrdSysRecMutex XrdCl::XCpSrc::pMtx [private] |
std::map<uint64_t, uint64_t> XrdCl::XCpSrc::pOngoing [private] |
A map of ongoing transfers (the offset is the key, the chunk size is the value).
Referenced by HasData().
uint8_t XrdCl::XCpSrc::pParallel [private] |
Number of parallel chunks
std::map<uint64_t, uint64_t> XrdCl::XCpSrc::pRecovered [private] |
A map of stolen chunks (again the offset is the key, the chunk size is the value).
Referenced by HasData().
size_t XrdCl::XCpSrc::pRefCount [private] |
SyncQueue<XRootDStatus*> XrdCl::XCpSrc::pReports [private] |
Sync queue with reports (statuses) from async reads that have been issued. An error appears only once per URL (independently of how many concurrent async reads are allowed).
bool XrdCl::XCpSrc::pRunning [private] |
A flag, true means the source is running, false means the source has been stopped, or failed.
Referenced by IsRunning(), and Stop().
time_t XrdCl::XCpSrc::pStartTime [private] |
The time when we started / restarted chunks
pthread_t XrdCl::XCpSrc::pThread [private] |
Thread id
time_t XrdCl::XCpSrc::pTransferTime [private] |
The total time we were transferring data, before the restart
std::string XrdCl::XCpSrc::pUrl [private] |
Source URL.