Loading...
Searching...
No Matches
XrdClCheckpointOperation.hh
Go to the documentation of this file.
/*
* XrdClCheckpointOperation.hh
*
* Created on: 31 May 2021
* Author: simonm
*/
#ifndef SRC_XRDCL_XRDCLCHECKPOINTOPERATION_HH_
#define SRC_XRDCL_XRDCLCHECKPOINTOPERATION_HH_
#include "XrdCl/XrdClFileOperations.hh"
namespace XrdCl
{
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
enum ChkPtCode
{
BEGIN = kXR_ckpBegin, COMMIT = kXR_ckpCommit, ROLLBACK = kXR_ckpRollback
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
template<bool HasHndl>
class CheckpointImpl: public FileOperation<CheckpointImpl, HasHndl, Resp<void>,
Arg<ChkPtCode>>
{
public:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
using FileOperation<CheckpointImpl, HasHndl, Resp<void>,
Arg<ChkPtCode>>::FileOperation;
//------------------------------------------------------------------------
//------------------------------------------------------------------------
enum { CodeArg };
//------------------------------------------------------------------------
//------------------------------------------------------------------------
std::string ToString()
{
return "Checkpoint";
}
protected:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
{
ChkPtCode code = std::get<CodeArg>( this->args ).Get();
uint16_t timeout = pipelineTimeout < this->timeout ?
pipelineTimeout : this->timeout;
return this->file->Checkpoint( code, handler, timeout );
}
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
inline CheckpointImpl<false> Checkpoint( Ctx<File> file, Arg<ChkPtCode> code, uint16_t timeout = 0 )
{
return CheckpointImpl<false>( std::move( file ), std::move( code ) ).Timeout( timeout );
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
template<bool HasHndl>
class ChkptWrtImpl: public FileOperation<ChkptWrtImpl, HasHndl, Resp<void>,
Arg<uint64_t>, Arg<uint32_t>, Arg<const void*>>
{
public:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
using FileOperation<ChkptWrtImpl, HasHndl, Resp<void>,
Arg<uint64_t>, Arg<uint32_t>, Arg<const void*>>::FileOperation;
//------------------------------------------------------------------------
//------------------------------------------------------------------------
enum { OffArg, LenArg, BufArg };
//------------------------------------------------------------------------
//------------------------------------------------------------------------
std::string ToString()
{
return "ChkptWrt";
}
protected:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
{
uint64_t off = std::get<OffArg>( this->args ).Get();
uint32_t len = std::get<LenArg>( this->args ).Get();
const void* buf = std::get<BufArg>( this->args ).Get();
uint16_t timeout = pipelineTimeout < this->timeout ?
pipelineTimeout : this->timeout;
return this->file->ChkptWrt( off, len, buf, handler, timeout );
}
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
inline ChkptWrtImpl<false> ChkptWrt( Ctx<File> file, Arg<uint64_t> offset,
Arg<uint32_t> size, Arg<const void*> buffer,
uint16_t timeout = 0 )
{
return ChkptWrtImpl<false>( std::move( file ), std::move( offset ),
std::move( size ), std::move( buffer ) ).Timeout( timeout );
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
template<bool HasHndl>
class ChkptWrtVImpl: public FileOperation<ChkptWrtVImpl, HasHndl, Resp<void>,
Arg<uint64_t>, Arg<std::vector<iovec>>>
{
public:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
using FileOperation<ChkptWrtVImpl, HasHndl, Resp<void>,
Arg<uint64_t>, Arg<std::vector<iovec>>>::FileOperation;
//------------------------------------------------------------------------
//------------------------------------------------------------------------
enum { OffArg, IovecArg, };
//------------------------------------------------------------------------
//------------------------------------------------------------------------
std::string ToString()
{
return "ChkptWrtV";
}
protected:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
XRootDStatus RunImpl( PipelineHandler *handler, uint16_t pipelineTimeout )
{
uint64_t off = std::get<OffArg>( this->args ).Get();
std::vector<iovec> &stdiov = std::get<IovecArg>( this->args ).Get();
uint16_t timeout = pipelineTimeout < this->timeout ?
pipelineTimeout : this->timeout;
int iovcnt = stdiov.size();
iovec iov[iovcnt];
for( size_t i = 0; i < stdiov.size(); ++i )
{
iov[i].iov_base = stdiov[i].iov_base;
iov[i].iov_len = stdiov[i].iov_len;
}
return this->file->ChkptWrtV( off, iov, iovcnt, handler, timeout );
}
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
inline ChkptWrtVImpl<false> ChkptWrtV( Ctx<File> file, Arg<uint64_t> offset,
Arg<std::vector<iovec>> iov,
uint16_t timeout = 0 )
{
return ChkptWrtVImpl<false>( std::move( file ), std::move( offset ),
std::move( iov ) ).Timeout( timeout );
}
}
#endif /* SRC_XRDCL_XRDCLCHECKPOINTOPERATION_HH_ */
kXR_ckpRollback
static const int kXR_ckpRollback
Definition XProtocol.hh:215
kXR_ckpCommit
static const int kXR_ckpCommit
Definition XProtocol.hh:213
kXR_ckpBegin
static const int kXR_ckpBegin
Definition XProtocol.hh:212
XrdClFileOperations.hh
XrdCl::Arg
Definition XrdClArg.hh:234
XrdCl::CheckpointImpl
Checkpoint operation (.
Definition XrdClCheckpointOperation.hh:29
XrdCl::CheckpointImpl::CodeArg
@ CodeArg
Definition XrdClCheckpointOperation.hh:41
XrdCl::CheckpointImpl::ToString
std::string ToString()
Definition XrdClCheckpointOperation.hh:46
XrdCl::CheckpointImpl::RunImpl
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClCheckpointOperation.hh:60
XrdCl::ChkptWrtImpl
Checkpointed write operation (.
Definition XrdClCheckpointOperation.hh:84
XrdCl::ChkptWrtImpl::BufArg
@ BufArg
Definition XrdClCheckpointOperation.hh:96
XrdCl::ChkptWrtImpl::LenArg
@ LenArg
Definition XrdClCheckpointOperation.hh:96
XrdCl::ChkptWrtImpl::OffArg
@ OffArg
Definition XrdClCheckpointOperation.hh:96
XrdCl::ChkptWrtImpl::ToString
std::string ToString()
Definition XrdClCheckpointOperation.hh:101
XrdCl::ChkptWrtImpl::RunImpl
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClCheckpointOperation.hh:115
XrdCl::ChkptWrtVImpl
Checkpointed WriteV operation (.
Definition XrdClCheckpointOperation.hh:144
XrdCl::ChkptWrtVImpl::ToString
std::string ToString()
Definition XrdClCheckpointOperation.hh:161
XrdCl::ChkptWrtVImpl::IovecArg
@ IovecArg
Definition XrdClCheckpointOperation.hh:156
XrdCl::ChkptWrtVImpl::OffArg
@ OffArg
Definition XrdClCheckpointOperation.hh:156
XrdCl::ChkptWrtVImpl::RunImpl
XRootDStatus RunImpl(PipelineHandler *handler, uint16_t pipelineTimeout)
Definition XrdClCheckpointOperation.hh:175
XrdCl::ConcreteOperation< CheckpointImpl, HasHndl, Resp< void >, Arguments... >::args
std::tuple< Args... > args
Definition XrdClOperations.hh:737
XrdCl::ConcreteOperation::Timeout
Derived< HasHndl > Timeout(uint16_t timeout)
Set operation timeout.
Definition XrdClOperations.hh:647
XrdCl::ConcreteOperation< CheckpointImpl, HasHndl, Resp< void >, Arguments... >::timeout
uint16_t timeout
Definition XrdClOperations.hh:742
XrdCl::FileOperation< CheckpointImpl, HasHndl, Resp< void >, Arg< ChkPtCode > >::FileOperation
friend class FileOperation
Definition XrdClFileOperations.hh:48
XrdCl::FileOperation< CheckpointImpl, HasHndl, Resp< void >, Arg< ChkPtCode > >::file
Ctx< File > file
Definition XrdClFileOperations.hh:88
XrdCl::Operation::handler
std::unique_ptr< PipelineHandler > handler
Operation handler.
Definition XrdClOperations.hh:150
XrdCl::PipelineHandler
Definition XrdClOperations.hh:168
XrdCl::XRootDStatus
Request status.
Definition XrdClXRootDResponses.hh:219
XrdCl
Definition XrdClAction.hh:34
XrdCl::ChkptWrt
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
XrdCl::Checkpoint
CheckpointImpl< false > Checkpoint(Ctx< File > file, Arg< ChkPtCode > code, uint16_t timeout=0)
Factory for creating ReadImpl objects.
Definition XrdClCheckpointOperation.hh:72
XrdCl::ChkPtCode
ChkPtCode
Checkpoint operation code.
Definition XrdClCheckpointOperation.hh:19
XrdCl::BEGIN
@ BEGIN
Definition XrdClCheckpointOperation.hh:20
XrdCl::COMMIT
@ COMMIT
Definition XrdClCheckpointOperation.hh:20
XrdCl::ROLLBACK
@ ROLLBACK
Definition XrdClCheckpointOperation.hh:20
XrdCl::ChkptWrtV
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
XrdCl::Ctx
Utility class for storing a pointer to operation context.
Definition XrdClCtx.hh:39
XrdCl::Resp
Definition XrdClOperationHandlers.hh:670
iov
Definition XrdOucIOVec.hh:65