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
28
#include "
XrdCl/XrdClSyncQueue.hh
"
29
#include "
XrdCl/XrdClXRootDResponses.hh
"
30
#include "
XrdSys/XrdSysPthread.hh
"
31
32
#include <cstdint>
33
#include <iostream>
34
35
namespace
XrdCl
36
{
37
38
class
XCpSrc;
39
40
class
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
{
63
XrdSysMutexHelper
lck( pMtx );
64
--pRefCount;
65
if
( !pRefCount )
66
{
67
lck.
UnLock
();
68
delete
this
;
69
}
70
}
71
77
XCpCtx
*
Self
()
78
{
79
XrdSysMutexHelper
lck( pMtx );
80
++pRefCount;
81
return
this
;
82
}
83
91
bool
GetNextUrl
( std::string & url );
92
100
XCpSrc
*
WeakestLink
(
XCpSrc
*exclude );
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
{
131
XrdSysCondVarHelper
lck( pFileSizeCV );
132
while
( pFileSize < 0 && GetRunning() > 0 ) pFileSizeCV.
Wait
();
133
return
pFileSize;
134
}
135
144
XRootDStatus
Initialize
();
145
160
XRootDStatus
GetChunk
(
XrdCl::PageInfo
&ci );
161
167
void
RemoveSrc
(
XCpSrc
*src )
168
{
169
XrdSysMutexHelper
lck( pMtx );
170
pSources.remove( src );
171
}
172
180
void
NotifyIdleSrc
();
181
190
bool
AllDone
();
191
197
void
NotifyInitExpectant
()
198
{
199
pFileSizeCV.
Broadcast
();
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
233
uint8_t pParallelSrc;
234
238
uint32_t pChunkSize;
239
243
uint8_t pParallelChunks;
244
250
uint64_t pOffset;
251
255
int64_t pFileSize;
256
261
XrdSysCondVar
pFileSizeCV;
262
267
std::list<XCpSrc*> pSources;
268
273
SyncQueue<PageInfo*>
pSink;
274
278
uint64_t pDataReceived;
279
284
bool
pDone;
285
290
XrdSysCondVar
pDoneCV;
291
295
XrdSysMutex
pMtx;
296
300
size_t
pRefCount;
301
};
302
303
}
/* namespace XrdCl */
304
305
#endif
/* SRC_XRDCL_XRDCLXCPCTX_HH_ */
XrdClSyncQueue.hh
XrdClXRootDResponses.hh
XrdSysPthread.hh
XrdCl::SyncQueue
A synchronized queue.
Definition
XrdClSyncQueue.hh:33
XrdCl::XCpCtx
Definition
XrdClXCpCtx.hh:41
XrdCl::XCpCtx::Delete
void Delete()
Definition
XrdClXCpCtx.hh:61
XrdCl::XCpCtx::NotifyInitExpectant
void NotifyInitExpectant()
Definition
XrdClXCpCtx.hh:197
XrdCl::XCpCtx::NotifyIdleSrc
void NotifyIdleSrc()
Definition
XrdClXCpCtx.cc:172
XrdCl::XCpCtx::GetNextUrl
bool GetNextUrl(std::string &url)
Definition
XrdClXCpCtx.cc:57
XrdCl::XCpCtx::AllDone
bool AllDone()
Definition
XrdClXCpCtx.cc:177
XrdCl::XCpCtx::RemoveSrc
void RemoveSrc(XCpSrc *src)
Definition
XrdClXCpCtx.hh:167
XrdCl::XCpCtx::WeakestLink
XCpSrc * WeakestLink(XCpSrc *exclude)
Definition
XrdClXCpCtx.cc:66
XrdCl::XCpCtx::PutChunk
void PutChunk(PageInfo *chunk)
Definition
XrdClXCpCtx.cc:87
XrdCl::XCpCtx::XCpCtx
XCpCtx(const std::vector< std::string > &urls, uint64_t blockSize, uint8_t parallelSrc, uint64_t chunkSize, uint64_t parallelChunks, int64_t fileSize)
Definition
XrdClXCpCtx.cc:36
XrdCl::XCpCtx::GetSize
int64_t GetSize()
Definition
XrdClXCpCtx.hh:129
XrdCl::XCpCtx::SetFileSize
void SetFileSize(int64_t size)
Definition
XrdClXCpCtx.cc:104
XrdCl::XCpCtx::GetBlock
std::pair< uint64_t, uint64_t > GetBlock()
Definition
XrdClXCpCtx.cc:92
XrdCl::XCpCtx::Initialize
XRootDStatus Initialize()
Definition
XrdClXCpCtx.cc:121
XrdCl::XCpCtx::Self
XCpCtx * Self()
Definition
XrdClXCpCtx.hh:77
XrdCl::XCpCtx::GetChunk
XRootDStatus GetChunk(XrdCl::PageInfo &ci)
Definition
XrdClXCpCtx.cc:140
XrdCl::XCpSrc
Definition
XrdClXCpSrc.hh:38
XrdCl::XRootDStatus
Request status.
Definition
XrdClXRootDResponses.hh:219
XrdSysCondVarHelper
Definition
XrdSysPthread.hh:129
XrdSysCondVar
Definition
XrdSysPthread.hh:79
XrdSysCondVar::Wait
int Wait()
Definition
XrdSysPthread.cc:99
XrdSysCondVar::Broadcast
void Broadcast()
Definition
XrdSysPthread.hh:89
XrdSysMutexHelper
Definition
XrdSysPthread.hh:263
XrdSysMutexHelper::UnLock
void UnLock()
Definition
XrdSysPthread.hh:274
XrdSysMutex
Definition
XrdSysPthread.hh:165
XrdCl
Definition
XrdClAction.hh:34
XrdCl::PageInfo
Definition
XrdClXRootDResponses.hh:956
XrdCl
XrdClXCpCtx.hh
Generated by
1.10.0