xrootd
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
XrdCl::XCpSrc Class Reference

#include <XrdClXCpSrc.hh>

Collaboration diagram for XrdCl::XCpSrc:
Collaboration graph
[legend]

Public Member Functions

 XCpSrc (uint32_t chunkSize, uint8_t parallel, int64_t fileSize, XCpCtx *ctx)
 
void Start ()
 
void Stop ()
 
void Delete ()
 
XCpSrcSelf ()
 
bool IsRunning ()
 
bool HasData ()
 
uint64_t TransferRate ()
 

Static Public Member Functions

static void DeleteChunk (PageInfo *&chunk)
 

Private Member Functions

virtual ~XCpSrc ()
 
void StartDownloading ()
 
XRootDStatus Initialize ()
 
XRootDStatus Recover ()
 
XRootDStatus ReadChunks ()
 
void Steal (XCpSrc *src)
 
XRootDStatus GetWork ()
 
void ReportResponse (XRootDStatus *status, PageInfo *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
 
XCpCtxpCtx
 
std::string pUrl
 
FilepFile
 
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
 
bool pUsePgRead
 

Friends

class ChunkHandler
 

Constructor & Destructor Documentation

◆ XCpSrc()

XrdCl::XCpSrc::XCpSrc ( uint32_t  chunkSize,
uint8_t  parallel,
int64_t  fileSize,
XCpCtx ctx 
)

Constructor.

Parameters
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

◆ ~XCpSrc()

virtual XrdCl::XCpSrc::~XCpSrc ( )
privatevirtual

Destructor (private).

Use Delelte() method to destroy the object.

Member Function Documentation

◆ Delete()

void XrdCl::XCpSrc::Delete ( )
inline

Deletes the instance if the reference counter reached 0.

References pMtx, pRefCount, and XrdSysMutexHelper::UnLock().

◆ DeleteChunk()

static void XrdCl::XCpSrc::DeleteChunk ( PageInfo *&  chunk)
inlinestatic

Delete ChunkInfo object, and set the pointer to null.

Parameters
chunk: the chunk to be deleted

References XrdCl::PageInfo::GetBuffer().

◆ DeletePtr()

template<typename T >
static void XrdCl::XCpSrc::DeletePtr ( T *&  obj)
inlinestaticprivate

Delets a pointer and sets it to null.

◆ FilesEqual()

static bool XrdCl::XCpSrc::FilesEqual ( File f1,
File f2 
)
inlinestaticprivate

Check if two file object point to the same URL.

Returns
: true if both files point to the same URL, false otherwise

References XrdCl::File::GetProperty().

◆ GetWork()

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.

Returns
: error if didn't got any data to transfer

◆ HasData()

bool XrdCl::XCpSrc::HasData ( )
inline
Returns
true if the source has a block of non zero size / some chunks allocated, false otherwise

References pBlkEnd, pCurrentOffset, pMtx, pOngoing, and pRecovered.

◆ Initialize()

XRootDStatus XrdCl::XCpSrc::Initialize ( )
private

Initializes the object:

  • Opens a file (retries with another URL, in case of failure)
  • Stats the file if necessary
  • Gets the first block (offset and size) for download
Returns
: error in case the object could not be initialized

◆ IsRunning()

bool XrdCl::XCpSrc::IsRunning ( )
inline
Returns
: true if the thread is running, false otherwise

References pRunning.

◆ ReadChunks()

XRootDStatus XrdCl::XCpSrc::ReadChunks ( )
private

Asynchronously reads consecutive chunks.

Returns
: operation status:
  • suContinue : I still have work to do
  • suPartial : I only have ongoing transfers, but the block has been consumed
  • suDone : We are done, the block has been consumed, there are no ongoing transfers, and there are no new data

◆ Recover()

XRootDStatus XrdCl::XCpSrc::Recover ( )
private

Tries to open the file at the next available URL. Moves all ongoing chunk to recovered.

Returns
: error if run out of URLs to try, success otherwise

◆ ReportResponse()

void XrdCl::XCpSrc::ReportResponse ( XRootDStatus status,
PageInfo chunk,
File handle 
)
private

This method is used by ChunkHandler to report the result of a write, to the source object.

Parameters
status: operation status
chunk: the read chunk (if operation failed, should be null)
handle: the file object used to read the chunk

◆ Run()

static void * XrdCl::XCpSrc::Run ( void *  arg)
staticprivate

The start routine.

◆ Self()

XCpSrc * XrdCl::XCpSrc::Self ( )
inline

Increments the reference counter.

Returns
: myself.

References pMtx, and pRefCount.

◆ Start()

void XrdCl::XCpSrc::Start ( )

Creates new thread with XCpSrc::Run as the start routine.

◆ StartDownloading()

void XrdCl::XCpSrc::StartDownloading ( )
private

Initializes the object first. Afterwards, starts the download.

◆ Steal()

void XrdCl::XCpSrc::Steal ( XCpSrc src)
private

Steal work from given source.

  • if it is a failed source we can have everything
  • otherwise, if the source has a block of size greater than 0, steal respective fraction of the block
  • otherwise, if the source has recovered chunks, steal respective fraction of those chunks
  • otherwise, steal respective fraction of ongoing chunks, if we are a faster source
Parameters
src: the source from whom we are stealing

◆ Stop()

void XrdCl::XCpSrc::Stop ( )
inline

Stops the thread.

References pRunning.

◆ TransferRate()

uint64_t XrdCl::XCpSrc::TransferRate ( )

Get the transfer rate for current source

Returns
: transfer rate for current source [B/s]

Friends And Related Symbol Documentation

◆ ChunkHandler

friend class ChunkHandler
friend

Member Data Documentation

◆ pBlkEnd

uint64_t XrdCl::XCpSrc::pBlkEnd
private

End of the our block.

Referenced by HasData().

◆ pChunkSize

uint32_t XrdCl::XCpSrc::pChunkSize
private

Default chunk size

◆ pCtx

XCpCtx* XrdCl::XCpSrc::pCtx
private

Extreme Copy context

◆ pCurrentOffset

uint64_t XrdCl::XCpSrc::pCurrentOffset
private

The offset of the next chunk to be transferred.

Referenced by HasData().

◆ pDataTransfered

uint64_t XrdCl::XCpSrc::pDataTransfered
private

Total number of data transferred from this source.

◆ pFailed

std::map<File*, uint8_t> XrdCl::XCpSrc::pFailed
private

◆ pFile

File* XrdCl::XCpSrc::pFile
private

Handle to the file.

◆ pFileSize

int64_t XrdCl::XCpSrc::pFileSize
private

The file size

◆ pMtx

XrdSysRecMutex XrdCl::XCpSrc::pMtx
private

A mutex guarding the object.

Referenced by Delete(), HasData(), and Self().

◆ pOngoing

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().

◆ pParallel

uint8_t XrdCl::XCpSrc::pParallel
private

Number of parallel chunks

◆ pRecovered

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().

◆ pRefCount

size_t XrdCl::XCpSrc::pRefCount
private

Reference counter

Referenced by Delete(), and Self().

◆ pReports

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).

◆ pRunning

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().

◆ pStartTime

time_t XrdCl::XCpSrc::pStartTime
private

The time when we started / restarted chunks

◆ pThread

pthread_t XrdCl::XCpSrc::pThread
private

Thread id

◆ pTransferTime

time_t XrdCl::XCpSrc::pTransferTime
private

The total time we were transferring data, before the restart

◆ pUrl

std::string XrdCl::XCpSrc::pUrl
private

Source URL.

◆ pUsePgRead

bool XrdCl::XCpSrc::pUsePgRead
private

The total time we were transferring data, before the restart


The documentation for this class was generated from the following file: