XrdCl::FileStateHandler Class Reference

Handle the stateful operations. More...

#include <XrdClFileStateHandler.hh>

Collaboration diagram for XrdCl::FileStateHandler:
Collaboration graph
[legend]

List of all members.

Classes

struct  RequestData

Public Types

enum  FileStatus {
  Closed, Opened, Error, Recovering,
  OpenInProgress, CloseInProgress
}
 

State of the file.

More...

Public Member Functions

 FileStateHandler ()
 Constructor.
 FileStateHandler (bool useVirtRedirector)
 ~FileStateHandler ()
 Destructor.
XRootDStatus Open (const std::string &url, uint16_t flags, uint16_t mode, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Close (ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Stat (bool force, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Read (uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Write (uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Sync (ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Truncate (uint64_t size, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus VectorRead (const ChunkList &chunks, void *buffer, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus VectorWrite (const ChunkList &chunks, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus WriteV (uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Fcntl (const Buffer &arg, ResponseHandler *handler, uint16_t timeout=0)
XRootDStatus Visa (ResponseHandler *handler, uint16_t timeout=0)
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.
void OnStateError (XRootDStatus *status, Message *message, ResponseHandler *userHandler, MessageSendParams &sendParams)
 Handle an error while sending a stateful message.
void OnStateRedirection (const std::string &redirectUrl, Message *message, ResponseHandler *userHandler, MessageSendParams &sendParams)
 Handle stateful redirect.
void OnStateResponse (XRootDStatus *status, Message *message, AnyObject *response, HostList *hostList)
 Handle stateful response.
bool IsOpen () const
 Check if the file is open.
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.

Private Types

typedef std::list< RequestDataRequestList

Private Member Functions

Status SendOrQueue (const URL &url, Message *msg, ResponseHandler *handler, MessageSendParams &sendParams)
 Send a message to a host or put it in the recovery queue.
bool IsRecoverable (const XRootDStatus &stataus) const
 Check if the stateful error is recoverable.
Status RecoverMessage (RequestData rd, bool callbackOnFailure=true)
Status RunRecovery ()
 Run the recovery procedure if appropriate.
Status SendClose (uint16_t timeout)
bool IsReadOnly () const
 Check if the file is open for read only.
Status ReOpenFileAtServer (const URL &url, uint16_t timeout)
 Re-open the current file at a given server.
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)

Private Attributes

XrdSysMutex pMutex
FileStatus pFileState
XRootDStatus pStatus
StatInfopStatInfo
URLpFileUrl
URLpDataServer
URLpLoadBalancer
URLpStateRedirect
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
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
ResponseHandlerHolder * pReOpenHandler
LocalFileHandlerpLFileHandler

Detailed Description

Handle the stateful operations.


Member Typedef Documentation

typedef std::list<RequestData> XrdCl::FileStateHandler::RequestList [private]

Member Enumeration Documentation

State of the file.

Enumerator:
Closed 

The file is closed.

Opened 

Opening has succeeded.

Error 

Opening has failed.

Recovering 

Recovering from an error.

OpenInProgress 

Opening is in progress.

CloseInProgress 

Closing operation is in progress.


Constructor & Destructor Documentation

XrdCl::FileStateHandler::FileStateHandler (  ) 

Constructor.

XrdCl::FileStateHandler::FileStateHandler ( bool  useVirtRedirector  ) 

Constructor

Parameters:
useVirtRedirector if true Metalink files will be treated as a VirtualRedirectors
XrdCl::FileStateHandler::~FileStateHandler (  ) 

Destructor.


Member Function Documentation

void XrdCl::FileStateHandler::AfterForkChild (  ) 

Called in the child process after the fork.

XRootDStatus XrdCl::FileStateHandler::Close ( ResponseHandler handler,
uint16_t  timeout = 0 
)

Close the file object

Parameters:
handler handler to be notified about the status of the operation
timeout timeout value, if 0 the environment default will be used
Returns:
status of the operation
void XrdCl::FileStateHandler::FailMessage ( RequestData  rd,
XRootDStatus  status 
) [private]

Fail a message.

void XrdCl::FileStateHandler::FailQueuedMessages ( XRootDStatus  status  )  [private]

Fail queued messages.

XRootDStatus XrdCl::FileStateHandler::Fcntl ( const Buffer arg,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Performs a custom operation on an open file, server implementation dependent - async

Parameters:
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
Returns:
status of the operation
bool XrdCl::FileStateHandler::GetProperty ( const std::string &  name,
std::string &  value 
) const

Get file property

See also:
File::SetProperty for property list
bool XrdCl::FileStateHandler::IsOpen (  )  const

Check if the file is open.

bool XrdCl::FileStateHandler::IsReadOnly (  )  const [private]

Check if the file is open for read only.

bool XrdCl::FileStateHandler::IsRecoverable ( const XRootDStatus stataus  )  const [private]

Check if the stateful error is recoverable.

XRootDStatus XrdCl::FileStateHandler::IssueRequest ( const URL url,
Message msg,
ResponseHandler handler,
MessageSendParams sendParams 
) [private]

Issues request:

  • if the request is for a Metalink a redirect is generated
  • if the request is for a local file, it will be passed to LocalFileHandler
  • otherwise vanilla XRootD request will be sent
void XrdCl::FileStateHandler::Lock (  )  [inline]

Lock the internal lock.

References XrdSysMutex::Lock(), and pMutex.

void XrdCl::FileStateHandler::MonitorClose ( const XRootDStatus status  )  [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.

void XrdCl::FileStateHandler::OnStateError ( XRootDStatus status,
Message message,
ResponseHandler userHandler,
MessageSendParams sendParams 
)

Handle an error while sending a stateful message.

void XrdCl::FileStateHandler::OnStateRedirection ( const std::string &  redirectUrl,
Message message,
ResponseHandler userHandler,
MessageSendParams sendParams 
)

Handle stateful redirect.

void XrdCl::FileStateHandler::OnStateResponse ( XRootDStatus status,
Message message,
AnyObject response,
HostList hostList 
)

Handle stateful response.

XRootDStatus XrdCl::FileStateHandler::Open ( const std::string &  url,
uint16_t  flags,
uint16_t  mode,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Open the file pointed to by the given URL

Parameters:
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
Returns:
status of the operation
XRootDStatus XrdCl::FileStateHandler::Read ( uint64_t  offset,
uint32_t  size,
void *  buffer,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Read a data chunk at a given offset - sync

Parameters:
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
Returns:
status of the operation
Status XrdCl::FileStateHandler::RecoverMessage ( RequestData  rd,
bool  callbackOnFailure = true 
) [private]

Recover a message

Parameters:
rd request data associated with the message
callbackOnFailure should the current handler be called back if the recovery procedure fails
Status XrdCl::FileStateHandler::ReOpenFileAtServer ( const URL url,
uint16_t  timeout 
) [private]

Re-open the current file at a given server.

void XrdCl::FileStateHandler::ReSendQueuedMessages (  )  [private]

Re-send queued messages.

void XrdCl::FileStateHandler::ResetMonitoringVars (  )  [inline, private]

Reset monitoring vars.

References pCloseReason, pOpenTime, pRBytes, pRCount, pVRBytes, pVRCount, pVSegs, pWBytes, and pWCount.

void XrdCl::FileStateHandler::ReWriteFileHandle ( Message msg  )  [private]

Re-write file handle.

Status XrdCl::FileStateHandler::RunRecovery (  )  [private]

Run the recovery procedure if appropriate.

Status XrdCl::FileStateHandler::SendClose ( uint16_t  timeout  )  [private]
Status XrdCl::FileStateHandler::SendOrQueue ( const URL url,
Message msg,
ResponseHandler handler,
MessageSendParams sendParams 
) [private]

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

See also:
File::GetProperty for propert list
XRootDStatus XrdCl::FileStateHandler::Stat ( bool  force,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Obtain status information for this file - async

Parameters:
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
Returns:
status of the operation
XRootDStatus XrdCl::FileStateHandler::Sync ( ResponseHandler handler,
uint16_t  timeout = 0 
)

Commit all pending disk writes - async

Parameters:
handler handler to be notified when the response arrives
timeout timeout value, if 0 the environment default will be used
Returns:
status of the operation
void XrdCl::FileStateHandler::Tick ( time_t  now  ) 

Tick.

void XrdCl::FileStateHandler::TimeOutRequests ( time_t  now  ) 

Declare timeout on requests being recovered.

XRootDStatus XrdCl::FileStateHandler::Truncate ( uint64_t  size,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Truncate the file to a particular size - async

Parameters:
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
Returns:
status of the operation
void XrdCl::FileStateHandler::UnLock (  )  [inline]

Unlock the internal lock.

References pMutex, and XrdSysMutex::UnLock().

XRootDStatus XrdCl::FileStateHandler::VectorRead ( const ChunkList chunks,
void *  buffer,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Read scattered data chunks in one operation - async

Parameters:
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
Returns:
status of the operation
XRootDStatus XrdCl::FileStateHandler::VectorWrite ( const ChunkList chunks,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Write scattered data chunks in one operation - async

Parameters:
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
Returns:
status of the operation
XRootDStatus XrdCl::FileStateHandler::Visa ( ResponseHandler handler,
uint16_t  timeout = 0 
)

Get access token to a file - async

Parameters:
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
Returns:
status of the operation
XRootDStatus XrdCl::FileStateHandler::Write ( uint64_t  offset,
uint32_t  size,
const void *  buffer,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Write a data chunk at a given offset - async

Parameters:
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
Returns:
status of the operation
XRootDStatus XrdCl::FileStateHandler::WriteV ( uint64_t  offset,
const struct iovec *  iov,
int  iovcnt,
ResponseHandler handler,
uint16_t  timeout = 0 
)

Write scattered buffers in one operation - async

Parameters:
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
Returns:
status of the operation

Member Data Documentation

Referenced by ResetMonitoringVars().

Referenced by Lock(), and UnLock().

Referenced by ResetMonitoringVars().

Referenced by ResetMonitoringVars().

Referenced by ResetMonitoringVars().

ResponseHandlerHolder* XrdCl::FileStateHandler::pReOpenHandler [private]

Referenced by ResetMonitoringVars().

Referenced by ResetMonitoringVars().

uint64_t XrdCl::FileStateHandler::pVSegs [private]

Referenced by ResetMonitoringVars().

Referenced by ResetMonitoringVars().

Referenced by ResetMonitoringVars().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 17 Dec 2019 for xrootd by  doxygen 1.6.1