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;
935 pCloseReason = Status();
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.
static XRootDStatus Read(std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus SetXAttr(std::shared_ptr< FileStateHandler > &self, const std::vector< xattr_t > &attrs, ResponseHandler *handler, time_t timeout=0)
void AfterForkChild()
Called in the child process after the fork.
static XRootDStatus PgReadImpl(std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, void *buffer, uint16_t flags, ResponseHandler *handler, time_t timeout=0)
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.
static XRootDStatus ListXAttr(std::shared_ptr< FileStateHandler > &self, ResponseHandler *handler, time_t timeout=0)
void Tick(time_t now)
Tick.
static XRootDStatus Truncate(std::shared_ptr< FileStateHandler > &self, uint64_t size, ResponseHandler *handler, time_t timeout=0)
bool NeedFileTempl() const
Checks if we need to set a file template.
static XRootDStatus Checkpoint(std::shared_ptr< FileStateHandler > &self, kXR_char code, ResponseHandler *handler, time_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, time_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.
FileStateHandler(FilePlugIn *&plugin)
Constructor.
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, time_t timeout=0)
static std::unique_ptr< ExportedFileTemplate > ExportTemplate(std::shared_ptr< FileStateHandler > &self)
static XRootDStatus ChkptWrt(std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus Write(std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, time_t timeout=0)
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 Close(std::shared_ptr< FileStateHandler > &self, 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.
static XRootDStatus DelXAttr(std::shared_ptr< FileStateHandler > &self, const std::vector< std::string > &attrs, ResponseHandler *handler, time_t timeout=0)
void OnOpen(const XRootDStatus *status, const OpenInfo *openInfo, const HostList *hostList)
Process the results of the opening operation.
static XRootDStatus Open(std::shared_ptr< FileStateHandler > &self, const std::string &url, OpenFlags::Flags flags, uint16_t mode, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus PgRead(std::shared_ptr< FileStateHandler > &self, uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, time_t timeout=0)
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 Sync(std::shared_ptr< FileStateHandler > &self, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus PreRead(std::shared_ptr< FileStateHandler > &self, const TractList &tracts, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus ChkptWrtV(std::shared_ptr< FileStateHandler > &self, uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus GetXAttr(std::shared_ptr< FileStateHandler > &self, const std::vector< std::string > &attrs, ResponseHandler *handler, time_t timeout=0)
bool IsSecure() const
Check if the file is using an encrypted connection.
static XRootDStatus WriteV(std::shared_ptr< FileStateHandler > &self, uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, time_t timeout=0)
~FileStateHandler()
Destructor.
bool GetProperty(const std::string &name, std::string &value) const
static XRootDStatus VectorRead(std::shared_ptr< FileStateHandler > &self, const ChunkList &chunks, void *buffer, ResponseHandler *handler, time_t timeout=0)
static XRootDStatus VectorWrite(std::shared_ptr< FileStateHandler > &self, const ChunkList &chunks, ResponseHandler *handler, time_t timeout=0)
bool IsOpen() const
Check if the file is open.
void Lock()
Lock the internal lock.
The message representation used throughout the system.
Information returned by file open operation.
Handle an async response.
std::vector< HostInfo > HostList
std::vector< TractInfo > TractList
List of Tracts.
std::vector< ChunkInfo > ChunkList
List of chunks.
static const int kXR_pgRetry
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.