25#ifndef __XRD_CL_FILE_STATE_HANDLER_HH__
26#define __XRD_CL_FILE_STATE_HANDLER_HH__
49 class PgReadRetryHandler;
50 class PgReadSubstitutionHandler;
97 friend class ::PgReadHandler;
98 friend class ::PgReadRetryHandler;
99 friend class ::PgReadSubstitutionHandler;
100 friend class ::OpenHandler;
146 const std::string &url,
150 time_t timeout = 0 );
167 std::shared_ptr<FileStateHandler> &self,
169 const std::string &url,
173 time_t timeout = 0 );
185 time_t timeout = 0 );
201 time_t timeout = 0 );
217 time_t timeout = 0 );
240 time_t timeout = 0 );
261 time_t timeout = 0 );
280 PgReadHandler *handler,
281 time_t timeout = 0 );
304 time_t timeout = 0 );
322 time_t timeout = 0 );
339 time_t timeout = 0 );
361 time_t timeout = 0 );
379 std::vector<uint32_t> &cksums,
381 time_t timeout = 0 );
400 time_t timeout = 0 );
419 std::vector<uint32_t> &cksums,
422 time_t timeout = 0 );
434 time_t timeout = 0 );
448 time_t timeout = 0 );
464 time_t timeout = 0 );
478 time_t timeout = 0 );
493 const struct iovec *
iov,
496 time_t timeout = 0 );
514 time_t timeout = 0 );
533 time_t timeout = 0 );
547 time_t timeout = 0 );
562 const std::vector<xattr_t> &attrs,
564 time_t timeout = 0 );
579 const std::vector<std::string> &attrs,
581 time_t timeout = 0 );
596 const std::vector<std::string> &attrs,
598 time_t timeout = 0 );
613 time_t timeout = 0 );
629 time_t timeout = 0 );
647 time_t timeout = 0 );
662 const struct iovec *
iov,
665 time_t timeout = 0 );
679 time_t timeout = 0 );
696 static void OnStateError( std::shared_ptr<FileStateHandler> &self,
706 const std::string &redirectUrl,
730 return pIsChannelEncrypted;
738 bool SetProperty(
const std::string &name,
const std::string &value );
745 bool GetProperty(
const std::string &name, std::string &value )
const;
766 void Tick( time_t now );
789 std::shared_ptr<FileStateHandler> &self )
791 return std::make_unique<FileStateHandlerTemplate>(self);
810 RequestData(): request(0), handler(0) {}
811 RequestData( Message *r, ResponseHandler *h,
812 const MessageSendParams &p ):
813 request(r), handler(h), params(p) {}
815 ResponseHandler *handler;
816 MessageSendParams params;
818 typedef std::list<RequestData> RequestList;
829 static Status XAttrOperationImpl( std::shared_ptr<FileStateHandler> &self,
832 const std::vector<T> &attrs,
833 ResponseHandler *handler,
834 time_t timeout = 0 );
839 static Status SendOrQueue( std::shared_ptr<FileStateHandler> &self,
842 ResponseHandler *handler,
843 MessageSendParams &sendParams );
848 bool IsRecoverable(
const XRootDStatus &stataus )
const;
857 static Status RecoverMessage( std::shared_ptr<FileStateHandler> &self,
859 bool callbackOnFailure =
true );
864 static Status RunRecovery( std::shared_ptr<FileStateHandler> &self );
869 static XRootDStatus SendClose( std::shared_ptr<FileStateHandler> &self,
875 bool IsReadOnly()
const;
880 static XRootDStatus ReOpenFileAtServer( std::shared_ptr<FileStateHandler> &self,
887 void FailMessage( RequestData rd, XRootDStatus status );
892 void FailQueuedMessages( XRootDStatus status );
897 static XRootDStatus FillFhTempl( std::shared_ptr<FileStateHandler> &self,
905 static XRootDStatus
OpenImpl( std::shared_ptr<FileStateHandler> &self,
906 const std::string &url,
909 ResponseHandler *handler,
910 time_t timeout = 0 );
915 void ReSendQueuedMessages();
920 void ReWriteFileHandle( Message *msg );
925 void ResetMonitoringVars()
927 pOpenTime.tv_sec = 0; pOpenTime.tv_usec = 0;
941 void MonitorClose(
const XRootDStatus *status );
950 XRootDStatus IssueRequest(
const URL &url,
952 ResponseHandler *handler,
953 MessageSendParams &sendParams );
958 static XRootDStatus WriteKernelBuffer( std::shared_ptr<FileStateHandler> &self,
961 std::unique_ptr<XrdSys::KernelBuffer> kbuff,
962 ResponseHandler *handler,
965 mutable XrdSysMutex pMutex;
967 XRootDStatus pStatus;
973 URL *pWrtRecoveryRedir;
974 uint8_t *pFileHandle;
977 RequestList pToBeRecovered;
978 std::set<Message*> pInTheFly;
981 bool pDoRecoverWrite;
982 bool pFollowRedirects;
983 bool pUseVirtRedirector;
984 bool pIsChannelEncrypted;
985 bool pAllowBundledClose;
1000 XRootDStatus pCloseReason;
1005 LocalFileHandler *pLFileHandler;
1010 FilePlugIn *&pPlugin;
1015 std::weak_ptr<FileStateHandler> pTemplateFileWp;
#define XRDOUC_ENUM_OPERATORS(T)
Binary blob representation.
An interface for file plug-ins.
FileStateHandlerTemplate(std::shared_ptr< FileStateHandler > fhp)
~FileStateHandlerTemplate()
std::weak_ptr< FileStateHandler > pTemplateFileWp
Handle the stateful operations.
static XRootDStatus PgReadRetry(std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, size_t pgnb, void *buffer, PgReadHandler *handler, time_t timeout=0)
static XRootDStatus TryOtherServer(std::shared_ptr< FileStateHandler > &self, time_t timeout)
Try other data server.
void AfterForkChild()
Called in the child process after the fork.
static XRootDStatus Clone(std::shared_ptr< FileStateHandler > &self, const CloneLocations &locs, ResponseHandler *handler, time_t timeout=0)
static void OnStateRedirection(std::shared_ptr< FileStateHandler > &self, const std::string &redirectUrl, Message *message, ResponseHandler *userHandler, MessageSendParams &sendParams)
Handle stateful redirect.
void TimeOutRequests(time_t now)
Declare timeout on requests being recovered.
void Tick(time_t now)
Tick.
bool NeedFileTempl() const
Checks if we need to set a file template.
static void OnStateError(std::shared_ptr< FileStateHandler > &self, XRootDStatus *status, Message *message, ResponseHandler *userHandler, MessageSendParams &sendParams)
Handle an error while sending a stateful message.
FileStateHandler(FilePlugIn *&plugin)
Constructor.
static std::unique_ptr< ExportedFileTemplate > ExportTemplate(std::shared_ptr< FileStateHandler > &self)
FileStatus
State of the file.
@ OpenInProgress
Opening is in progress.
@ CloseInProgress
Closing operation is in progress.
@ Closed
The file is closed.
@ Opened
Opening has succeeded.
@ Error
Opening has failed.
@ Recovering
Recovering from an error.
void UnLock()
Unlock the internal lock.
static XRootDStatus PgWriteRetry(std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, uint32_t digest, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus ReadV(std::shared_ptr< FileStateHandler > &self, uint64_t offset, struct iovec *iov, int iovcnt, ResponseHandler *handler, time_t timeout=0)
bool SetProperty(const std::string &name, const std::string &value)
static void OnStateResponse(std::shared_ptr< FileStateHandler > &self, XRootDStatus *status, Message *message, AnyObject *response, HostList *hostList)
Handle stateful response.
void OnClose(const XRootDStatus *status)
Process the results of the closing operation.
void OnOpen(const XRootDStatus *status, const OpenInfo *openInfo, const HostList *hostList)
Process the results of the opening operation.
static XRootDStatus OpenUsingTemplate(std::shared_ptr< FileStateHandler > &self, ExportedFileTemplate *templ, const std::string &url, OpenFlags::Flags flags, uint16_t mode, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus PreRead(std::shared_ptr< FileStateHandler > &self, const TractList &tracts, ResponseHandler *handler, time_t timeout=0)
bool IsSecure() const
Check if the file is using an encrypted connection.
bool GetProperty(const std::string &name, std::string &value) const
bool IsOpen() const
Check if the file is open.
void Lock()
Lock the internal lock.
The message representation used throughout the system.
OpenImpl(Ctx< File > f, Arg< std::string > url, Arg< OpenFlags::Flags > flags, Arg< Access::Mode > mode=Access::None)
Constructor (.
Information returned by file open operation.
Handle an async response.
ReadImpl< false > Read(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, time_t timeout=0)
Factory for creating ReadImpl objects.
GetXAttrImpl< false > GetXAttr(Ctx< File > file, Arg< std::string > name)
VectorReadImpl< false > VectorRead(Ctx< File > file, Arg< ChunkList > chunks, Arg< void * > buffer, time_t timeout=0)
Factory for creating VectorReadImpl objects.
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, time_t timeout=0)
std::vector< HostInfo > HostList
DelXAttrImpl< false > DelXAttr(Ctx< File > file, Arg< std::string > name)
WriteVImpl< false > WriteV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec > > iov, time_t timeout=0)
Factory for creating WriteVImpl objects.
PgWriteImpl< false > PgWrite(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, Arg< std::vector< uint32_t > > cksums, time_t timeout=0)
Factory for creating PgReadImpl objects.
CloseImpl< false > Close(Ctx< File > file, time_t timeout=0)
Factory for creating CloseImpl objects.
SetXAttrImpl< false > SetXAttr(Ctx< File > file, Arg< std::string > name, Arg< std::string > value)
SyncImpl< false > Sync(Ctx< File > file, time_t timeout=0)
Factory for creating SyncImpl objects.
std::vector< TractInfo > TractList
List of Tracts.
PgReadImpl< false > PgRead(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, time_t timeout=0)
Factory for creating PgReadImpl objects.
ListXAttrImpl< false > ListXAttr(Ctx< File > file)
std::vector< ChunkInfo > ChunkList
List of chunks.
CheckpointImpl< false > Checkpoint(Ctx< File > file, Arg< ChkPtCode > code, time_t timeout=0)
Factory for creating ReadImpl objects.
OpenImpl< false > Open(Ctx< File > file, Arg< std::string > url, Arg< OpenFlags::Flags > flags, Arg< Access::Mode > mode=Access::None, time_t timeout=0)
Factory for creating ReadImpl objects.
WriteImpl< false > Write(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< const void * > buffer, time_t timeout=0)
Factory for creating WriteImpl objects.
VectorWriteImpl< false > VectorWrite(Ctx< File > file, Arg< ChunkList > chunks, time_t timeout=0)
Factory for creating VectorWriteImpl objects.
ChkptWrtImpl< false > ChkptWrt(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< const void * > buffer, time_t timeout=0)
Factory for creating ReadImpl objects.
TruncateImpl< false > Truncate(Ctx< File > file, Arg< uint64_t > size, time_t timeout)
ChkptWrtVImpl< false > ChkptWrtV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec > > iov, time_t timeout=0)
Factory for creating ChkptWrtVImpl objects.
Flags
Open flags, may be or'd when appropriate.
@ Samefs
Open file on the same filesystem as another.
@ Dup
Open file duplicating content from another.
Code
XRootD query request codes.
Status(uint16_t st=stOK, uint16_t cod=errNone, uint32_t errN=0)
Constructor.