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 time_t timeout = 0 );
146 time_t timeout = 0 );
162 time_t timeout = 0 );
186 time_t timeout = 0 );
207 time_t timeout = 0 );
221 static XRootDStatus PgReadRetry( std::shared_ptr<FileStateHandler> &
self,
226 PgReadHandler *handler,
227 time_t timeout = 0 );
250 time_t timeout = 0 );
268 time_t timeout = 0 );
285 time_t timeout = 0 );
307 time_t timeout = 0 );
325 std::vector<uint32_t> &cksums,
327 time_t timeout = 0 );
340 static XRootDStatus PgWriteRetry( std::shared_ptr<FileStateHandler> &
self,
346 time_t timeout = 0 );
365 std::vector<uint32_t> &cksums,
368 time_t timeout = 0 );
380 time_t timeout = 0 );
394 time_t timeout = 0 );
410 time_t timeout = 0 );
424 time_t timeout = 0 );
439 const struct iovec *
iov,
442 time_t timeout = 0 );
455 static XRootDStatus ReadV( std::shared_ptr<FileStateHandler> &
self,
460 time_t timeout = 0 );
477 time_t timeout = 0 );
491 time_t timeout = 0 );
506 const std::vector<xattr_t> &attrs,
508 time_t timeout = 0 );
523 const std::vector<std::string> &attrs,
525 time_t timeout = 0 );
540 const std::vector<std::string> &attrs,
542 time_t timeout = 0 );
557 time_t timeout = 0 );
573 time_t timeout = 0 );
591 time_t timeout = 0 );
606 const struct iovec *
iov,
609 time_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 time_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.
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.
WriteVImpl< false > WriteV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec >> iov, time_t timeout=0)
Factory for creating WriteVImpl objects.
DelXAttrImpl< false > DelXAttr(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, time_t timeout=0)
Factory for creating ReadImpl 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.
SetXAttrImpl< false > SetXAttr(Ctx< File > file, Arg< std::string > name, Arg< std::string > value)
TruncateImpl< false > Truncate(Ctx< File > file, Arg< uint64_t > size, time_t timeout)
StatImpl< false > Stat(Ctx< File > file, Arg< bool > force, time_t timeout=0)
std::vector< HostInfo > HostList
GetXAttrImpl< false > GetXAttr(Ctx< File > file, Arg< std::string > name)
ChkptWrtVImpl< false > ChkptWrtV(Ctx< File > file, Arg< uint64_t > offset, Arg< std::vector< iovec >> iov, time_t timeout=0)
Factory for creating ChkptWrtVImpl objects.
std::vector< ChunkInfo > ChunkList
List of chunks.
SyncImpl< false > Sync(Ctx< File > file, time_t timeout=0)
Factory for creating SyncImpl 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.
CloseImpl< false > Close(Ctx< File > file, time_t timeout=0)
Factory for creating CloseImpl objects.
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)
VectorReadImpl< false > VectorRead(Ctx< File > file, Arg< ChunkList > chunks, Arg< void * > buffer, time_t timeout=0)
Factory for creating VectorReadImpl 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.
CheckpointImpl< false > Checkpoint(Ctx< File > file, Arg< ChkPtCode > code, time_t timeout=0)
Factory for creating ReadImpl objects.
VectorWriteImpl< false > VectorWrite(Ctx< File > file, Arg< ChunkList > chunks, time_t timeout=0)
Factory for creating VectorWriteImpl objects.
none object for initializing empty Optional
static const int kXR_pgRetry