25 #ifndef __XRD_CL_FILE_STATE_HANDLER_HH__
26 #define __XRD_CL_FILE_STATE_HANDLER_HH__
49 class PgReadRetryHandler;
50 class PgReadSubstitutionHandler;
81 friend class ::PgReadHandler;
82 friend class ::PgReadRetryHandler;
83 friend class ::PgReadSubstitutionHandler;
84 friend class ::OpenHandler;
130 const std::string &url,
134 uint16_t timeout = 0 );
146 uint16_t timeout = 0 );
162 uint16_t timeout = 0 );
186 uint16_t timeout = 0 );
207 uint16_t timeout = 0 );
221 static XRootDStatus PgReadRetry( std::shared_ptr<FileStateHandler> &
self,
226 PgReadHandler *handler,
227 uint16_t timeout = 0 );
250 uint16_t timeout = 0 );
268 uint16_t timeout = 0 );
285 uint16_t timeout = 0 );
307 uint16_t timeout = 0 );
325 std::vector<uint32_t> &cksums,
327 uint16_t timeout = 0 );
340 static XRootDStatus PgWriteRetry( std::shared_ptr<FileStateHandler> &
self,
346 uint16_t timeout = 0 );
365 std::vector<uint32_t> &cksums,
368 uint16_t timeout = 0 );
380 uint16_t timeout = 0 );
394 uint16_t timeout = 0 );
410 uint16_t timeout = 0 );
424 uint16_t timeout = 0 );
439 const struct iovec *
iov,
442 uint16_t timeout = 0 );
455 static XRootDStatus ReadV( std::shared_ptr<FileStateHandler> &
self,
460 uint16_t timeout = 0 );
477 uint16_t timeout = 0 );
491 uint16_t timeout = 0 );
506 const std::vector<xattr_t> &attrs,
508 uint16_t timeout = 0 );
523 const std::vector<std::string> &attrs,
525 uint16_t timeout = 0 );
540 const std::vector<std::string> &attrs,
542 uint16_t timeout = 0 );
557 uint16_t timeout = 0 );
573 uint16_t timeout = 0 );
591 uint16_t timeout = 0 );
606 const struct iovec *
iov,
609 uint16_t timeout = 0 );
626 static void OnStateError( std::shared_ptr<FileStateHandler> &
self,
635 static void OnStateRedirection( std::shared_ptr<FileStateHandler> &
self,
636 const std::string &redirectUrl,
644 static void OnStateResponse( std::shared_ptr<FileStateHandler> &
self,
660 return pIsChannelEncrypted;
668 bool SetProperty(
const std::string &name,
const std::string &value );
675 bool GetProperty(
const std::string &name, std::string &value )
const;
696 void Tick( time_t now );
701 void TimeOutRequests( time_t now );
706 void AfterForkChild();
711 static XRootDStatus TryOtherServer( std::shared_ptr<FileStateHandler> &
self,
720 RequestData(): request(0), handler(0) {}
721 RequestData( Message *r, ResponseHandler *h,
722 const MessageSendParams &p ):
723 request(r), handler(h), params(p) {}
725 ResponseHandler *handler;
726 MessageSendParams params;
728 typedef std::list<RequestData> RequestList;
739 static Status XAttrOperationImpl( std::shared_ptr<FileStateHandler> &
self,
742 const std::vector<T> &attrs,
743 ResponseHandler *handler,
744 uint16_t timeout = 0 );
749 static Status SendOrQueue( std::shared_ptr<FileStateHandler> &
self,
752 ResponseHandler *handler,
753 MessageSendParams &sendParams );
758 bool IsRecoverable(
const XRootDStatus &stataus )
const;
767 static Status RecoverMessage( std::shared_ptr<FileStateHandler> &
self,
769 bool callbackOnFailure =
true );
774 static Status RunRecovery( std::shared_ptr<FileStateHandler> &
self );
779 static XRootDStatus SendClose( std::shared_ptr<FileStateHandler> &
self,
785 bool IsReadOnly()
const;
790 static XRootDStatus ReOpenFileAtServer( std::shared_ptr<FileStateHandler> &
self,
797 void FailMessage( RequestData rd, XRootDStatus status );
802 void FailQueuedMessages( XRootDStatus status );
807 void ReSendQueuedMessages();
812 void ReWriteFileHandle( Message *msg );
817 void ResetMonitoringVars()
819 pOpenTime.tv_sec = 0; pOpenTime.tv_usec = 0;
827 pCloseReason = Status();
833 void MonitorClose(
const XRootDStatus *status );
842 XRootDStatus IssueRequest(
const URL &url,
844 ResponseHandler *handler,
845 MessageSendParams &sendParams );
850 static XRootDStatus WriteKernelBuffer( std::shared_ptr<FileStateHandler> &
self,
853 std::unique_ptr<XrdSys::KernelBuffer> kbuff,
854 ResponseHandler *handler,
858 FileStatus pFileState;
859 XRootDStatus pStatus;
865 URL *pWrtRecoveryRedir;
866 uint8_t *pFileHandle;
869 RequestList pToBeRecovered;
870 std::set<Message*> pInTheFly;
873 bool pDoRecoverWrite;
874 bool pFollowRedirects;
875 bool pUseVirtRedirector;
876 bool pIsChannelEncrypted;
877 bool pAllowBundledClose;
892 XRootDStatus pCloseReason;
897 LocalFileHandler *pLFileHandler;
902 FilePlugIn *&pPlugin;
#define XRDOUC_ENUM_OPERATORS(T)
Binary blob representation.
An interface for file plug-ins.
Handle the stateful operations.
FileStatus
State of the file.
@ OpenInProgress
Opening 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.
bool IsSecure() const
Check if the file is using an encrypted connection.
void Lock()
Lock the internal lock.
The message representation used throughout the system.
Information returned by file open operation.
Handle an async response.
VectorWriteImpl< false > VectorWrite(Ctx< File > file, Arg< ChunkList > chunks, uint16_t timeout=0)
Factory for creating VectorWriteImpl objects.
DelXAttrImpl< false > DelXAttr(Ctx< File > file, Arg< std::string > name)
CheckpointImpl< false > Checkpoint(Ctx< File > file, Arg< ChkPtCode > code, uint16_t timeout=0)
Factory for creating ReadImpl objects.
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, uint16_t timeout=0)
WriteImpl< false > Write(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< const void * > buffer, uint16_t timeout=0)
Factory for creating WriteImpl objects.
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.
SetXAttrImpl< false > SetXAttr(Ctx< File > file, Arg< std::string > name, Arg< std::string > value)
ReadImpl< false > Read(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout=0)
Factory for creating ReadImpl objects.
ChkptWrtVImpl< false > ChkptWrtV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec >> iov, uint16_t timeout=0)
Factory for creating ChkptWrtVImpl objects.
std::vector< HostInfo > HostList
GetXAttrImpl< false > GetXAttr(Ctx< File > file, Arg< std::string > name)
OpenImpl< false > Open(Ctx< File > file, Arg< std::string > url, Arg< OpenFlags::Flags > flags, Arg< Access::Mode > mode=Access::None, uint16_t timeout=0)
Factory for creating ReadImpl objects.
PgWriteImpl< false > PgWrite(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, Arg< std::vector< uint32_t >> cksums, uint16_t timeout=0)
Factory for creating PgReadImpl objects.
SyncImpl< false > Sync(Ctx< File > file, uint16_t timeout=0)
Factory for creating SyncImpl objects.
VectorReadImpl< false > VectorRead(Ctx< File > file, Arg< ChunkList > chunks, Arg< void * > buffer, uint16_t timeout=0)
Factory for creating VectorReadImpl objects.
std::vector< ChunkInfo > ChunkList
List of chunks.
TruncateImpl< false > Truncate(Ctx< File > file, Arg< uint64_t > size, uint16_t timeout)
ListXAttrImpl< false > ListXAttr(Ctx< File > file)
WriteVImpl< false > WriteV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec >> iov, uint16_t timeout=0)
Factory for creating WriteVImpl objects.
PgReadImpl< false > PgRead(Ctx< File > file, Arg< uint64_t > offset, Arg< uint32_t > size, Arg< void * > buffer, uint16_t timeout=0)
Factory for creating PgReadImpl objects.
CloseImpl< false > Close(Ctx< File > file, uint16_t timeout=0)
Factory for creating CloseImpl objects.
none object for initializing empty Optional
static const int kXR_pgRetry