xrootd
Loading...
Searching...
No Matches
XrdClXCpCtx.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2011-2017 by European Organization for Nuclear Research (CERN)
3// Author: Michal Simon <michal.simon@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
6//
7// XRootD is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// XRootD is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19//
20// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
25#ifndef SRC_XRDCL_XRDCLXCPCTX_HH_
26#define SRC_XRDCL_XRDCLXCPCTX_HH_
27
31
32#include <cstdint>
33#include <iostream>
34
35namespace XrdCl
36{
37
38class XCpSrc;
39
40class XCpCtx
41{
42 public:
43
56 XCpCtx( const std::vector<std::string> &urls, uint64_t blockSize, uint8_t parallelSrc, uint64_t chunkSize, uint64_t parallelChunks, int64_t fileSize );
57
61 void Delete()
62 {
64 --pRefCount;
65 if( !pRefCount )
66 {
67 lck.UnLock();
68 delete this;
69 }
70 }
71
78 {
80 ++pRefCount;
81 return this;
82 }
83
91 bool GetNextUrl( std::string & url );
92
101
107 void PutChunk( PageInfo* chunk );
108
114 std::pair<uint64_t, uint64_t> GetBlock();
115
123 void SetFileSize( int64_t size );
124
129 int64_t GetSize()
130 {
132 while( pFileSize < 0 && GetRunning() > 0 ) pFileSizeCV.Wait();
133 return pFileSize;
134 }
135
145
161
167 void RemoveSrc( XCpSrc *src )
168 {
169 XrdSysMutexHelper lck( pMtx );
170 pSources.remove( src );
171 }
172
181
190 bool AllDone();
191
198 {
200 }
201
202
203 private:
204
210 size_t GetRunning();
211
217 virtual ~XCpCtx();
218
223 std::queue<std::string> pUrls;
224
228 uint64_t pBlockSize;
229
234
238 uint32_t pChunkSize;
239
244
250 uint64_t pOffset;
251
255 int64_t pFileSize;
256
262
267 std::list<XCpSrc*> pSources;
268
274
279
284 bool pDone;
285
291
296
300 size_t pRefCount;
301};
302
303} /* namespace XrdCl */
304
305#endif /* SRC_XRDCL_XRDCLXCPCTX_HH_ */
A synchronized queue.
Definition XrdClSyncQueue.hh:33
Definition XrdClXCpCtx.hh:41
void Delete()
Definition XrdClXCpCtx.hh:61
SyncQueue< PageInfo * > pSink
Definition XrdClXCpCtx.hh:273
void NotifyInitExpectant()
Definition XrdClXCpCtx.hh:197
XrdSysCondVar pFileSizeCV
Definition XrdClXCpCtx.hh:261
void NotifyIdleSrc()
bool GetNextUrl(std::string &url)
uint32_t pChunkSize
Definition XrdClXCpCtx.hh:238
size_t GetRunning()
uint64_t pDataReceived
Definition XrdClXCpCtx.hh:278
uint8_t pParallelChunks
Definition XrdClXCpCtx.hh:243
void RemoveSrc(XCpSrc *src)
Definition XrdClXCpCtx.hh:167
XCpSrc * WeakestLink(XCpSrc *exclude)
void PutChunk(PageInfo *chunk)
virtual ~XCpCtx()
uint64_t pOffset
Definition XrdClXCpCtx.hh:250
XCpCtx(const std::vector< std::string > &urls, uint64_t blockSize, uint8_t parallelSrc, uint64_t chunkSize, uint64_t parallelChunks, int64_t fileSize)
int64_t GetSize()
Definition XrdClXCpCtx.hh:129
void SetFileSize(int64_t size)
int64_t pFileSize
Definition XrdClXCpCtx.hh:255
std::pair< uint64_t, uint64_t > GetBlock()
size_t pRefCount
Definition XrdClXCpCtx.hh:300
std::queue< std::string > pUrls
Definition XrdClXCpCtx.hh:223
std::list< XCpSrc * > pSources
Definition XrdClXCpCtx.hh:267
XrdSysMutex pMtx
Definition XrdClXCpCtx.hh:295
XrdSysCondVar pDoneCV
Definition XrdClXCpCtx.hh:290
uint8_t pParallelSrc
Definition XrdClXCpCtx.hh:233
XRootDStatus Initialize()
XCpCtx * Self()
Definition XrdClXCpCtx.hh:77
XRootDStatus GetChunk(XrdCl::PageInfo &ci)
uint64_t pBlockSize
Definition XrdClXCpCtx.hh:228
bool pDone
Definition XrdClXCpCtx.hh:284
Definition XrdClXCpSrc.hh:38
Request status.
Definition XrdClXRootDResponses.hh:219
Definition XrdSysPthread.hh:129
Definition XrdSysPthread.hh:79
void Broadcast()
Definition XrdSysPthread.hh:89
Definition XrdSysPthread.hh:263
void UnLock()
Definition XrdSysPthread.hh:274
Definition XrdSysPthread.hh:165
Definition XrdClAction.hh:34
Definition XrdClXRootDResponses.hh:956