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

#include <XrdClXCpCtx.hh>

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

Public Member Functions

 XCpCtx (const std::vector< std::string > &urls, uint64_t blockSize, uint8_t parallelSrc, uint64_t chunkSize, uint64_t parallelChunks, int64_t fileSize)
 
void Delete ()
 
XCpCtxSelf ()
 
bool GetNextUrl (std::string &url)
 
XCpSrcWeakestLink (XCpSrc *exclude)
 
void PutChunk (PageInfo *chunk)
 
std::pair< uint64_t, uint64_t > GetBlock ()
 
void SetFileSize (int64_t size)
 
int64_t GetSize ()
 
XRootDStatus Initialize ()
 
XRootDStatus GetChunk (XrdCl::PageInfo &ci)
 
void RemoveSrc (XCpSrc *src)
 
void NotifyIdleSrc ()
 
bool AllDone ()
 
void NotifyInitExpectant ()
 

Private Member Functions

size_t GetRunning ()
 
virtual ~XCpCtx ()
 

Private Attributes

std::queue< std::string > pUrls
 
uint64_t pBlockSize
 
uint8_t pParallelSrc
 
uint32_t pChunkSize
 
uint8_t pParallelChunks
 
uint64_t pOffset
 
int64_t pFileSize
 
XrdSysCondVar pFileSizeCV
 
std::list< XCpSrc * > pSources
 
SyncQueue< PageInfo * > pSink
 
uint64_t pDataReceived
 
bool pDone
 
XrdSysCondVar pDoneCV
 
XrdSysMutex pMtx
 
size_t pRefCount
 

Constructor & Destructor Documentation

◆ XCpCtx()

XrdCl::XCpCtx::XCpCtx ( const std::vector< std::string > &  urls,
uint64_t  blockSize,
uint8_t  parallelSrc,
uint64_t  chunkSize,
uint64_t  parallelChunks,
int64_t  fileSize 
)

Constructor

Parameters
urls: list of replica urls
blockSize: the default block size
parallelSrc: maximum number of parallel sources
chunkSize: the default chunk size
parallelChunks: the default number of parallel chunks per source
fileSize: the file size if specified in the metalink file (-1 indicates that the file size is not known and a stat should be done)

◆ ~XCpCtx()

virtual XrdCl::XCpCtx::~XCpCtx ( )
privatevirtual

Destructor (private).

Use Delelte to destroy the object.

Member Function Documentation

◆ AllDone()

bool XrdCl::XCpCtx::AllDone ( )

Returns true if all chunks have been transferred, otherwise blocks until NotifyIdleSrc is called, or a 1 minute timeout occurs.

Returns
: true is all chunks have been transferred, false otherwise.

◆ Delete()

void XrdCl::XCpCtx::Delete ( )
inline

Deletes the instance if the reference counter reached 0.

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

◆ GetBlock()

std::pair< uint64_t, uint64_t > XrdCl::XCpCtx::GetBlock ( )

Get next block that has to be transferred

Returns
: pair of offset and block size

◆ GetChunk()

XRootDStatus XrdCl::XCpCtx::GetChunk ( XrdCl::PageInfo ci)

Gets the next chunk from the sink, if the sink is empty blocks.

Parameters
ci: the chunk retrieved from sink (output parameter)
Returns
: stError if we failed to transfer the file, stOK otherwise, with one of the following codes:
  • suDone : the whole file has been transferred, we are done
  • suContinue : a chunk has been written into ci, continue calling GetChunk in order to retrieve remaining chunks
  • suRetry : a chunk has not been written into ci, try again.

◆ GetNextUrl()

bool XrdCl::XCpCtx::GetNextUrl ( std::string &  url)

Gets the next URL from the list of file replicas

Parameters
url: the output parameter
Returns
: true if a url has been written to the url parameter, false otherwise

◆ GetRunning()

size_t XrdCl::XCpCtx::GetRunning ( )
private

Returns the number of active sources

Returns
: number of active sources

Referenced by GetSize().

◆ GetSize()

int64_t XrdCl::XCpCtx::GetSize ( )
inline

Get file size. The call blocks until the file size is being set using SetFileSize.

References GetRunning(), pFileSize, pFileSizeCV, and XrdSysCondVar::Wait().

◆ Initialize()

XRootDStatus XrdCl::XCpCtx::Initialize ( )

Starts one thread per source, each thread tries to open a file, stat the file if necessary, and then starts reading the file, all chunks read go to the sink.

Returns
Error if we were not able to create any threads

◆ NotifyIdleSrc()

void XrdCl::XCpCtx::NotifyIdleSrc ( )

Notify idle sources, used in two case:

  • if one of the sources failed and an idle source needs to take over
  • or if we are done and all idle source should be stopped

◆ NotifyInitExpectant()

void XrdCl::XCpCtx::NotifyInitExpectant ( )
inline

Notify those who are waiting for initialization. In particular the GetSize() caller will be waiting on the result of initialization.

References XrdSysCondVar::Broadcast(), and pFileSizeCV.

◆ PutChunk()

void XrdCl::XCpCtx::PutChunk ( PageInfo chunk)

Put a chunk into the sink

Parameters
chunk: the chunk

◆ RemoveSrc()

void XrdCl::XCpCtx::RemoveSrc ( XCpSrc src)
inline

Remove given source

Parameters
src: the source to be removed

References pMtx, and pSources.

◆ Self()

XCpCtx * XrdCl::XCpCtx::Self ( )
inline

Increments the reference counter.

Returns
: myself.

References pMtx, and pRefCount.

◆ SetFileSize()

void XrdCl::XCpCtx::SetFileSize ( int64_t  size)

Set the file size (GetSize will block until SetFileSize will be called). Also calculates the block size.

Parameters
size: file size

◆ WeakestLink()

XCpSrc * XrdCl::XCpCtx::WeakestLink ( XCpSrc exclude)

Get the 'weakest' sources

Parameters
exclude: the source that is excluded from the search
Returns
: the weakest source

Member Data Documentation

◆ pBlockSize

uint64_t XrdCl::XCpCtx::pBlockSize
private

The size of the block allocated to a single source.

◆ pChunkSize

uint32_t XrdCl::XCpCtx::pChunkSize
private

Chunk size.

◆ pDataReceived

uint64_t XrdCl::XCpCtx::pDataReceived
private

Total amount of data received

◆ pDone

bool XrdCl::XCpCtx::pDone
private

A flag, true if all chunks have been received and we are done, false otherwise

◆ pDoneCV

XrdSysCondVar XrdCl::XCpCtx::pDoneCV
private

A condition variable, idle sources wait on this cond var until we are done, or until one of the active sources fails.

◆ pFileSize

int64_t XrdCl::XCpCtx::pFileSize
private

File size.

Referenced by GetSize().

◆ pFileSizeCV

XrdSysCondVar XrdCl::XCpCtx::pFileSizeCV
private

File Size conditional variable. (notifies waiters if the file size has been set)

Referenced by GetSize(), and NotifyInitExpectant().

◆ pMtx

XrdSysMutex XrdCl::XCpCtx::pMtx
private

A mutex guarding the object

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

◆ pOffset

uint64_t XrdCl::XCpCtx::pOffset
private

Offset in the file (everything before the offset has been allocated, everything after the offset needs to be allocated)

◆ pParallelChunks

uint8_t XrdCl::XCpCtx::pParallelChunks
private

Number of parallel chunks per source.

◆ pParallelSrc

uint8_t XrdCl::XCpCtx::pParallelSrc
private

Number of parallel sources.

◆ pRefCount

size_t XrdCl::XCpCtx::pRefCount
private

Reference counter

Referenced by Delete(), and Self().

◆ pSink

SyncQueue<PageInfo*> XrdCl::XCpCtx::pSink
private

A queue shared between all the sources (producers), and the extreme copy context (consumer).

◆ pSources

std::list<XCpSrc*> XrdCl::XCpCtx::pSources
private

List of sources. Those pointers are not owned by this object.

Referenced by RemoveSrc().

◆ pUrls

std::queue<std::string> XrdCl::XCpCtx::pUrls
private

The URLs of all the replicas that were provided to us.


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