xrootd
|
Handle the stateful operations. More...
#include <XrdClFileStateHandler.hh>
Classes | |
struct | RequestData |
Public Types | |
enum | FileStatus { Closed , Opened , Error , Recovering , OpenInProgress , CloseInProgress } |
State of the file. More... | |
Public Member Functions | |
FileStateHandler (FilePlugIn *&plugin) | |
Constructor. | |
FileStateHandler (bool useVirtRedirector, FilePlugIn *&plugin) | |
~FileStateHandler () | |
Destructor. | |
void | OnOpen (const XRootDStatus *status, const OpenInfo *openInfo, const HostList *hostList) |
Process the results of the opening operation. | |
void | OnClose (const XRootDStatus *status) |
Process the results of the closing operation. | |
bool | IsOpen () const |
Check if the file is open. | |
bool | IsSecure () const |
Check if the file is using an encrypted connection. | |
bool | SetProperty (const std::string &name, const std::string &value) |
bool | GetProperty (const std::string &name, std::string &value) const |
void | Lock () |
Lock the internal lock. | |
void | UnLock () |
Unlock the internal lock. | |
void | Tick (time_t now) |
Tick. | |
void | TimeOutRequests (time_t now) |
Declare timeout on requests being recovered. | |
void | AfterForkChild () |
Called in the child process after the fork. | |
Static Public Member Functions | |
static XRootDStatus | Open (std::shared_ptr< FileStateHandler > &self, const std::string &url, uint16_t flags, uint16_t mode, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Close (std::shared_ptr< FileStateHandler > &self, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Stat (std::shared_ptr< FileStateHandler > &self, bool force, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Read (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | PgRead (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | PgReadRetry (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, size_t pgnb, void *buffer, PgReadHandler *handler, uint16_t timeout=0) |
static XRootDStatus | PgReadImpl (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, void *buffer, uint16_t flags, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Write (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Write (std::shared_ptr< FileStateHandler > &self, uint64_t offset, Buffer &&buffer, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Write (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, Optional< uint64_t > fdoff, int fd, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | PgWrite (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, std::vector< uint32_t > &cksums, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | PgWriteRetry (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, uint32_t digest, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | PgWriteImpl (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, std::vector< uint32_t > &cksums, kXR_char flags, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Sync (std::shared_ptr< FileStateHandler > &self, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Truncate (std::shared_ptr< FileStateHandler > &self, uint64_t size, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | VectorRead (std::shared_ptr< FileStateHandler > &self, const ChunkList &chunks, void *buffer, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | VectorWrite (std::shared_ptr< FileStateHandler > &self, const ChunkList &chunks, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | WriteV (std::shared_ptr< FileStateHandler > &self, uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | ReadV (std::shared_ptr< FileStateHandler > &self, uint64_t offset, struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Fcntl (std::shared_ptr< FileStateHandler > &self, const Buffer &arg, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Visa (std::shared_ptr< FileStateHandler > &self, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | SetXAttr (std::shared_ptr< FileStateHandler > &self, const std::vector< xattr_t > &attrs, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | GetXAttr (std::shared_ptr< FileStateHandler > &self, const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | DelXAttr (std::shared_ptr< FileStateHandler > &self, const std::vector< std::string > &attrs, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | ListXAttr (std::shared_ptr< FileStateHandler > &self, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | Checkpoint (std::shared_ptr< FileStateHandler > &self, kXR_char code, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | ChkptWrt (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0) |
static XRootDStatus | ChkptWrtV (std::shared_ptr< FileStateHandler > &self, uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0) |
static void | OnStateError (std::shared_ptr< FileStateHandler > &self, XRootDStatus *status, Message *message, ResponseHandler *userHandler, MessageSendParams &sendParams) |
Handle an error while sending a stateful message. | |
static void | OnStateRedirection (std::shared_ptr< FileStateHandler > &self, const std::string &redirectUrl, Message *message, ResponseHandler *userHandler, MessageSendParams &sendParams) |
Handle stateful redirect. | |
static void | OnStateResponse (std::shared_ptr< FileStateHandler > &self, XRootDStatus *status, Message *message, AnyObject *response, HostList *hostList) |
Handle stateful response. | |
static XRootDStatus | TryOtherServer (std::shared_ptr< FileStateHandler > &self, uint16_t timeout) |
Try other data server. | |
Private Types | |
typedef std::list< RequestData > | RequestList |
Private Member Functions | |
bool | IsRecoverable (const XRootDStatus &stataus) const |
Check if the stateful error is recoverable. | |
bool | IsReadOnly () const |
Check if the file is open for read only. | |
void | FailMessage (RequestData rd, XRootDStatus status) |
Fail a message. | |
void | FailQueuedMessages (XRootDStatus status) |
Fail queued messages. | |
void | ReSendQueuedMessages () |
Re-send queued messages. | |
void | ReWriteFileHandle (Message *msg) |
Re-write file handle. | |
void | ResetMonitoringVars () |
Reset monitoring vars. | |
void | MonitorClose (const XRootDStatus *status) |
Dispatch monitoring information on close. | |
XRootDStatus | IssueRequest (const URL &url, Message *msg, ResponseHandler *handler, MessageSendParams &sendParams) |
Static Private Member Functions | |
template<typename T > | |
static Status | XAttrOperationImpl (std::shared_ptr< FileStateHandler > &self, kXR_char subcode, kXR_char options, const std::vector< T > &attrs, ResponseHandler *handler, uint16_t timeout=0) |
static Status | SendOrQueue (std::shared_ptr< FileStateHandler > &self, const URL &url, Message *msg, ResponseHandler *handler, MessageSendParams &sendParams) |
Send a message to a host or put it in the recovery queue. | |
static Status | RecoverMessage (std::shared_ptr< FileStateHandler > &self, RequestData rd, bool callbackOnFailure=true) |
static Status | RunRecovery (std::shared_ptr< FileStateHandler > &self) |
Run the recovery procedure if appropriate. | |
static XRootDStatus | SendClose (std::shared_ptr< FileStateHandler > &self, uint16_t timeout) |
static XRootDStatus | ReOpenFileAtServer (std::shared_ptr< FileStateHandler > &self, const URL &url, uint16_t timeout) |
Re-open the current file at a given server. | |
static XRootDStatus | WriteKernelBuffer (std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t length, std::unique_ptr< XrdSys::KernelBuffer > kbuff, ResponseHandler *handler, uint16_t timeout) |
Send a write request with payload being stored in a kernel buffer. | |
Private Attributes | |
XrdSysMutex | pMutex |
FileStatus | pFileState |
XRootDStatus | pStatus |
StatInfo * | pStatInfo |
URL * | pFileUrl |
URL * | pDataServer |
URL * | pLoadBalancer |
URL * | pStateRedirect |
URL * | pWrtRecoveryRedir |
uint8_t * | pFileHandle |
uint16_t | pOpenMode |
uint16_t | pOpenFlags |
RequestList | pToBeRecovered |
std::set< Message * > | pInTheFly |
uint64_t | pSessionId |
bool | pDoRecoverRead |
bool | pDoRecoverWrite |
bool | pFollowRedirects |
bool | pUseVirtRedirector |
bool | pIsChannelEncrypted |
bool | pAllowBundledClose |
timeval | pOpenTime |
uint64_t | pRBytes |
uint64_t | pVRBytes |
uint64_t | pWBytes |
uint64_t | pVWBytes |
uint64_t | pVSegs |
uint64_t | pRCount |
uint64_t | pVRCount |
uint64_t | pWCount |
uint64_t | pVWCount |
XRootDStatus | pCloseReason |
LocalFileHandler * | pLFileHandler |
FilePlugIn *& | pPlugin |
Friends | |
class | ::PgReadHandler |
class | ::PgReadRetryHandler |
class | ::PgReadSubstitutionHandler |
class | ::OpenHandler |
Handle the stateful operations.
|
private |
XrdCl::FileStateHandler::FileStateHandler | ( | FilePlugIn *& | plugin | ) |
Constructor.
XrdCl::FileStateHandler::FileStateHandler | ( | bool | useVirtRedirector, |
FilePlugIn *& | plugin | ||
) |
Constructor
useVirtRedirector | if true Metalink files will be treated as a VirtualRedirectors |
XrdCl::FileStateHandler::~FileStateHandler | ( | ) |
Destructor.
void XrdCl::FileStateHandler::AfterForkChild | ( | ) |
Called in the child process after the fork.
|
static |
Create a checkpoint
handler | : handler to be notified when the response arrives, the response parameter will hold a std::vector of XAttr objects |
timeout | : timeout value, if 0 the environment default will be used |
|
static |
Checkpointed write - async
offset | offset from the beginning of the file |
size | number of bytes to be written |
buffer | a pointer to the buffer holding the data to be written |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Checkpointed WriteV - async
offset | offset from the beginning of the file |
iov | list of the buffers to be written |
iovcnt | number of buffers |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 then the environment default will be used |
|
static |
Close the file object
handler | handler to be notified about the status of the operation |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Delete extended attributes - async
attrs | : list of extended attributes to set |
handler | : handler to be notified when the response arrives, the response parameter will hold a std::vector of XAttrStatus objects |
timeout | : timeout value, if 0 the environment default will be used |
|
private |
Fail a message.
|
private |
Fail queued messages.
|
static |
Performs a custom operation on an open file, server implementation dependent - async
arg | query argument |
handler | handler to be notified when the response arrives, the response parameter will hold a Buffer object if the procedure is successful |
timeout | timeout value, if 0 the environment default will be used |
bool XrdCl::FileStateHandler::GetProperty | ( | const std::string & | name, |
std::string & | value | ||
) | const |
Get file property
|
static |
Get extended attributes - async
attrs | : list of extended attributes to get |
handler | : handler to be notified when the response arrives, the response parameter will hold a std::vector of XAttr objects |
timeout | : timeout value, if 0 the environment default will be used |
bool XrdCl::FileStateHandler::IsOpen | ( | ) | const |
Check if the file is open.
|
private |
Check if the file is open for read only.
|
private |
Check if the stateful error is recoverable.
|
inline |
Check if the file is using an encrypted connection.
|
private |
Issues request:
|
static |
List extended attributes - async
handler | : handler to be notified when the response arrives, the response parameter will hold a std::vector of XAttr objects |
timeout | : timeout value, if 0 the environment default will be used |
|
inline |
Lock the internal lock.
|
private |
Dispatch monitoring information on close.
void XrdCl::FileStateHandler::OnClose | ( | const XRootDStatus * | status | ) |
Process the results of the closing operation.
void XrdCl::FileStateHandler::OnOpen | ( | const XRootDStatus * | status, |
const OpenInfo * | openInfo, | ||
const HostList * | hostList | ||
) |
Process the results of the opening operation.
|
static |
Handle an error while sending a stateful message.
|
static |
Handle stateful redirect.
|
static |
Handle stateful response.
|
static |
Open the file pointed to by the given URL
url | url of the file to be opened |
flags | OpenFlags::Flags |
mode | Access::Mode for new files, 0 otherwise |
handler | handler to be notified about the status of the operation |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Read data pages at a given offset
offset | : offset from the beginning of the file (Note: has to 4KB aligned) |
size | : buffer size |
buffer | : a pointer to buffer big enough to hold the data |
handler | : handler to be notified when the response arrives, the response parameter will hold a PgReadInfo object if the procedure was successful |
timeout | : timeout value, if 0 environment default will be used |
|
static |
Read data pages at a given offset (actual implementation)
offset | : offset from the beginning of the file (Note: has to 4KB aligned) |
size | : buffer size |
buffer | : a pointer to buffer big enough to hold the data |
flags | : PgRead flags |
handler | : handler to be notified when the response arrives, the response parameter will hold a PgReadInfo object if the procedure was successful |
timeout | : timeout value, if 0 environment default will be used |
|
static |
Retry reading one page of data at a given offset
offset | : offset from the beginning of the file (Note: has to 4KB aligned) |
size | : buffer size |
buffer | : a pointer to buffer big enough to hold the data |
handler | : handler to be notified when the response arrives |
timeout | : timeout value, if 0 environment default will be used |
|
static |
Write number of pages at a given offset - async
offset | offset from the beginning of the file |
size | buffer size |
buffer | a pointer to a buffer holding data pages |
cksums | the crc32c checksums for each 4KB page |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Write number of pages at a given offset - async
offset | offset from the beginning of the file |
size | buffer size |
buffer | a pointer to a buffer holding data pages |
cksums | the crc32c checksums for each 4KB page |
flags | PgWrite flags |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Write number of pages at a given offset - async
offset | offset from the beginning of the file |
size | buffer size |
buffer | a pointer to a buffer holding data pages |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Read a data chunk at a given offset - sync
offset | offset from the beginning of the file |
size | number of bytes to be read |
buffer | a pointer to a buffer big enough to hold the data or 0 if the buffer should be allocated by the system |
handler | handler to be notified when the response arrives, the response parameter will hold a buffer object if the procedure was successful, if a preallocated buffer was specified then the buffer object will "wrap" this buffer |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Read data into scattered buffers in one operation - async
offset | offset from the beginning of the file |
iov | list of the buffers to be written |
iovcnt | number of buffers |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 then the environment default will be used |
|
staticprivate |
Recover a message
rd | request data associated with the message |
callbackOnFailure | should the current handler be called back if the recovery procedure fails |
|
staticprivate |
Re-open the current file at a given server.
|
private |
Re-send queued messages.
|
inlineprivate |
Reset monitoring vars.
|
private |
Re-write file handle.
|
staticprivate |
Run the recovery procedure if appropriate.
|
staticprivate |
|
staticprivate |
Send a message to a host or put it in the recovery queue.
bool XrdCl::FileStateHandler::SetProperty | ( | const std::string & | name, |
const std::string & | value | ||
) |
Set file property
|
static |
Set extended attributes - async
attrs | : list of extended attributes to set |
handler | : handler to be notified when the response arrives, the response parameter will hold a std::vector of XAttrStatus objects |
timeout | : timeout value, if 0 the environment default will be used |
|
static |
Obtain status information for this file - async
force | do not use the cached information, force re-stating |
handler | handler to be notified when the response arrives, the response parameter will hold a StatInfo object if the procedure is successful |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Commit all pending disk writes - async
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
void XrdCl::FileStateHandler::Tick | ( | time_t | now | ) |
Tick.
void XrdCl::FileStateHandler::TimeOutRequests | ( | time_t | now | ) |
Declare timeout on requests being recovered.
|
static |
Truncate the file to a particular size - async
size | desired size of the file |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Try other data server.
|
inline |
Unlock the internal lock.
|
static |
Read scattered data chunks in one operation - async
chunks | list of the chunks to be read |
buffer | a pointer to a buffer big enough to hold the data |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 then the environment default will be used |
|
static |
Write scattered data chunks in one operation - async
chunks | list of the chunks to be read |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 then the environment default will be used |
|
static |
Get access token to a file - async
handler | handler to be notified when the response arrives, the response parameter will hold a Buffer object if the procedure is successful |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Write a data chunk at a given offset - async
offset | offset from the beginning of the file |
buffer | r-value reference to Buffer object, in this case XrdCl runtime takes ownership of the buffer |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Write a data chunk at a given offset - async
offset | offset from the beginning of the file |
size | number of bytes to be written |
buffer | a pointer to the buffer holding the data to be written |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
static |
Write a data from a given file descriptor at a given offset - async
offset | offset from the beginning of the file |
size | number of bytes to be written |
fdoff | offset of the data to be written from the file descriptor (optional, if not provided will copy data from the file descriptor at the current cursor position) |
fd | file descriptor open for reading |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 the environment default will be used |
|
staticprivate |
Send a write request with payload being stored in a kernel buffer.
|
static |
Write scattered buffers in one operation - async
offset | offset from the beginning of the file |
iov | list of the buffers to be written |
iovcnt | number of buffers |
handler | handler to be notified when the response arrives |
timeout | timeout value, if 0 then the environment default will be used |
|
staticprivate |
Generic implementation of xattr operation
subcode | : xattr operation code |
attrs | : operation argument |
handler | : operation handler |
timeout | : operation timeout |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |