xrootd
Loading...
Searching...
No Matches
XrdClCheckpointOperation.hh
Go to the documentation of this file.
1/*
2 * XrdClCheckpointOperation.hh
3 *
4 * Created on: 31 May 2021
5 * Author: simonm
6 */
7
8#ifndef SRC_XRDCL_XRDCLCHECKPOINTOPERATION_HH_
9#define SRC_XRDCL_XRDCLCHECKPOINTOPERATION_HH_
10
12
13namespace XrdCl
14{
15 //----------------------------------------------------------------------------
17 //----------------------------------------------------------------------------
22
23 //----------------------------------------------------------------------------
25 //----------------------------------------------------------------------------
26 template<bool HasHndl>
27 class CheckpointImpl: public FileOperation<CheckpointImpl, HasHndl, Resp<void>,
28 Arg<ChkPtCode>>
29 {
30 public:
31
32 //------------------------------------------------------------------------
34 //------------------------------------------------------------------------
37
38 //------------------------------------------------------------------------
40 //------------------------------------------------------------------------
41 enum { CodeArg };
42
43 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
46 std::string ToString()
47 {
48 return "Checkpoint";
49 }
50
51 protected:
52
53 //------------------------------------------------------------------------
59 //------------------------------------------------------------------------
60 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
61 {
62 ChkPtCode code = std::get<CodeArg>( this->args ).Get();
63 uint16_t timeout = pipelineTimeout < this->timeout ?
64 pipelineTimeout : this->timeout;
65 return this->file->Checkpoint( code, handler, timeout );
66 }
67 };
68
69 //----------------------------------------------------------------------------
71 //----------------------------------------------------------------------------
72 inline CheckpointImpl<false> Checkpoint( Ctx<File> file, Arg<ChkPtCode> code, uint16_t timeout = 0 )
73 {
74 return CheckpointImpl<false>( std::move( file ), std::move( code ) ).Timeout( timeout );
75 }
76
77
78 //----------------------------------------------------------------------------
80 //----------------------------------------------------------------------------
81 template<bool HasHndl>
82 class ChkptWrtImpl: public FileOperation<ChkptWrtImpl, HasHndl, Resp<void>,
83 Arg<uint64_t>, Arg<uint32_t>, Arg<const void*>>
84 {
85 public:
86
87 //------------------------------------------------------------------------
89 //------------------------------------------------------------------------
92
93 //------------------------------------------------------------------------
95 //------------------------------------------------------------------------
96 enum { OffArg, LenArg, BufArg };
97
98 //------------------------------------------------------------------------
100 //------------------------------------------------------------------------
101 std::string ToString()
102 {
103 return "ChkptWrt";
104 }
105
106 protected:
107
108 //------------------------------------------------------------------------
114 //------------------------------------------------------------------------
115 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
116 {
117 uint64_t off = std::get<OffArg>( this->args ).Get();
118 uint32_t len = std::get<LenArg>( this->args ).Get();
119 const void* buf = std::get<BufArg>( this->args ).Get();
120 uint16_t timeout = pipelineTimeout < this->timeout ?
121 pipelineTimeout : this->timeout;
122 return this->file->ChkptWrt( off, len, buf, handler, timeout );
123 }
124 };
125
126 //----------------------------------------------------------------------------
128 //----------------------------------------------------------------------------
130 Arg<uint32_t> size, Arg<const void*> buffer,
131 uint16_t timeout = 0 )
132 {
133 return ChkptWrtImpl<false>( std::move( file ), std::move( offset ),
134 std::move( size ), std::move( buffer ) ).Timeout( timeout );
135 }
136
137
138 //----------------------------------------------------------------------------
140 //----------------------------------------------------------------------------
141 template<bool HasHndl>
142 class ChkptWrtVImpl: public FileOperation<ChkptWrtVImpl, HasHndl, Resp<void>,
143 Arg<uint64_t>, Arg<std::vector<iovec>>>
144 {
145 public:
146
147 //------------------------------------------------------------------------
149 //------------------------------------------------------------------------
150 using FileOperation<ChkptWrtVImpl, HasHndl, Resp<void>,
152
153 //------------------------------------------------------------------------
155 //------------------------------------------------------------------------
156 enum { OffArg, IovecArg, };
157
158 //------------------------------------------------------------------------
160 //------------------------------------------------------------------------
161 std::string ToString()
162 {
163 return "ChkptWrtV";
164 }
165
166 protected:
167
168 //------------------------------------------------------------------------
174 //------------------------------------------------------------------------
175 XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
176 {
177 uint64_t off = std::get<OffArg>( this->args ).Get();
178 std::vector<iovec> &stdiov = std::get<IovecArg>( this->args ).Get();
179 uint16_t timeout = pipelineTimeout < this->timeout ?
180 pipelineTimeout : this->timeout;
181
182 int iovcnt = stdiov.size();
183 iovec iov[iovcnt];
184 for( size_t i = 0; i < stdiov.size(); ++i )
185 {
186 iov[i].iov_base = stdiov[i].iov_base;
187 iov[i].iov_len = stdiov[i].iov_len;
188 }
189
190 return this->file->ChkptWrtV( off, iov, iovcnt, handler, timeout );
191 }
192 };
193
194 //----------------------------------------------------------------------------
196 //----------------------------------------------------------------------------
198 Arg<std::vector<iovec>> iov,
199 uint16_t timeout = 0 )
200 {
201 return ChkptWrtVImpl<false>( std::move( file ), std::move( offset ),
202 std::move( iov ) ).Timeout( timeout );
203 }
204}
205
206#endif /* SRC_XRDCL_XRDCLCHECKPOINTOPERATION_HH_ */
static const int kXR_ckpRollback
Definition XProtocol.hh:215
static const int kXR_ckpCommit
Definition XProtocol.hh:213
static const int kXR_ckpBegin
Definition XProtocol.hh:212
Definition XrdClArg.hh:234
Checkpoint operation (.
Definition XrdClCheckpointOperation.hh:29
std::string ToString()
Definition XrdClCheckpointOperation.hh:46
@ CodeArg
Definition XrdClCheckpointOperation.hh:41
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClCheckpointOperation.hh:60
Checkpointed write operation (.
Definition XrdClCheckpointOperation.hh:84
@ BufArg
Definition XrdClCheckpointOperation.hh:96
@ LenArg
Definition XrdClCheckpointOperation.hh:96
@ OffArg
Definition XrdClCheckpointOperation.hh:96
std::string ToString()
Definition XrdClCheckpointOperation.hh:101
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClCheckpointOperation.hh:115
Checkpointed WriteV operation (.
Definition XrdClCheckpointOperation.hh:144
@ IovecArg
Definition XrdClCheckpointOperation.hh:156
@ OffArg
Definition XrdClCheckpointOperation.hh:156
std::string ToString()
Definition XrdClCheckpointOperation.hh:161
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClCheckpointOperation.hh:175
std::tuple< Args... > args
Operation arguments.
Definition XrdClOperations.hh:771
Derived< HasHndl > Timeout(uint16_t timeout)
Set operation timeout.
Definition XrdClOperations.hh:681
uint16_t timeout
Operation timeout.
Definition XrdClOperations.hh:776
Definition XrdClFileOperations.hh:46
Ctx< File > file
The file object itself.
Definition XrdClFileOperations.hh:88
std::unique_ptr< PipelineHandler > handler
Operation handler.
Definition XrdClOperations.hh:309
Definition XrdClOperations.hh:64
Request status.
Definition XrdClXRootDResponses.hh:219
Definition XrdClAction.hh:34
ChkptWrtImpl< false > ChkptWrt(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< const void * > buffer, uint16_t timeout=0)
Factory for creating ReadImpl objects.
Definition XrdClCheckpointOperation.hh:129
CheckpointImpl< false > Checkpoint(Ctx< File > file, Arg< ChkPtCode > code, uint16_t timeout=0)
Factory for creating ReadImpl objects.
Definition XrdClCheckpointOperation.hh:72
ChkPtCode
Checkpoint operation code.
Definition XrdClCheckpointOperation.hh:19
@ BEGIN
Definition XrdClCheckpointOperation.hh:20
@ COMMIT
Definition XrdClCheckpointOperation.hh:20
@ ROLLBACK
Definition XrdClCheckpointOperation.hh:20
ChkptWrtVImpl< false > ChkptWrtV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec > > iov, uint16_t timeout=0)
Factory for creating ChkptWrtVImpl objects.
Definition XrdClCheckpointOperation.hh:197
Utility class for storing a pointer to operation context.
Definition XrdClCtx.hh:39
Definition XrdClOperationHandlers.hh:662
Definition XrdOucIOVec.hh:65