XrdCl::XCpSrc Class Reference

#include <XrdClXCpSrc.hh>

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

List of all members.

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

Friends

class ChunkHandler

Constructor & Destructor Documentation

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
virtual XrdCl::XCpSrc::~XCpSrc (  )  [private, virtual]

Destructor (private).

Use Delelte() method to destroy the object.


Member Function Documentation

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.

Parameters:
chunk : the chunk to be deleted

References XrdCl::ChunkInfo::buffer.

template<typename T >
static void XrdCl::XCpSrc::DeletePtr ( T *&  obj  )  [inline, static, private]

Delets a pointer and sets it to null.

static bool XrdCl::XCpSrc::FilesEqual ( File f1,
File f2 
) [inline, static, private]

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

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

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
bool XrdCl::XCpSrc::IsRunning (  )  [inline]
Returns:
: true if the thread is running, false otherwise

References pRunning.

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

Parameters:
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]

Increments the reference counter.

Returns:
: myself.

References pMtx, and pRefCount.

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.

  • 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
void XrdCl::XCpSrc::Stop (  )  [inline]

Stops the thread.

References pRunning.

uint64_t XrdCl::XCpSrc::TransferRate (  ) 

Get the transfer rate for current source

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

Friends And Related Function Documentation

friend class ChunkHandler [friend]

Member Data Documentation

uint64_t XrdCl::XCpSrc::pBlkEnd [private]

End of the our block.

Referenced by HasData().

uint32_t XrdCl::XCpSrc::pChunkSize [private]

Default chunk size

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]

Handle to the file.

int64_t XrdCl::XCpSrc::pFileSize [private]

The file size

A mutex guarding the object.

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

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]

Reference counter

Referenced by Delete(), and Self().

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 9 Oct 2019 for xrootd by  doxygen 1.6.1