xrootd
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
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 ()
 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)
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 (RedirectInfo *redirectInfo, 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.
void EnableReadRecovery (bool enable)
void EnableWriteRecovery (bool enable)
std::string GetDataServer () const
 Get the data server the file is accessed at.
URL GetLastURL () const
 Get final url with all the cgi information.
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< RequestData > RequestList

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.
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.

Private Attributes

XrdSysMutex pMutex
FileStatus pFileState
XRootDStatus pStatus
StatInfo * pStatInfo
URL * pFileUrl
URL * pDataServer
URL * pLoadBalancer
URL * pStateRedirect
uint8_t * pFileHandle
uint16_t pOpenMode
uint16_t pOpenFlags
RequestList pToBeRecovered
std::set< Message * > pInTheFly
uint64_t pSessionId
bool pDoRecoverRead
bool pDoRecoverWrite
timeval pOpenTime
uint64_t pRBytes
uint64_t pVBytes
uint64_t pWBytes
uint64_t pVSegs
uint64_t pRCount
uint64_t pVCount
uint64_t pWCount
XRootDStatus pCloseReason

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


Member Function Documentation

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

Enable/disable state recovery procedures while the file is open for reading

References pDoRecoverRead, and pMutex.

Referenced by XrdCl::File::EnableReadRecovery().

Enable/disable state recovery procedures while the file is open for writing or read/write

References pDoRecoverWrite, and pMutex.

Referenced by XrdCl::File::EnableWriteRecovery().

void XrdCl::FileStateHandler::FailMessage ( RequestData  rd,
XRootDStatus  status 
) [private]

Fail queued messages.

References FailMessage(), and pToBeRecovered.

Referenced by OnOpen(), and RunRecovery().

Get the data server the file is accessed at.

References XrdCl::URL::GetHostId(), pDataServer, and pMutex.

Referenced by XrdCl::File::GetDataServer().

Get final url with all the cgi information.

References pDataServer, and pMutex.

Referenced by XrdCl::File::GetLastURL().

Check if the file is open.

References Opened, pFileState, pMutex, and Recovering.

Referenced by XrdCl::File::IsOpen().

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

Check if the file is open for read only.

References kXR_open_apnd, kXR_open_read, kXR_open_updt, and pOpenFlags.

Referenced by AfterForkChild(), Close(), IsRecoverable(), and RunRecovery().

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

Check if the stateful error is recoverable.

References XrdCl::Status::code, XrdCl::errInvalidSession, XrdCl::errSocketError, IsReadOnly(), pDoRecoverRead, and pDoRecoverWrite.

Referenced by OnStateError(), and SendOrQueue().

void XrdCl::FileStateHandler::Lock ( ) [inline]

Lock the internal lock.

References XrdSysMutex::Lock(), and pMutex.

void XrdCl::FileStateHandler::MonitorClose ( const XRootDStatus *  status) [private]
void XrdCl::FileStateHandler::OnOpen ( const XRootDStatus *  status,
const OpenInfo *  openInfo,
const HostList *  hostList 
)
void XrdCl::FileStateHandler::OnStateError ( XRootDStatus *  status,
Message *  message,
ResponseHandler *  userHandler,
MessageSendParams &  sendParams 
)
void XrdCl::FileStateHandler::OnStateRedirection ( RedirectInfo *  redirectInfo,
Message *  message,
ResponseHandler *  userHandler,
MessageSendParams &  sendParams 
)
void XrdCl::FileStateHandler::OnStateResponse ( XRootDStatus *  status,
Message *  message,
AnyObject *  response,
HostList *  hostList 
)
XRootDStatus XrdCl::FileStateHandler::Open ( const std::string &  url,
uint16_t  flags,
uint16_t  mode,
ResponseHandler *  handler,
uint16_t  timeout = 0 
)
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:
offsetoffset from the beginning of the file
sizenumber of bytes to be read
buffera pointer to a buffer big enough to hold the data or 0 if the buffer should be allocated by the system
handlerhandler 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
timeouttimeout value, if 0 the environment default will be used
Returns:
status of the operation

References XrdCl::MessageSendParams::chunkList, XrdCl::MessageUtils::CreateRequest(), XrdCl::Log::Debug(), XrdCl::errInvalidOp, ClientReadRequest::fhandle, XrdCl::FileMsg, XrdCl::MessageSendParams::followRedirects, XrdCl::URL::GetHostId(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetURL(), kXR_read, ClientReadRequest::offset, Opened, pDataServer, pFileHandle, pFileState, pFileUrl, pMutex, XrdCl::MessageUtils::ProcessSendParams(), Recovering, ClientReadRequest::requestid, ClientReadRequest::rlen, SendOrQueue(), XrdCl::XRootDTransport::SetDescription(), XrdCl::MessageSendParams::stateful, XrdCl::stError, and XrdCl::MessageSendParams::timeout.

Referenced by XrdCl::File::Read().

Status XrdCl::FileStateHandler::RecoverMessage ( RequestData  rd,
bool  callbackOnFailure = true 
) [private]

Recover a message

Parameters:
rdrequest data associated with the message
callbackOnFailureshould the current handler be called back if the recovery procedure fails

References XrdCl::Log::Dump(), FailMessage(), XrdCl::FileMsg, XrdCl::Message::GetDescription(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetURL(), XrdCl::Status::IsOK(), pFileState, pFileUrl, pToBeRecovered, Recovering, XrdCl::FileStateHandler::RequestData::request, and RunRecovery().

Referenced by OnStateError(), OnStateRedirection(), and SendOrQueue().

Status XrdCl::FileStateHandler::ReOpenFileAtServer ( const URL &  url,
uint16_t  timeout 
) [private]

Reset monitoring vars.

References pCloseReason, pOpenTime, pRBytes, pRCount, pVBytes, pVCount, pVSegs, pWBytes, and pWCount.

Referenced by FileStateHandler(), OnClose(), and ~FileStateHandler().

Status XrdCl::FileStateHandler::SendOrQueue ( const URL &  url,
Message *  msg,
ResponseHandler *  handler,
MessageSendParams &  sendParams 
) [private]
XRootDStatus XrdCl::FileStateHandler::Stat ( bool  force,
ResponseHandler *  handler,
uint16_t  timeout = 0 
)

Obtain status information for this file - async

Parameters:
forcedo not use the cached information, force re-stating
handlerhandler to be notified when the response arrives, the response parameter will hold a StatInfo object if the procedure is successful
timeouttimeout value, if 0 the environment default will be used
Returns:
status of the operation

References XrdCl::Buffer::Append(), XrdCl::MessageUtils::CreateRequest(), XrdCl::Log::Debug(), ClientStatRequest::dlen, XrdCl::errInvalidOp, XrdCl::FileMsg, XrdCl::MessageSendParams::followRedirects, XrdCl::URL::GetHostId(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetPath(), XrdCl::URL::GetURL(), XrdCl::ResponseHandler::HandleResponseWithHosts(), kXR_stat, Opened, pDataServer, pFileHandle, pFileState, pFileUrl, pMutex, XrdCl::MessageUtils::ProcessSendParams(), pStatInfo, Recovering, ClientStatRequest::requestid, SendOrQueue(), XrdCl::AnyObject::Set(), XrdCl::XRootDTransport::SetDescription(), XrdCl::MessageSendParams::stateful, XrdCl::stError, and XrdCl::MessageSendParams::timeout.

Referenced by XrdCl::File::Stat().

XRootDStatus XrdCl::FileStateHandler::Sync ( ResponseHandler *  handler,
uint16_t  timeout = 0 
)
void XrdCl::FileStateHandler::Tick ( time_t  now)

Tick.

References pMutex, and TimeOutRequests().

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

Unlock the internal lock.

References pMutex, and XrdSysMutex::UnLock().

XRootDStatus XrdCl::FileStateHandler::VectorRead ( const ChunkList &  chunks,
void *  buffer,
ResponseHandler *  handler,
uint16_t  timeout = 0 
)
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:
offsetoffset from the beginning of the file
sizenumber of bytes to be written
buffera pointer to the buffer holding the data to be written
handlerhandler to be notified when the response arrives
timeouttimeout value, if 0 the environment default will be used
Returns:
status of the operation

References XrdCl::MessageSendParams::chunkList, XrdCl::MessageUtils::CreateRequest(), XrdCl::Log::Debug(), ClientWriteRequest::dlen, XrdCl::errInvalidOp, ClientWriteRequest::fhandle, XrdCl::FileMsg, XrdCl::MessageSendParams::followRedirects, XrdCl::URL::GetHostId(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetURL(), kXR_write, ClientWriteRequest::offset, Opened, pDataServer, pFileHandle, pFileState, pFileUrl, pMutex, XrdCl::MessageUtils::ProcessSendParams(), Recovering, ClientWriteRequest::requestid, SendOrQueue(), XrdCl::XRootDTransport::SetDescription(), XrdCl::MessageSendParams::stateful, XrdCl::stError, and XrdCl::MessageSendParams::timeout.

Referenced by XrdCl::File::Write().


Member Data Documentation

Referenced by Open(), and ReOpenFileAtServer().

Referenced by OnStateRedirection(), and RunRecovery().

Referenced by Close(), OnClose(), OnOpen(), and Open().

uint64_t XrdCl::FileStateHandler::pVSegs [private]

The documentation for this class was generated from the following files: